-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
63 lines (62 loc) · 2.64 KB
/
.eslintrc.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-patch/modern-module-resolution');
module.exports = {
extends: ['plugin:@croct/typescript'],
root: true,
plugins: ['@croct'],
parserOptions: {
project: ['./tsconfig.json'],
},
overrides: [
{
files: ['src/**/*.ts'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: 'CallExpression[arguments.length=0] '
+ "> MemberExpression[object.name='Instant'][property.name='now']",
message: 'Do not use Instant.now without a clock.',
},
{
selector: 'CallExpression[arguments.length=0] '
+ "> MemberExpression[object.name='LocalDateTime'][property.name='now']",
message: 'Do not use LocalDateTime.now without a clock.',
},
{
selector: 'CallExpression[arguments.length=1] '
+ "> MemberExpression[object.name='LocalDateTime'][property.name='nowIn']",
message: 'Do not use LocalDateTime.nowIn without a clock.',
},
{
selector: 'CallExpression[arguments.length=0] '
+ "> MemberExpression[object.name='Date'][property.name='now']",
message: 'Do not use Date.now, use a clock.',
},
{
selector: "NewExpression[callee.name='Date']",
message: 'Do not create a Date instance, use a clock.',
},
],
},
},
{
files: ['test/**/*.ts'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: "CallExpression[callee.object.name='jest'][callee.property.name='spyOn'] "
+ "> Identifier[name='Instant'] ~ Literal[value='now']",
message: 'Do not mock Instant.now, use a FixedClock.',
},
{
selector: "CallExpression[callee.object.name='jest'][callee.property.name='spyOn'] "
+ "> Identifier[name='LocalDateTime'] ~ Literal[value='now']",
message: 'Do not mock LocalDateTime.now, use a FixedClock.',
},
],
},
},
],
};