@@ -15,15 +15,9 @@ import { fileURLToPath } from 'url';
1515
1616const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
1717
18- export default defineConfig ( [
18+ const config = [
1919 {
20- ignores : [
21- 'benchmark/downloads' ,
22- 'benchmark/remotes' ,
23- 'dist' ,
24- 'node_modules' ,
25- 'types' ,
26- ] ,
20+ ignores : [ 'benchmark/downloads' , 'benchmark/remotes' , 'dist' , 'node_modules' , 'types' ] ,
2721 } ,
2822 js . configs . recommended ,
2923 {
@@ -40,8 +34,8 @@ export default defineConfig([
4034 rules : {
4135 ...prettierPlugin . configs . recommended . rules ,
4236
43- 'no-use-before-define' : [ 'error ' , { 'functions' : false , 'classes' : false } ] ,
44- 'eqeqeq' : [ 'error ' , 'always' , { 'null' : 'ignore' } ] ,
37+ 'no-use-before-define' : [ 'warn ' , { 'functions' : false , 'classes' : false } ] ,
38+ 'eqeqeq' : [ 'warn ' , 'always' , { 'null' : 'ignore' } ] ,
4539
4640 // imports
4741 'import/extensions' : [ 'warn' , 'never' ] ,
@@ -63,12 +57,12 @@ export default defineConfig([
6357 'sort-imports' : [ 'warn' , { ignoreDeclarationSort : true } ] ,
6458
6559 // stylistic rules
66- 'no-var' : 'error ' ,
60+ 'no-var' : 'warn ' ,
6761 'object-shorthand' : [ 'warn' , 'always' , { avoidQuotes : true } ] ,
6862 'one-var' : [ 'warn' , 'never' ] ,
6963 'prefer-arrow-callback' : 'warn' ,
7064 'prefer-const' : [ 'warn' , { 'destructuring' : 'all' } ] ,
71- 'prefer-spread' : 'error ' ,
65+ 'prefer-spread' : 'warn ' ,
7266
7367 // JSDoc
7468 'jsdoc/check-alignment' : 'warn' ,
@@ -83,18 +77,18 @@ export default defineConfig([
8377 'jsdoc/require-property-name' : 'warn' ,
8478
8579 // regexp
86- 'regexp/no-dupe-disjunctions' : 'error ' ,
87- 'regexp/no-empty-alternative' : 'error ' ,
88- 'regexp/no-empty-capturing-group' : 'error ' ,
89- 'regexp/no-empty-lookarounds-assertion' : 'error ' ,
90- 'regexp/no-lazy-ends' : 'error ' ,
91- 'regexp/no-obscure-range' : 'error ' ,
92- 'regexp/no-optional-assertion' : 'error ' ,
93- 'regexp/no-standalone-backslash' : 'error ' ,
94- 'regexp/no-super-linear-backtracking' : 'error ' ,
95- 'regexp/no-unused-capturing-group' : 'error ' ,
96- 'regexp/no-zero-quantifier' : 'error ' ,
97- 'regexp/optimal-lookaround-quantifier' : 'error ' ,
80+ 'regexp/no-dupe-disjunctions' : 'warn ' ,
81+ 'regexp/no-empty-alternative' : 'warn ' ,
82+ 'regexp/no-empty-capturing-group' : 'warn ' ,
83+ 'regexp/no-empty-lookarounds-assertion' : 'warn ' ,
84+ 'regexp/no-lazy-ends' : 'warn ' ,
85+ 'regexp/no-obscure-range' : 'warn ' ,
86+ 'regexp/no-optional-assertion' : 'warn ' ,
87+ 'regexp/no-standalone-backslash' : 'warn ' ,
88+ 'regexp/no-super-linear-backtracking' : 'warn ' ,
89+ 'regexp/no-unused-capturing-group' : 'warn ' ,
90+ 'regexp/no-zero-quantifier' : 'warn ' ,
91+ 'regexp/optimal-lookaround-quantifier' : 'warn ' ,
9892
9993 'regexp/match-any' : 'warn' ,
10094 'regexp/negation' : 'warn' ,
@@ -168,7 +162,7 @@ export default defineConfig([
168162 'no-empty-character-class' : 'off' ,
169163 'no-useless-escape' : 'off' ,
170164
171- 'eslint-comments/disable-enable-pair' : [ 'error ' , { allowWholeFile : true } ] ,
165+ 'eslint-comments/disable-enable-pair' : [ 'warn ' , { allowWholeFile : true } ] ,
172166
173167 // Allow {} type
174168 '@typescript-eslint/no-empty-object-type' : 'off' ,
@@ -268,4 +262,46 @@ export default defineConfig([
268262 } ,
269263 } ,
270264 } ,
271- ] ) ;
265+ ] ;
266+
267+ export default defineConfig ( replaceErrorsWithWarnings ( config ) ) ;
268+
269+ /*
270+ * Many recommended ESLint configs (such as those from @typescript-eslint) default to "error" severity for some rules.
271+ * However, we want all rules only to warn, not error.
272+ * This function recursively traverses the config and downgrades all "error" severities to "warn".
273+ * This ensures a consistent linting experience, even when extending third-party configs that use "error" by default.
274+ */
275+ function replaceErrorsWithWarnings ( config ) {
276+ if ( Array . isArray ( config ) ) {
277+ return config . map ( replaceErrorsWithWarnings ) ;
278+ }
279+
280+ if ( typeof config === 'object' && config !== null ) {
281+ const newConfig = { ...config } ;
282+
283+ if ( newConfig . rules ) {
284+ newConfig . rules = Object . fromEntries (
285+ Object . entries ( newConfig . rules ) . map ( ( [ rule , setting ] ) => {
286+ if ( setting === 'error' || setting === 2 ) {
287+ return [ rule , 'warn' ] ;
288+ }
289+
290+ if ( Array . isArray ( setting ) && ( setting [ 0 ] === 'error' || setting [ 0 ] === 2 ) ) {
291+ return [ rule , [ 'warn' , ...setting . slice ( 1 ) ] ] ;
292+ }
293+
294+ return [ rule , setting ] ;
295+ } )
296+ ) ;
297+ }
298+
299+ if ( newConfig . overrides ) {
300+ newConfig . overrides = replaceErrorsWithWarnings ( newConfig . overrides ) ;
301+ }
302+
303+ return newConfig ;
304+ }
305+
306+ return config ;
307+ }
0 commit comments