add ESLint rules to warn about native date/time functions

This commit is contained in:
Hazelnoot 2025-10-01 20:26:04 -04:00
parent 2b4b5fd32c
commit 9c96dca5a6

View file

@ -51,6 +51,36 @@ export default [
}],
},
},
{
files: ['src/**/*.ts'],
rules: {
'no-restricted-globals': [
'error',
{
name: 'setTimeout',
message: 'Use TimeService.startTimer instead.',
}, {
name: 'setInterval',
message: 'Use TimeService.startTimer instead.',
}
],
'no-restricted-properties': [
'error',
{
object: 'Date',
property: 'now',
message: 'Use TimeService.now instead.',
},
],
'no-restricted-syntax': [
'error',
{
"selector": "NewExpression[callee.name='Date'][arguments.length=0]",
"message": "new Date() is restricted. Use TimeService.date instead."
}
],
}
},
{
files: ['src/server/web/**/*.js', 'src/server/web/**/*.ts'],
languageOptions: {