1+ import js from '@eslint/js' ;
2+ import tsEslint from 'typescript-eslint' ;
3+ import tsEslintParser from '@typescript-eslint/parser' ;
4+ //import vitest from 'eslint-plugin-vitest';
5+ import eslintImport from 'eslint-plugin-import' ;
6+ import { fixupPluginRules } from '@eslint/compat' ;
7+
8+ /** @type {import('eslint').Linter.FlatConfig[] } */
9+ export default tsEslint . config (
10+ {
11+ ignores : [ '**/*.js' , '**/*.mjs' , '.gitignore' ]
12+ } ,
13+ js . configs . recommended ,
14+ tsEslint . configs . eslintRecommended ,
15+ ...tsEslint . configs . strictTypeChecked ,
16+ ...tsEslint . configs . stylisticTypeChecked ,
17+ {
18+ languageOptions : {
19+ ecmaVersion : 2022 ,
20+ parser : tsEslintParser ,
21+ parserOptions : {
22+ tsconfigDirName : import . meta. dirname ,
23+ project : [ './tsconfig.json' ] ,
24+ } ,
25+ globals : {
26+ Atomics : 'readonly' ,
27+ SharedArrayBuffer : 'readonly' ,
28+ } ,
29+ } ,
30+ } ,
31+ {
32+ files : [ '**/*.ts' ] ,
33+ plugins : {
34+ import : fixupPluginRules ( eslintImport ) ,
35+ } ,
36+ rules : {
37+ ...eslintImport . configs . errors . rules ,
38+ ...eslintImport . configs . warnings . rules ,
39+ ...eslintImport . configs . typescript . rules ,
40+ '@typescript-eslint/consistent-type-definitions' : [ 'error' , 'interface' ] ,
41+ '@typescript-eslint/explicit-member-accessibility' : [
42+ 'error' ,
43+ {
44+ accessibility : 'explicit' ,
45+ overrides : {
46+ accessors : 'explicit' ,
47+ constructors : 'explicit' ,
48+ methods : 'explicit' ,
49+ properties : 'off' ,
50+ parameterProperties : 'off' ,
51+ } ,
52+ } ,
53+ ] ,
54+ '@typescript-eslint/member-ordering' : [ 'warn' ] ,
55+ '@typescript-eslint/naming-convention' : [
56+ 'error' ,
57+ {
58+ selector : [ 'classProperty' ] ,
59+ format : [ 'strictCamelCase' , 'UPPER_CASE' , 'snake_case' ] ,
60+ leadingUnderscore : 'allow' ,
61+ } ,
62+ {
63+ selector : 'typeParameter' ,
64+ format : [ 'StrictPascalCase' ] ,
65+ prefix : [ 'T' ] ,
66+ } ,
67+ {
68+ selector : [ 'typeLike' ] ,
69+ format : [ 'StrictPascalCase' ] ,
70+ } ,
71+ {
72+ selector : [ 'function' , 'classMethod' ] ,
73+ format : [ 'strictCamelCase' ] ,
74+ leadingUnderscore : 'allow' ,
75+ } ,
76+ {
77+ selector : [ 'variable' ] ,
78+ format : [ 'StrictPascalCase' , 'strictCamelCase' ] ,
79+ modifiers : [ 'const' , 'exported' ] ,
80+ leadingUnderscore : 'allow' ,
81+ } ,
82+ {
83+ selector : [ 'parameter' ] ,
84+ format : [ 'strictCamelCase' ] ,
85+ leadingUnderscore : 'allow' ,
86+ } ,
87+ {
88+ selector : [ 'variableLike' ] ,
89+ format : [ 'strictCamelCase' , 'UPPER_CASE' , 'snake_case' ] ,
90+ } ,
91+ ] ,
92+ '@typescript-eslint/no-deprecated' : 'off' ,
93+ '@typescript-eslint/no-duplicate-type-constituents' : 'off' ,
94+ '@typescript-eslint/no-dynamic-delete' : 'error' ,
95+ '@typescript-eslint/no-empty-function' : 'warn' ,
96+ '@typescript-eslint/no-empty-object-type' : 'off' ,
97+ '@typescript-eslint/no-unnecessary-type-parameters' : 'off' ,
98+ '@typescript-eslint/no-inferrable-types' : 'off' ,
99+ '@typescript-eslint/no-invalid-void-type' : 'off' ,
100+ '@typescript-eslint/no-empty-interface' : 'off' ,
101+ '@typescript-eslint/no-explicit-any' : 'error' ,
102+ '@typescript-eslint/no-extraneous-class' : 'off' ,
103+ '@typescript-eslint/no-floating-promises' : [ 'error' ] ,
104+ '@typescript-eslint/no-non-null-assertion' : 'off' ,
105+ 'no-magic-numbers' : 'off' ,
106+ '@typescript-eslint/no-magic-numbers' : [
107+ 'warn' ,
108+ {
109+ ignore : [ 0 , 1 ] ,
110+ ignoreArrayIndexes : true ,
111+ ignoreEnums : true ,
112+ ignoreReadonlyClassProperties : true ,
113+ } ,
114+ ] ,
115+ '@typescript-eslint/no-require-imports' : 'error' ,
116+ '@typescript-eslint/no-unused-expressions' : [ 'error' ] ,
117+ '@typescript-eslint/no-useless-constructor' : 'error' ,
118+ '@typescript-eslint/prefer-for-of' : 'error' ,
119+ '@typescript-eslint/prefer-literal-enum-member' : 'off' ,
120+ '@typescript-eslint/prefer-nullish-coalescing' : [ 'off' ] ,
121+ '@typescript-eslint/prefer-optional-chain' : 'off' ,
122+ '@typescript-eslint/prefer-readonly' : [ 'warn' ] ,
123+ '@typescript-eslint/promise-function-async' : [ 'error' ] ,
124+ '@typescript-eslint/require-await' : 'off' ,
125+ '@typescript-eslint/restrict-plus-operands' : [
126+ 'error' ,
127+ {
128+ skipCompoundAssignments : false ,
129+ } ,
130+ ] ,
131+ '@typescript-eslint/restrict-template-expressions' : [
132+ 'error' ,
133+ {
134+ allowNumber : true ,
135+ } ,
136+ ] ,
137+ '@typescript-eslint/typedef' : [
138+ 'error' ,
139+ {
140+ arrayDestructuring : true ,
141+ arrowParameter : true ,
142+ memberVariableDeclaration : true ,
143+ objectDestructuring : true ,
144+ parameter : true ,
145+ propertyDeclaration : true ,
146+ variableDeclaration : true ,
147+ } ,
148+ ] ,
149+ '@typescript-eslint/unified-signatures' : 'error' ,
150+ 'import/default' : 'off' ,
151+ 'import/namespace' : 'off' ,
152+ 'import/newline-after-import' : 'error' ,
153+ 'import/no-named-as-default' : 'off' ,
154+ 'import/no-named-as-default-member' : 'off' ,
155+ 'import/order' : [
156+ 'error' ,
157+ {
158+ alphabetize : {
159+ order : 'asc' ,
160+ caseInsensitive : true ,
161+ } ,
162+ groups : [ 'external' , 'builtin' , 'internal' ] ,
163+ 'newlines-between' : 'always' ,
164+ pathGroups : [
165+ {
166+ pattern : 'vitest' ,
167+ group : 'external' ,
168+ position : 'before' ,
169+ } ,
170+ {
171+ pattern : 'vitest-mock' ,
172+ group : 'external' ,
173+ position : 'before' ,
174+ } ,
175+ ] ,
176+ pathGroupsExcludedImportTypes : [ 'vitest' , 'vitest-mock' ] ,
177+ } ,
178+ ] ,
179+ '@typescript-eslint/strict-boolean-expressions' : 'error' ,
180+ '@typescript-eslint/switch-exhaustiveness-check' : 'error' ,
181+ '@typescript-eslint/no-unused-vars' : [ 'warn' , { argsIgnorePattern : '^_' } ] ,
182+ '@typescript-eslint/unbound-method' : [ 'error' , { ignoreStatic : true } ] ,
183+ 'sort-keys' : [
184+ 'error' ,
185+ 'asc' ,
186+ {
187+ caseSensitive : false ,
188+ natural : true ,
189+ } ,
190+ ] ,
191+ } ,
192+ settings : {
193+ 'import/resolver' : {
194+ node : true ,
195+ typescript : true ,
196+ } ,
197+ } ,
198+ } ,
199+ // {
200+ // files: ['**/*.spec.ts'],
201+ // plugins: {
202+ // vitest
203+ // },
204+ // rules: {
205+ // ...vitest.configs.recommended.rules,
206+ // ...vitest.configs.all.rules,
207+ // '@typescript-eslint/unbound-method': 'off',
208+ // '@typescript-eslint/no-confusing-void-expression': 'off',
209+ // '@typescript-eslint/no-empty-function': "off",
210+ // '@typescript-eslint/no-magic-numbers': 'off',
211+ // '@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
212+ // 'vitest/consistent-test-filename': 'off',
213+ // 'vitest/max-expects': 'off',
214+ // 'vitest/no-hooks': 'off',
215+ // 'vitest/prefer-expect-assertions': 'off',
216+ // 'vitest/prefer-strict-equal': 'error',
217+ // 'vitest/valid-title': 'off',
218+ // },
219+ // },
220+ ) ;
0 commit comments