-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
eslint.config.js
157 lines (154 loc) · 3.49 KB
/
eslint.config.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
"use strict";
const js = require('@eslint/js');
const globals = require('globals');
const messages = {
gh237: 'See https://github.com/mochajs/mocha/issues/237',
gh3604: 'See https://github.com/mochajs/mocha/issues/3604'
};
module.exports = [
{
...js.configs.recommended,
languageOptions: {
ecmaVersion: 2020,
globals: {
...globals.browser,
...globals.node
},
sourceType: 'script'
},
rules: {
'no-var': 'off',
strict: ['error', 'global']
}
},
{
files: ['docs/js/**/*.js'],
languageOptions: {
globals: globals.browser
}
},
{
files: [
'.eleventy.js',
'.wallaby.js',
'package-scripts.js',
'karma.conf.js',
'bin/*',
'docs/_data/**/*.js',
'lib/cli/**/*.js',
'lib/nodejs/**/*.js',
'scripts/**/*.{js,mjs}',
'test/**/*.{js,mjs}',
'test/node-unit/**/*.js'
],
languageOptions: {
globals: globals.node,
ecmaVersion: 2020,
}
},
{
files: [
'lib/nodejs/esm-utils.js',
'rollup.config.js',
'scripts/*.mjs',
'scripts/pick-from-package-json.js'
],
languageOptions: {
sourceType: 'module'
}
},
{
files: ['test/**/*.{js,mjs}'],
languageOptions: {
globals: {
...globals.browser,
...globals.mocha,
...globals.node,
expect: 'readonly'
}
}
},
{
files: ['test/**/*.mjs'],
languageOptions: {
sourceType: "module"
},
},
{
files: ['bin/*', 'lib/**/*.js'],
rules: {
'no-restricted-globals': [
'error',
{
message: messages.gh237,
name: 'setTimeout'
},
{
message: messages.gh237,
name: 'clearTimeout'
},
{
message: messages.gh237,
name: 'setInterval'
},
{
message: messages.gh237,
name: 'clearInterval'
},
{
message: messages.gh237,
name: 'setImmediate'
},
{
message: messages.gh237,
name: 'clearImmediate'
},
{
message: messages.gh237,
name: 'Date'
}
],
'no-restricted-modules': ['error', 'timers'],
"no-restricted-syntax": ['error',
// disallow `global.setTimeout()`, `global.setInterval()`, etc.
{
message: messages.gh237,
selector: 'CallExpression[callee.object.name=global][callee.property.name=/(set|clear)(Timeout|Immediate|Interval)/]'
},
// disallow `new global.Date()`
{
message: messages.gh237,
selector: 'NewExpression[callee.object.name=global][callee.property.name=Date]'
},
// disallow property access of `global.<timer>.*`
{
message: messages.gh237,
selector: '*[object.object.name=global][object.property.name=/(Date|(set|clear)(Timeout|Immediate|Interval))/]:expression'
}
]
}
},
{
files: ['lib/reporters/*.js'],
rules: {
'no-restricted-syntax': ['error',
// disallow Reporters using `console.log()`
{
message: messages.gh3604,
selector: 'CallExpression[callee.object.name=console][callee.property.name=log]'
}
]
}
},
{
ignores: [
'**/*.{fixture,min}.{js,mjs}',
'coverage/**',
'docs/{_dist,_site,api,example}/**',
'out/**',
'test/integration/fixtures/**',
'.karma/**',
'mocha.js'
],
}
];