Skip to content

Commit 83c66c4

Browse files
authored
Eslint camelCase (#1625)
* Add eslint rule to flag up me forgetting to camelCase - I'd say I introduced all the snake_cases that are fixed here * Allow some dubious snake cases for now; we could examine again whether they can be converted to `camelCase['snake_var']` if we need to maintain backwards compatibility of output * add ESLINT_USE_FLAT_CONFIG against eslint v8.57.0 in order to continue using the deprecated .eslintrc.js method
1 parent 24f5fd9 commit 83c66c4

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.eslintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ module.exports = {
2323
rules: {
2424
'tsdoc/syntax': 'warn',
2525
'@typescript-eslint/prefer-as-const': 'warn',
26+
'camelcase': ['error', {
27+
allow: ['rr_.*', 'legacy_.*', 'UNSAFE_.*', '__rrweb_.*'],
28+
}],
2629
},
2730
};

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
"dev": "yarn turbo run dev --concurrency=18",
5454
"repl": "cd packages/rrweb && npm run repl",
5555
"live-stream": "cd packages/rrweb && yarn live-stream",
56-
"lint": "yarn run concurrently --success=all -r -m=1 'yarn run markdownlint docs' 'yarn eslint packages/*/src --ext .ts,.tsx,.js,.jsx,.svelte'",
57-
"lint:report": "yarn eslint --output-file eslint_report.json --format json packages/*/src --ext .ts,.tsx,.js,.jsx",
56+
"lint": "yarn run concurrently --success=all -r -m=1 'yarn run markdownlint docs' 'ESLINT_USE_FLAT_CONFIG=false yarn eslint packages/*/src --ext .ts,.tsx,.js,.jsx,.svelte'",
57+
"lint:report": "ESLINT_USE_FLAT_CONFIG=false yarn eslint --output-file eslint_report.json --format json packages/*/src --ext .ts,.tsx,.js,.jsx",
5858
"release": "yarn build:all && changeset publish"
5959
},
6060
"resolutions": {

packages/rrweb/src/replay/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -760,30 +760,30 @@ export class Replayer {
760760
this.service.send({ type: 'CAST_EVENT', payload: { event } });
761761

762762
// events are kept sorted by timestamp, check if this is the last event
763-
const last_index = this.service.state.context.events.length - 1;
763+
const lastIndex = this.service.state.context.events.length - 1;
764764
if (
765765
!this.config.liveMode &&
766-
event === this.service.state.context.events[last_index]
766+
event === this.service.state.context.events[lastIndex]
767767
) {
768768
const finish = () => {
769-
if (last_index < this.service.state.context.events.length - 1) {
769+
if (lastIndex < this.service.state.context.events.length - 1) {
770770
// more events have been added since the setTimeout
771771
return;
772772
}
773773
this.backToNormal();
774774
this.service.send('END');
775775
this.emitter.emit(ReplayerEvents.Finish);
776776
};
777-
let finish_buffer = 50; // allow for checking whether new events aren't just about to be loaded in
777+
let finishBuffer = 50; // allow for checking whether new events aren't just about to be loaded in
778778
if (
779779
event.type === EventType.IncrementalSnapshot &&
780780
event.data.source === IncrementalSource.MouseMove &&
781781
event.data.positions.length
782782
) {
783783
// 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
784-
finish_buffer += Math.max(0, -event.data.positions[0].timeOffset);
784+
finishBuffer += Math.max(0, -event.data.positions[0].timeOffset);
785785
}
786-
setTimeout(finish, finish_buffer);
786+
setTimeout(finish, finishBuffer);
787787
}
788788

789789
this.emitter.emit(ReplayerEvents.EventCast, event);

0 commit comments

Comments
 (0)