5
5
6
6
"use strict" ;
7
7
8
+ /*
9
+ * IMPORTANT!
10
+ *
11
+ * Any changes made to this file must also be made to .eslintrc.js.
12
+ *
13
+ * Internally, ESLint is using the eslint.config.js file to lint itself.
14
+ * The .eslintrc.js file is needed too, because:
15
+ *
16
+ * 1. There are tests that expect .eslintrc.js to be present to actually run.
17
+ * 2. ESLint VS Code extension expects eslintrc config files to be
18
+ * present to work correctly.
19
+ *
20
+ * Once we no longer need to support both eslintrc and flat config, we will
21
+ * remove .eslintrc.js.
22
+ */
23
+
8
24
//-----------------------------------------------------------------------------
9
25
// Requirements
10
26
//-----------------------------------------------------------------------------
11
27
12
28
const path = require ( "path" ) ;
13
29
const internalPlugin = require ( "eslint-plugin-internal-rules" ) ;
30
+ const eslintPlugin = require ( "eslint-plugin-eslint-plugin" ) ;
14
31
const { FlatCompat } = require ( "@eslint/eslintrc" ) ;
15
32
const globals = require ( "globals" ) ;
16
33
@@ -24,7 +41,6 @@ const compat = new FlatCompat({
24
41
25
42
const INTERNAL_FILES = {
26
43
CLI_ENGINE_PATTERN : "lib/cli-engine/**/*" ,
27
- INIT_PATTERN : "lib/init/**/*" ,
28
44
LINTER_PATTERN : "lib/linter/**/*" ,
29
45
RULE_TESTER_PATTERN : "lib/rule-tester/**/*" ,
30
46
RULES_PATTERN : "lib/rules/**/*" ,
@@ -60,11 +76,6 @@ function createInternalFilesPatterns(pattern = null) {
60
76
} ) ) ;
61
77
}
62
78
63
-
64
- //-----------------------------------------------------------------------------
65
- // Config
66
- //-----------------------------------------------------------------------------
67
-
68
79
module . exports = [
69
80
...compat . extends ( "eslint" , "plugin:eslint-plugin/recommended" ) ,
70
81
{
@@ -101,13 +112,25 @@ module.exports = [
101
112
"eslint-plugin/test-case-shorthand-strings" : "error" ,
102
113
"internal-rules/multiline-comment-style" : "error"
103
114
}
104
-
115
+ } ,
116
+ {
117
+ files : [ "tools/*.js" ] ,
118
+ rules : {
119
+ "no-console" : "off"
120
+ }
105
121
} ,
106
122
{
107
123
files : [ "lib/rules/*" , "tools/internal-rules/*" ] ,
108
- ignores : [ "index.js" ] ,
124
+ ignores : [ "**/ index.js" ] ,
109
125
rules : {
110
- "eslint-plugin/prefer-object-rule" : "error" ,
126
+ ...eslintPlugin . configs [ "rules-recommended" ] . rules ,
127
+ "eslint-plugin/no-missing-message-ids" : "error" ,
128
+ "eslint-plugin/no-unused-message-ids" : "error" ,
129
+ "eslint-plugin/prefer-message-ids" : "error" ,
130
+ "eslint-plugin/prefer-placeholders" : "error" ,
131
+ "eslint-plugin/prefer-replace-text" : "error" ,
132
+ "eslint-plugin/report-message-format" : [ "error" , "[^a-z].*\\.$" ] ,
133
+ "eslint-plugin/require-meta-docs-description" : [ "error" , { pattern : "^(Enforce|Require|Disallow)" } ] ,
111
134
"internal-rules/no-invalid-meta" : "error"
112
135
}
113
136
} ,
@@ -119,7 +142,16 @@ module.exports = [
119
142
}
120
143
} ,
121
144
{
122
- files : [ "tests/**/*" ] ,
145
+ files : [ "tests/lib/rules/*" , "tests/tools/internal-rules/*" ] ,
146
+ rules : {
147
+ ...eslintPlugin . configs [ "tests-recommended" ] . rules ,
148
+ "eslint-plugin/prefer-output-null" : "error" ,
149
+ "eslint-plugin/test-case-property-ordering" : "error" ,
150
+ "eslint-plugin/test-case-shorthand-strings" : "error"
151
+ }
152
+ } ,
153
+ {
154
+ files : [ "tests/**/*.js" ] ,
123
155
languageOptions : {
124
156
globals : {
125
157
...globals . mocha
@@ -147,17 +179,7 @@ module.exports = [
147
179
files : [ INTERNAL_FILES . CLI_ENGINE_PATTERN ] ,
148
180
rules : {
149
181
"n/no-restricted-require" : [ "error" , [
150
- ...createInternalFilesPatterns ( INTERNAL_FILES . CLI_ENGINE_PATTERN ) ,
151
- resolveAbsolutePath ( "lib/init/index.js" )
152
- ] ]
153
- }
154
- } ,
155
- {
156
- files : [ INTERNAL_FILES . INIT_PATTERN ] ,
157
- rules : {
158
- "n/no-restricted-require" : [ "error" , [
159
- ...createInternalFilesPatterns ( INTERNAL_FILES . INIT_PATTERN ) ,
160
- resolveAbsolutePath ( "lib/rule-tester/index.js" )
182
+ ...createInternalFilesPatterns ( INTERNAL_FILES . CLI_ENGINE_PATTERN )
161
183
] ]
162
184
}
163
185
} ,
@@ -168,7 +190,6 @@ module.exports = [
168
190
...createInternalFilesPatterns ( INTERNAL_FILES . LINTER_PATTERN ) ,
169
191
"fs" ,
170
192
resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
171
- resolveAbsolutePath ( "lib/init/index.js" ) ,
172
193
resolveAbsolutePath ( "lib/rule-tester/index.js" )
173
194
] ]
174
195
}
@@ -180,7 +201,6 @@ module.exports = [
180
201
...createInternalFilesPatterns ( INTERNAL_FILES . RULES_PATTERN ) ,
181
202
"fs" ,
182
203
resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
183
- resolveAbsolutePath ( "lib/init/index.js" ) ,
184
204
resolveAbsolutePath ( "lib/linter/index.js" ) ,
185
205
resolveAbsolutePath ( "lib/rule-tester/index.js" ) ,
186
206
resolveAbsolutePath ( "lib/source-code/index.js" )
@@ -193,7 +213,6 @@ module.exports = [
193
213
"n/no-restricted-require" : [ "error" , [
194
214
...createInternalFilesPatterns ( ) ,
195
215
resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
196
- resolveAbsolutePath ( "lib/init/index.js" ) ,
197
216
resolveAbsolutePath ( "lib/linter/index.js" ) ,
198
217
resolveAbsolutePath ( "lib/rule-tester/index.js" ) ,
199
218
resolveAbsolutePath ( "lib/source-code/index.js" )
@@ -207,7 +226,6 @@ module.exports = [
207
226
...createInternalFilesPatterns ( INTERNAL_FILES . SOURCE_CODE_PATTERN ) ,
208
227
"fs" ,
209
228
resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
210
- resolveAbsolutePath ( "lib/init/index.js" ) ,
211
229
resolveAbsolutePath ( "lib/linter/index.js" ) ,
212
230
resolveAbsolutePath ( "lib/rule-tester/index.js" ) ,
213
231
resolveAbsolutePath ( "lib/rules/index.js" )
@@ -219,8 +237,7 @@ module.exports = [
219
237
rules : {
220
238
"n/no-restricted-require" : [ "error" , [
221
239
...createInternalFilesPatterns ( INTERNAL_FILES . RULE_TESTER_PATTERN ) ,
222
- resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
223
- resolveAbsolutePath ( "lib/init/index.js" )
240
+ resolveAbsolutePath ( "lib/cli-engine/index.js" )
224
241
] ]
225
242
}
226
243
}
0 commit comments