-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy patheslint.config.js
More file actions
35 lines (32 loc) · 1.01 KB
/
Copy patheslint.config.js
File metadata and controls
35 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import tseslint from 'typescript-eslint';
import reactHooks from 'eslint-plugin-react-hooks';
const DATE_NOW_BAN = {
selector: 'CallExpression[callee.object.name="Date"][callee.property.name="now"]',
message: 'Use TimeService.now() for simulated time or realNow() for real wall-clock time. See os/TimeService.ts.',
};
const NEW_DATE_BAN = {
selector: 'NewExpression[callee.name="Date"]',
message: 'Use TimeService.getDate() / fromTimestamp(ts) / fromLocalParts(y,m,d) instead of new Date(...). See os/TimeService.ts.',
};
export default [
{
files: ['os/**/*.{ts,tsx}', 'apps/**/*.{ts,tsx}', 'system/**/*.{ts,tsx}'],
languageOptions: {
parser: tseslint.parser,
},
plugins: {
'react-hooks': reactHooks,
},
rules: {
'no-restricted-syntax': ['error', DATE_NOW_BAN, NEW_DATE_BAN],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
{
files: ['os/TimeService.ts'],
rules: {
'no-restricted-syntax': 'off',
},
},
];