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
This commit is contained in:
2
.changeset/eslint-camelcase-devonly.md
Normal file
2
.changeset/eslint-camelcase-devonly.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
---
|
||||||
@@ -23,5 +23,8 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
'tsdoc/syntax': 'warn',
|
'tsdoc/syntax': 'warn',
|
||||||
'@typescript-eslint/prefer-as-const': 'warn',
|
'@typescript-eslint/prefer-as-const': 'warn',
|
||||||
|
'camelcase': ['error', {
|
||||||
|
allow: ['rr_.*', 'legacy_.*', 'UNSAFE_.*', '__rrweb_.*'],
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,8 +53,8 @@
|
|||||||
"dev": "yarn turbo run dev --concurrency=18",
|
"dev": "yarn turbo run dev --concurrency=18",
|
||||||
"repl": "cd packages/rrweb && npm run repl",
|
"repl": "cd packages/rrweb && npm run repl",
|
||||||
"live-stream": "cd packages/rrweb && yarn live-stream",
|
"live-stream": "cd packages/rrweb && yarn live-stream",
|
||||||
"lint": "yarn run concurrently --success=all -r -m=1 'yarn run markdownlint docs' 'yarn eslint packages/*/src --ext .ts,.tsx,.js,.jsx,.svelte'",
|
"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'",
|
||||||
"lint:report": "yarn eslint --output-file eslint_report.json --format json packages/*/src --ext .ts,.tsx,.js,.jsx",
|
"lint:report": "ESLINT_USE_FLAT_CONFIG=false yarn eslint --output-file eslint_report.json --format json packages/*/src --ext .ts,.tsx,.js,.jsx",
|
||||||
"release": "yarn build:all && changeset publish"
|
"release": "yarn build:all && changeset publish"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
|
|||||||
@@ -760,13 +760,13 @@ export class Replayer {
|
|||||||
this.service.send({ type: 'CAST_EVENT', payload: { event } });
|
this.service.send({ type: 'CAST_EVENT', payload: { event } });
|
||||||
|
|
||||||
// events are kept sorted by timestamp, check if this is the last 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 (
|
if (
|
||||||
!this.config.liveMode &&
|
!this.config.liveMode &&
|
||||||
event === this.service.state.context.events[last_index]
|
event === this.service.state.context.events[lastIndex]
|
||||||
) {
|
) {
|
||||||
const finish = () => {
|
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
|
// more events have been added since the setTimeout
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -774,16 +774,16 @@ export class Replayer {
|
|||||||
this.service.send('END');
|
this.service.send('END');
|
||||||
this.emitter.emit(ReplayerEvents.Finish);
|
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 (
|
if (
|
||||||
event.type === EventType.IncrementalSnapshot &&
|
event.type === EventType.IncrementalSnapshot &&
|
||||||
event.data.source === IncrementalSource.MouseMove &&
|
event.data.source === IncrementalSource.MouseMove &&
|
||||||
event.data.positions.length
|
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
|
// 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);
|
this.emitter.emit(ReplayerEvents.EventCast, event);
|
||||||
|
|||||||
Reference in New Issue
Block a user