@@ -16,19 +16,27 @@ const eslintPluginTestsRecommendedConfig = require("eslint-plugin-eslint-plugin/
1616const globals = require ( "globals" ) ;
1717const eslintConfigESLintCJS = require ( "eslint-config-eslint/cjs" ) ;
1818const eslintConfigESLintFormatting = require ( "eslint-config-eslint/formatting" ) ;
19+ const json = require ( "@eslint/json" ) ;
1920
2021//-----------------------------------------------------------------------------
2122// Helpers
2223//-----------------------------------------------------------------------------
2324
24- const INTERNAL_FILES = {
25+ const INTERNAL_PATHS = {
2526 CLI_ENGINE_PATTERN : "lib/cli-engine/**/*" ,
2627 LINTER_PATTERN : "lib/linter/**/*" ,
2728 RULE_TESTER_PATTERN : "lib/rule-tester/**/*" ,
2829 RULES_PATTERN : "lib/rules/**/*" ,
2930 SOURCE_CODE_PATTERN : "lib/source-code/**/*"
3031} ;
3132
33+ // same paths but with `.js` at the end
34+ const INTERNAL_FILES = Object . fromEntries (
35+ Object . entries ( INTERNAL_PATHS ) . map ( ( [ key , value ] ) => [ key , `${ value } .js` ] )
36+ ) ;
37+
38+ const ALL_JS_FILES = "**/*.js" ;
39+
3240/**
3341 * Resolve an absolute path or glob pattern.
3442 * @param {string } pathOrPattern the path or glob pattern.
@@ -44,7 +52,7 @@ function resolveAbsolutePath(pathOrPattern) {
4452 * @returns {Object[] } The array of `no-restricted-require` entries.
4553 */
4654function createInternalFilesPatterns ( pattern = null ) {
47- return Object . values ( INTERNAL_FILES )
55+ return Object . values ( INTERNAL_PATHS )
4856 . filter ( p => p !== pattern )
4957 . map ( p => ( {
5058 name : [
@@ -59,8 +67,16 @@ function createInternalFilesPatterns(pattern = null) {
5967}
6068
6169module . exports = [
62- ...eslintConfigESLintCJS ,
63- eslintConfigESLintFormatting ,
70+ ...eslintConfigESLintCJS . map ( config => ( {
71+ ...config ,
72+ name : `eslint/${ config . name } ` ,
73+ files : [ ALL_JS_FILES ]
74+ } ) ) ,
75+ {
76+ ...eslintConfigESLintFormatting ,
77+ name : "eslint/formatting" ,
78+ files : [ ALL_JS_FILES ]
79+ } ,
6480 {
6581 name : "eslint/global-ignores" ,
6682 ignores : [
@@ -74,11 +90,13 @@ module.exports = [
7490 "tests/fixtures/**" ,
7591 "tests/performance/**" ,
7692 "tmp/**" ,
77- "**/test.js"
93+ "**/test.js" ,
94+ ".vscode"
7895 ]
7996 } ,
8097 {
8198 name : "eslint/internal-rules" ,
99+ files : [ ALL_JS_FILES ] ,
82100 plugins : {
83101 "internal-rules" : internalPlugin
84102 } ,
@@ -99,7 +117,7 @@ module.exports = [
99117 } ,
100118 {
101119 name : "eslint/rules" ,
102- files : [ "lib/rules/*" , "tools/internal-rules/*" ] ,
120+ files : [ "lib/rules/*.js " , "tools/internal-rules/*.js " ] ,
103121 ignores : [ "**/index.js" ] ,
104122 ...eslintPluginRulesRecommendedConfig ,
105123 rules : {
@@ -113,15 +131,15 @@ module.exports = [
113131 } ,
114132 {
115133 name : "eslint/core-rules" ,
116- files : [ "lib/rules/*" ] ,
134+ files : [ "lib/rules/*.js " ] ,
117135 ignores : [ "**/index.js" ] ,
118136 rules : {
119137 "eslint-plugin/require-meta-docs-url" : [ "error" , { pattern : "https://eslint.org/docs/latest/rules/{{name}}" } ]
120138 }
121139 } ,
122140 {
123141 name : "eslint/rules-tests" ,
124- files : [ "tests/lib/rules/*" , "tests/tools/internal-rules/*" ] ,
142+ files : [ "tests/lib/rules/*.js " , "tests/tools/internal-rules/*.js " ] ,
125143 ...eslintPluginTestsRecommendedConfig ,
126144 rules : {
127145 ...eslintPluginTestsRecommendedConfig . rules ,
@@ -156,10 +174,27 @@ module.exports = [
156174 }
157175 } ,
158176
177+ // JSON files
178+ {
179+ name : "eslint/json" ,
180+ files : [ "**/*.json" , ".c8rc" ] ,
181+ ignores : [ "**/package-lock.json" ] ,
182+ language : "json/json" ,
183+ ...json . configs . recommended
184+ } ,
185+
186+ // JSONC files
187+ {
188+ name : "eslint/jsonc" ,
189+ files : [ "knip.jsonc" ] ,
190+ language : "json/jsonc" ,
191+ ...json . configs . recommended
192+ } ,
193+
159194 // Restrict relative path imports
160195 {
161196 name : "eslint/lib" ,
162- files : [ "lib/*" ] ,
197+ files : [ "lib/*.js " ] ,
163198 ignores : [ "lib/unsupported-api.js" ] ,
164199 rules : {
165200 "n/no-restricted-require" : [ "error" , [
@@ -172,7 +207,7 @@ module.exports = [
172207 files : [ INTERNAL_FILES . CLI_ENGINE_PATTERN ] ,
173208 rules : {
174209 "n/no-restricted-require" : [ "error" , [
175- ...createInternalFilesPatterns ( INTERNAL_FILES . CLI_ENGINE_PATTERN )
210+ ...createInternalFilesPatterns ( INTERNAL_PATHS . CLI_ENGINE_PATTERN )
176211 ] ]
177212 }
178213 } ,
@@ -181,7 +216,7 @@ module.exports = [
181216 files : [ INTERNAL_FILES . LINTER_PATTERN ] ,
182217 rules : {
183218 "n/no-restricted-require" : [ "error" , [
184- ...createInternalFilesPatterns ( INTERNAL_FILES . LINTER_PATTERN ) ,
219+ ...createInternalFilesPatterns ( INTERNAL_PATHS . LINTER_PATTERN ) ,
185220 "fs" ,
186221 resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
187222 resolveAbsolutePath ( "lib/rule-tester/index.js" )
@@ -193,7 +228,7 @@ module.exports = [
193228 files : [ INTERNAL_FILES . RULES_PATTERN ] ,
194229 rules : {
195230 "n/no-restricted-require" : [ "error" , [
196- ...createInternalFilesPatterns ( INTERNAL_FILES . RULES_PATTERN ) ,
231+ ...createInternalFilesPatterns ( INTERNAL_PATHS . RULES_PATTERN ) ,
197232 "fs" ,
198233 resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
199234 resolveAbsolutePath ( "lib/linter/index.js" ) ,
@@ -204,7 +239,7 @@ module.exports = [
204239 } ,
205240 {
206241 name : "eslint/shared" ,
207- files : [ "lib/shared/**/*" ] ,
242+ files : [ "lib/shared/**/*.js " ] ,
208243 rules : {
209244 "n/no-restricted-require" : [ "error" , [
210245 ...createInternalFilesPatterns ( ) ,
@@ -220,7 +255,7 @@ module.exports = [
220255 files : [ INTERNAL_FILES . SOURCE_CODE_PATTERN ] ,
221256 rules : {
222257 "n/no-restricted-require" : [ "error" , [
223- ...createInternalFilesPatterns ( INTERNAL_FILES . SOURCE_CODE_PATTERN ) ,
258+ ...createInternalFilesPatterns ( INTERNAL_PATHS . SOURCE_CODE_PATTERN ) ,
224259 "fs" ,
225260 resolveAbsolutePath ( "lib/cli-engine/index.js" ) ,
226261 resolveAbsolutePath ( "lib/linter/index.js" ) ,
0 commit comments