Skip to content

Commit

Permalink
Add eslint rule to flag up me forgetting to camelCase - I'd say I int…
Browse files Browse the repository at this point in the history
…roduced all the ones that are fixed here
  • Loading branch information
eoghanmurray committed Jan 14, 2025
1 parent b812bcb commit 23675db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changeset/eslint-camelcase-devonly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
---

3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ module.exports = {
rules: {
'tsdoc/syntax': 'warn',
'@typescript-eslint/prefer-as-const': 'warn',
'camelcase': ['error', {
allow: ['rr_.*', 'legacy_.*', 'UNSAFE_.*', '__rrweb_.*'],
}],
},
};
12 changes: 6 additions & 6 deletions packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,30 +760,30 @@ export class Replayer {
this.service.send({ type: 'CAST_EVENT', payload: { event } });

// events are kept sorted by timestamp, check if this is the last event
const last_index = this.service.state.context.events.length - 1;
const lastIndex = this.service.state.context.events.length - 1;
if (
!this.config.liveMode &&
event === this.service.state.context.events[last_index]
event === this.service.state.context.events[lastIndex]
) {
const finish = () => {
if (last_index < this.service.state.context.events.length - 1) {
if (lastIndex < this.service.state.context.events.length - 1) {
// more events have been added since the setTimeout
return;
}
this.backToNormal();
this.service.send('END');
this.emitter.emit(ReplayerEvents.Finish);
};
let finish_buffer = 50; // allow for checking whether new events aren't just about to be loaded in
let finishBuffer = 50; // allow for checking whether new events aren't just about to be loaded in
if (
event.type === EventType.IncrementalSnapshot &&
event.data.source === IncrementalSource.MouseMove &&
event.data.positions.length
) {
// extend finish event if the last event is a mouse move so that the timer isn't stopped by the service before checking the last event
finish_buffer += Math.max(0, -event.data.positions[0].timeOffset);
finishBuffer += Math.max(0, -event.data.positions[0].timeOffset);
}
setTimeout(finish, finish_buffer);
setTimeout(finish, finishBuffer);
}

this.emitter.emit(ReplayerEvents.EventCast, event);
Expand Down

0 comments on commit 23675db

Please sign in to comment.