@@ -4,7 +4,10 @@ const tseslint = require('typescript-eslint');
44
55const ts = require ( '@typescript-eslint/eslint-plugin' ) ;
66const tsParser = require ( '@typescript-eslint/parser' ) ;
7- const imprt = require ( 'eslint-plugin-import' ) ;
7+ // When it works again do `npm install --save-dev eslint-plugin-import`
8+ // const imprt = require('eslint-plugin-import');
9+ // https://github.com/eslint/eslint/issues/18087
10+ // https://github.com/import-js/eslint-plugin-import/pull/2829
811const globals = require ( 'globals' ) ;
912const jest = require ( 'eslint-plugin-jest' ) ;
1013const off = 'off' ;
@@ -13,8 +16,7 @@ const warn = 'warn';
1316
1417const error = 'error' ;
1518
16- const TEST_ONLY_IMPORTS = [ 'fast-check' ,
17- 'jest' ] ;
19+ // const TEST_ONLY_IMPORTS = ['fast-check', 'jest'];
1820
1921/**
2022 * set of typescript-eslint any rules
@@ -33,11 +35,11 @@ const any_rules = (level) => {
3335 } ;
3436} ;
3537
36- module . exports
37- = [
38- js . configs . recommended ,
39- ... tseslint . configs . recommended ,
40- { languageOptions : {
38+ module . exports = [
39+ js . configs . recommended ,
40+ ... tseslint . configs . recommended ,
41+ {
42+ languageOptions : {
4143 globals : globals . node ,
4244 parser : tsParser ,
4345 parserOptions : {
@@ -51,123 +53,119 @@ module.exports
5153 ] ,
5254 } ,
5355 } ,
56+ } ,
57+ stylistic . configs [ 'recommended-flat' ] ,
58+ stylistic . configs . customize ( {
59+ // the following options are the default values
60+ semi : true ,
61+ } ) ,
62+ {
63+ languageOptions : { parser : tsParser } ,
64+ plugins : {
65+ // 'import': imprt,
66+ '@stylistic' : stylistic ,
67+ ts,
5468 } ,
55- stylistic . configs [ 'recommended-flat' ] ,
56- stylistic . configs . customize ( {
57- // the following options are the default values
58- semi : true ,
59- } ) ,
60- { languageOptions : { parser : tsParser } ,
61- plugins : {
62- 'import' : imprt ,
63- // '@typescript-eslint': ts,
64- '@stylistic' : stylistic ,
65- ts,
66- } } ,
67- {
68- ignores : [ '**/node_modules' ,
69- '**/dist' ,
70- '**/build' ,
71- '**/__snapshots__' ,
72- '**/mocks' ,
73- '**/coverage' ,
74- '**/report' ] ,
75- } ,
76- {
77- rules : {
78- ...ts . configs [ 'eslint-recommended' ] . rules ,
79- ...ts . configs [ 'recommended' ] . rules ,
80- ...ts . configs [ 'recommended-requiring-type-checking' ] . rules ,
81- ...imprt . configs [ 'errors' ] . rules ,
82- ...imprt . configs [ 'warnings' ] . rules ,
83- ...imprt . configs [ 'typescript' ] . rules ,
84- 'import/no-extraneous-dependencies' : error ,
85- 'no-console' : error ,
86- '@typescript-eslint/return-await' : [ 'error' ,
87- 'always' ] ,
88- 'no-unused-vars' : off ,
89- '@typescript-eslint/no-unused-vars' : error ,
90- 'eqeqeq' : [ error ,
91- 'smart' ] ,
92- 'no-else-return' : [
93- error ,
94- {
95- allowElseIf : true ,
96- } ,
97- ] ,
98- '@typescript-eslint/require-await' : error ,
99- '@typescript-eslint/unbound-method' : [
100- error ,
101- {
102- ignoreStatic : true ,
103- } ,
104- ] ,
105- // See https://github.com/orgs/react-hook-form/discussions/8622#discussioncomment-4060570
106- '@typescript-eslint/no-misused-promises' : [
107- error ,
108- {
109- checksVoidReturn : {
110- attributes : false ,
111- } ,
112- } ,
113- ] ,
114- 'no-restricted-imports' : [
115- 'error' ,
116- {
117- paths : TEST_ONLY_IMPORTS . map ( ( name ) => {
118- return { name,
119- message : `${ name } is only available during testing` } ;
120- } ) ,
121- patterns : TEST_ONLY_IMPORTS . map ( dep => `${ dep } /*` ) ,
69+ } ,
70+ {
71+ ignores : [
72+ '**/node_modules' ,
73+ '**/dist' ,
74+ '**/build' ,
75+ '**/__snapshots__' ,
76+ '**/mocks' ,
77+ '**/coverage' ,
78+ '**/report' ,
79+ ] ,
80+ } ,
81+ {
82+ rules : {
83+ ...ts . configs [ 'eslint-recommended' ] . rules ,
84+ ...ts . configs [ 'recommended' ] . rules ,
85+ ...ts . configs [ 'recommended-requiring-type-checking' ] . rules ,
86+ // ...imprt.configs['errors'].rules,
87+ // ...imprt.configs['warnings'].rules,
88+ // ...imprt.configs['typescript'].rules,
89+ // "import/no-extraneous-dependencies": error,
90+ 'no-console' : error ,
91+ '@typescript-eslint/return-await' : [ 'error' , 'always' ] ,
92+ 'no-unused-vars' : off ,
93+ '@typescript-eslint/no-unused-vars' : error ,
94+ 'eqeqeq' : [ error , 'smart' ] ,
95+ 'no-else-return' : [
96+ error ,
97+ {
98+ allowElseIf : true ,
99+ } ,
100+ ] ,
101+ '@typescript-eslint/require-await' : error ,
102+ '@typescript-eslint/unbound-method' : [
103+ error ,
104+ {
105+ ignoreStatic : true ,
106+ } ,
107+ ] ,
108+ // See https://github.com/orgs/react-hook-form/discussions/8622#discussioncomment-4060570
109+ '@typescript-eslint/no-misused-promises' : [
110+ error ,
111+ {
112+ checksVoidReturn : {
113+ attributes : false ,
122114 } ,
123- ] ,
124- '@typescript-eslint/explicit-member-accessibility' : warn ,
125- '@typescript-eslint/no-explicit-any' : warn ,
126- '@typescript-eslint/explicit-function-return-type' : off ,
127- // '@typescript-eslint/no-var-requires': off,
128- '@typescript-eslint/no-empty-function' : off ,
129- '@typescript-eslint/no-floating-promises' : error ,
130- } ,
115+ } ,
116+ ] ,
117+ // 'no-restricted-imports': [
118+ // 'error',
119+ // {
120+ // paths: TEST_ONLY_IMPORTS.map((name) => {
121+ // return { name,
122+ // message: `${name} is only available during testing` };
123+ // }),
124+ // patterns: TEST_ONLY_IMPORTS.map(dep => `${dep}/*`),
125+ // },
126+ // ],
127+ '@typescript-eslint/explicit-member-accessibility' : warn ,
128+ '@typescript-eslint/no-explicit-any' : warn ,
129+ '@typescript-eslint/explicit-function-return-type' : off ,
130+ // '@typescript-eslint/no-var-requires': off,
131+ '@typescript-eslint/no-empty-function' : off ,
132+ '@typescript-eslint/no-floating-promises' : error ,
131133 } ,
132- {
133- files : [ '.*.js' ,
134- '.*.cjs' ,
135- '*.config.cjs' ,
136- '*.config.js' ,
137- '*.config.ts' ] ,
138- rules : {
139- 'no-restricted-imports' : off ,
140- // Consider if this is too leanient for tests
141- ...any_rules ( 'off' ) ,
142- } ,
134+ } ,
135+ {
136+ files : [ '.*.js' , '.*.cjs' , '*.config.cjs' , '*.config.js' , '*.config.ts' ] ,
137+ rules : {
138+ 'no-restricted-imports' : off ,
139+ // Consider if this is too leanient for tests
140+ ...any_rules ( 'off' ) ,
143141 } ,
144- {
145- files : [
146- '**/*.test.js' ,
147- '**/*.spec.js' ,
148- '**/*.test.ts' ,
149- '**/*.spec.ts' ,
150- 'tests/**/*.js' ,
151- 'tests/**/*.ts' ,
152- '__tests__/**/*.js' ,
153- '__tests__/**/*.ts' ,
154- 'jest.*.js' ,
155- 'jest.*.ts' ,
142+ } ,
143+ {
144+ files : [
145+ '**/*.test.js' ,
146+ '**/*.spec.js' ,
147+ '**/*.test.ts' ,
148+ '**/*.spec.ts' ,
149+ 'tests/**/*.js' ,
150+ 'tests/**/*.ts' ,
151+ '__tests__/**/*.js' ,
152+ '__tests__/**/*.ts' ,
153+ 'jest.*.js' ,
154+ 'jest.*.ts' ,
155+ ] ,
156+ // https://eslint.org/docs/user-guide/configuring#specifying-environments
157+ languageOptions : { globals : globals . jest } ,
158+ plugins : { jest } ,
159+ rules : {
160+ ...jest . configs [ 'recommended' ] . rules ,
161+ // 'no-restricted-imports': off,
162+ 'jest/expect-expect' : [
163+ error ,
164+ {
165+ assertFunctionNames : [ 'expect' , 'fc.assert' ] ,
166+ } ,
156167 ] ,
157- // https://eslint.org/docs/user-guide/configuring#specifying-environments
158- languageOptions : { globals : globals . jest } ,
159- plugins : { jest } ,
160- rules : {
161- ...jest . configs [ 'recommended' ] . rules ,
162- 'no-restricted-imports' : off ,
163- 'jest/expect-expect' : [
164- error ,
165- {
166- assertFunctionNames : [ 'expect' ,
167- 'fc.assert' ] ,
168- } ,
169- ] ,
170- ...any_rules ( 'off' ) ,
171- } ,
168+ ...any_rules ( 'off' ) ,
172169 } ,
173- ] ;
170+ } ,
171+ ] ;
0 commit comments