@@ -3,6 +3,26 @@ import typescript from '@typescript-eslint/eslint-plugin';
33import typescriptParser from '@typescript-eslint/parser' ;
44import globals from 'globals' ;
55
6+ // Shared TypeScript rules used by both base and test configurations
7+ const sharedTypeScriptRules = {
8+ ...typescript . configs . recommended . rules ,
9+ '@typescript-eslint/no-unused-vars' : [ 'error' , { argsIgnorePattern : '^_' } ] ,
10+ '@typescript-eslint/explicit-function-return-type' : [ 'error' , {
11+ allowExpressions : true ,
12+ allowTypedFunctionExpressions : true
13+ } ] ,
14+ // Enforce explicit return types for exported/public APIs
15+ '@typescript-eslint/explicit-module-boundary-types' : 'error' ,
16+ '@typescript-eslint/no-explicit-any' : 'error' ,
17+ '@typescript-eslint/no-inferrable-types' : 'off' ,
18+ '@typescript-eslint/strict-boolean-expressions' : [ 'error' , {
19+ allowNullableObject : true
20+ } ] ,
21+ 'prefer-const' : 'error' ,
22+ 'no-var' : 'error' ,
23+ 'no-unused-vars' : 'off' , // Turn off base rule as it can conflict with @typescript -eslint/no-unused-vars
24+ } ;
25+
626export default [
727 js . configs . recommended ,
828 {
@@ -29,24 +49,7 @@ export default [
2949 plugins : {
3050 '@typescript-eslint' : typescript ,
3151 } ,
32- rules : {
33- ...typescript . configs . recommended . rules ,
34- '@typescript-eslint/no-unused-vars' : [ 'error' , { argsIgnorePattern : '^_' } ] ,
35- '@typescript-eslint/explicit-function-return-type' : [ 'error' , {
36- allowExpressions : true ,
37- allowTypedFunctionExpressions : true
38- } ] ,
39- // Enforce explicit return types for exported/public APIs
40- '@typescript-eslint/explicit-module-boundary-types' : 'error' ,
41- '@typescript-eslint/no-explicit-any' : 'error' ,
42- '@typescript-eslint/no-inferrable-types' : 'off' ,
43- '@typescript-eslint/strict-boolean-expressions' : [ 'error' , {
44- allowNullableObject : true
45- } ] ,
46- 'prefer-const' : 'error' ,
47- 'no-var' : 'error' ,
48- 'no-unused-vars' : 'off' , // Turn off base rule as it can conflict with @typescript -eslint/no-unused-vars
49- } ,
52+ rules : sharedTypeScriptRules ,
5053 } ,
5154 {
5255 files : [ 'tests/**/*.ts' , '**/*.test.ts' , '**/*.spec.ts' ] ,
@@ -75,23 +78,7 @@ export default [
7578 plugins : {
7679 '@typescript-eslint' : typescript ,
7780 } ,
78- rules : {
79- ...typescript . configs . recommended . rules ,
80- '@typescript-eslint/no-unused-vars' : [ 'error' , { argsIgnorePattern : '^_' } ] ,
81- '@typescript-eslint/explicit-function-return-type' : [ 'error' , {
82- allowExpressions : true ,
83- allowTypedFunctionExpressions : true
84- } ] ,
85- '@typescript-eslint/explicit-module-boundary-types' : 'error' ,
86- '@typescript-eslint/no-explicit-any' : 'error' ,
87- '@typescript-eslint/no-inferrable-types' : 'off' ,
88- '@typescript-eslint/strict-boolean-expressions' : [ 'error' , {
89- allowNullableObject : true
90- } ] ,
91- 'prefer-const' : 'error' ,
92- 'no-var' : 'error' ,
93- 'no-unused-vars' : 'off' ,
94- } ,
81+ rules : sharedTypeScriptRules ,
9582 } ,
9683 {
9784 ignores : [
0 commit comments