55
66"use strict" ;
77
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+
824//-----------------------------------------------------------------------------
925// Requirements
1026//-----------------------------------------------------------------------------
1127
1228const path = require ( "path" ) ;
1329const internalPlugin = require ( "eslint-plugin-internal-rules" ) ;
30+ const eslintPlugin = require ( "eslint-plugin-eslint-plugin" ) ;
1431const { FlatCompat } = require ( "@eslint/eslintrc" ) ;
1532const globals = require ( "globals" ) ;
1633
@@ -24,7 +41,6 @@ const compat = new FlatCompat({
2441
2542const INTERNAL_FILES = {
2643 CLI_ENGINE_PATTERN : "lib/cli-engine/**/*" ,
27- INIT_PATTERN : "lib/init/**/*" ,
2844 LINTER_PATTERN : "lib/linter/**/*" ,
2945 RULE_TESTER_PATTERN : "lib/rule-tester/**/*" ,
3046 RULES_PATTERN : "lib/rules/**/*" ,
@@ -60,11 +76,6 @@ function createInternalFilesPatterns(pattern = null) {
6076 } ) ) ;
6177}
6278
63-
64- //-----------------------------------------------------------------------------
65- // Config
66- //-----------------------------------------------------------------------------
67-
6879module . exports = [
6980 ...compat . extends ( "eslint" , "plugin:eslint-plugin/recommended" ) ,
7081 {
@@ -101,13 +112,25 @@ module.exports = [
101112 "eslint-plugin/test-case-shorthand-strings" : "error" ,
102113 "internal-rules/multiline-comment-style" : "error"
103114 }
104-
115+ } ,
116+ {
117+ files : [ "tools/*.js" ] ,
118+ rules : {
119+ "no-console" : "off"
120+ }
105121 } ,
106122 {
107123 files : [ "lib/rules/*" , "tools/internal-rules/*" ] ,
108- ignores : [ "index.js" ] ,
124+ ignores : [ "**/ index.js" ] ,
109125 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)" } ] ,
111134 "internal-rules/no-invalid-meta" : "error"
112135 }
113136 } ,
@@ -119,7 +142,16 @@ module.exports = [
119142 }
120143 } ,
121144 {
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" ] ,
123155 languageOptions : {
124156 globals : {
125157 ...globals . mocha
@@ -147,17 +179,7 @@ module.exports = [
147179 files : [ INTERNAL_FILES . CLI_ENGINE_PATTERN ] ,
148180 rules : {
149181 "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 )
161183 ] ]
162184 }
163185 } ,
@@ -168,7 +190,6 @@ module.exports = [
168190 ...createInternalFilesPatterns ( INTERNAL_FILES . LINTER_PATTERN ) ,
169191 "fs" ,
170192 resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
171- resolveAbsolutePath ( "lib/init/index.js" ) ,
172193 resolveAbsolutePath ( "lib/rule-tester/index.js" )
173194 ] ]
174195 }
@@ -180,7 +201,6 @@ module.exports = [
180201 ...createInternalFilesPatterns ( INTERNAL_FILES . RULES_PATTERN ) ,
181202 "fs" ,
182203 resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
183- resolveAbsolutePath ( "lib/init/index.js" ) ,
184204 resolveAbsolutePath ( "lib/linter/index.js" ) ,
185205 resolveAbsolutePath ( "lib/rule-tester/index.js" ) ,
186206 resolveAbsolutePath ( "lib/source-code/index.js" )
@@ -193,7 +213,6 @@ module.exports = [
193213 "n/no-restricted-require" : [ "error" , [
194214 ...createInternalFilesPatterns ( ) ,
195215 resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
196- resolveAbsolutePath ( "lib/init/index.js" ) ,
197216 resolveAbsolutePath ( "lib/linter/index.js" ) ,
198217 resolveAbsolutePath ( "lib/rule-tester/index.js" ) ,
199218 resolveAbsolutePath ( "lib/source-code/index.js" )
@@ -207,7 +226,6 @@ module.exports = [
207226 ...createInternalFilesPatterns ( INTERNAL_FILES . SOURCE_CODE_PATTERN ) ,
208227 "fs" ,
209228 resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
210- resolveAbsolutePath ( "lib/init/index.js" ) ,
211229 resolveAbsolutePath ( "lib/linter/index.js" ) ,
212230 resolveAbsolutePath ( "lib/rule-tester/index.js" ) ,
213231 resolveAbsolutePath ( "lib/rules/index.js" )
@@ -219,8 +237,7 @@ module.exports = [
219237 rules : {
220238 "n/no-restricted-require" : [ "error" , [
221239 ...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" )
224241 ] ]
225242 }
226243 }
0 commit comments