1+ import eslint from '@eslint/js' ;
2+ import stylistic from "@stylistic/eslint-plugin" ;
3+
4+ import * as importPlugin from "eslint-plugin-import" ;
5+ import globals from "globals" ;
6+ import tseslint from "typescript-eslint" ;
7+
8+ export default tseslint . config (
9+ eslint . configs . recommended ,
10+ ...tseslint . configs . strictTypeChecked ,
11+ ...tseslint . configs . stylisticTypeChecked ,
12+ {
13+ languageOptions : {
14+ ecmaVersion : 2023 ,
15+ sourceType : "module" ,
16+ globals : {
17+ ...globals . browser ,
18+ ...globals . node ,
19+ } ,
20+ parserOptions : {
21+ projectService : true ,
22+ tsconfigRootDir : import . meta. dirname ,
23+ } ,
24+ } ,
25+ rules : {
26+ // These rules relate to possible logic errors in code:
27+
28+ "array-callback-return" : "error" ,
29+ "no-constructor-return" : "error" ,
30+ "no-inner-declarations" : [ "error" , "both" ] ,
31+ "no-promise-executor-return" : "error" ,
32+ "no-self-compare" : "error" ,
33+ "no-template-curly-in-string" : "warn" ,
34+ "no-unmodified-loop-condition" : "warn" ,
35+ "no-unreachable-loop" : "error" ,
36+ "require-atomic-updates" : "error" ,
37+
38+ // These rules suggest alternate ways of doing things:
39+
40+ "accessor-pairs" : "error" ,
41+ "arrow-body-style" : [ "error" , "as-needed" ] ,
42+ "block-scoped-var" : "error" ,
43+
44+ "camelcase" : [ "error" , {
45+ properties : "never" ,
46+ } ] ,
47+
48+ "consistent-this" : [ "error" , "self" ] ,
49+ "curly" : "error" ,
50+ "default-case-last" : "error" ,
51+
52+ "eqeqeq" : "error" ,
53+ "func-names" : [ "error" , "as-needed" ] ,
54+ "func-style" : [ "error" , "expression" ] ,
55+
56+ "grouped-accessor-pairs" : "error" ,
57+ "guard-for-in" : "error" ,
58+
59+ "logical-assignment-operators" : [ "error" , "always" , {
60+ enforceForIfStatements : true
61+ } ] ,
62+
63+ "new-cap" : [ "error" , {
64+ newIsCap : true ,
65+ capIsNew : true ,
66+ } ] ,
67+
68+ "no-bitwise" : [ "error" , {
69+ int32Hint : true ,
70+ } ] ,
71+
72+ "no-caller" : "error" ,
73+ "no-div-regex" : "error" ,
74+ "no-eq-null" : "error" ,
75+ "no-eval" : "error" ,
76+ "no-extend-native" : "error" ,
77+ "no-extra-bind" : "error" ,
78+ "no-extra-label" : "error" ,
79+ "no-implicit-coercion" : "error" ,
80+ "no-implicit-globals" : "error" ,
81+ "no-invalid-this" : "error" ,
82+ "no-iterator" : "error" ,
83+ "no-label-var" : "error" ,
84+ "no-lone-blocks" : "error" ,
85+ "no-lonely-if" : "error" ,
86+ "no-multi-assign" : "error" ,
87+ "no-nested-ternary" : "error" ,
88+ "no-new" : "error" ,
89+ "no-new-func" : "error" ,
90+ "no-new-wrappers" : "error" ,
91+ "no-object-constructor" : "error" ,
92+ "no-octal-escape" : "error" ,
93+
94+ "no-plusplus" : [ "error" , {
95+ allowForLoopAfterthoughts : true ,
96+ } ] ,
97+
98+ "no-proto" : "error" ,
99+ "no-return-assign" : "error" ,
100+ "no-sequences" : "error" ,
101+ "no-unneeded-ternary" : "error" ,
102+ "one-var" : [ "error" , "never" ] ,
103+ "operator-assignment" : "error" ,
104+ "prefer-arrow-callback" : "error" ,
105+ "prefer-const" : "error" ,
106+ "prefer-exponentiation-operator" : "error" ,
107+ "prefer-numeric-literals" : "error" ,
108+ "prefer-object-has-own" : "error" ,
109+ "prefer-object-spread" : "error" ,
110+ "prefer-regex-literals" : "error" ,
111+ "prefer-rest-params" : "error" ,
112+ "prefer-spread" : "error" ,
113+ "prefer-template" : "error" ,
114+ "radix" : [ "error" , "as-needed" ] ,
115+ "require-unicode-regexp" : "error" ,
116+
117+ "sort-imports" : [ "error" , {
118+ ignoreDeclarationSort : true ,
119+ } ] ,
120+
121+ "symbol-description" : "error" ,
122+ "vars-on-top" : "error" ,
123+
124+ // These rules care about how the code looks rather than how it executes:
125+
126+ "unicode-bom" : "error" ,
127+ }
128+ } ,
129+ {
130+ rules : {
131+ // override
132+ "@typescript-eslint/no-require-imports" : [ "error" , {
133+ allowAsImport : true ,
134+ } ] ,
135+
136+ "@typescript-eslint/no-unused-vars" : [ "error" , {
137+ args : "all" ,
138+ argsIgnorePattern : "^_" ,
139+ caughtErrors : "all" ,
140+ caughtErrorsIgnorePattern : "^_" ,
141+ destructuredArrayIgnorePattern : "^_" ,
142+ varsIgnorePattern : "^_" ,
143+ ignoreRestSiblings : true ,
144+ } ] ,
145+
146+ "@typescript-eslint/restrict-template-expressions" : [ "error" , {
147+ allowBoolean : true ,
148+ allowNullish : true ,
149+ allowNumber : true ,
150+ allowRegExp : true ,
151+ } ] ,
152+
153+ // switch on
154+
155+ "@typescript-eslint/consistent-type-exports" : "error" ,
156+
157+ "@typescript-eslint/consistent-type-imports" : [ "error" , {
158+ disallowTypeAnnotations : false ,
159+ fixStyle : "separate-type-imports" ,
160+ prefer : "type-imports" ,
161+ } ] ,
162+
163+ "@typescript-eslint/default-param-last" : "error" ,
164+ "@typescript-eslint/explicit-function-return-type" : "error" ,
165+
166+ "@typescript-eslint/explicit-member-accessibility" : [ "error" , {
167+ accessibility : "no-public" ,
168+ } ] ,
169+
170+ "@typescript-eslint/explicit-module-boundary-types" : "error" ,
171+ "@typescript-eslint/method-signature-style" : "error" ,
172+ "@typescript-eslint/no-import-type-side-effects" : "error" ,
173+ "@typescript-eslint/no-loop-func" : "error" ,
174+ "@typescript-eslint/no-unnecessary-parameter-property-assignment" : "error" ,
175+ "@typescript-eslint/no-unnecessary-qualifier" : "error" ,
176+ "@typescript-eslint/no-use-before-define" : "error" ,
177+ "@typescript-eslint/no-useless-empty-export" : "error" ,
178+ } ,
179+ } ,
180+ stylistic . configs [ 'recommended-flat' ] ,
181+ {
182+ rules : {
183+ // override
184+
185+ "@stylistic/arrow-parens" : [ "error" , "always" ] ,
186+ "@stylistic/brace-style" : [ "error" , "1tbs" , { } ] ,
187+
188+ "@stylistic/indent" : [ "error" , 4 , {
189+ SwitchCase : 1 ,
190+ } ] ,
191+
192+ "@stylistic/indent-binary-ops" : [ "error" , 4 ] ,
193+ "@stylistic/lines-between-class-members" : "off" ,
194+ "@stylistic/member-delimiter-style" : [ "error" , { } ] ,
195+ "@stylistic/multiline-ternary" : [ "error" , "never" ] ,
196+
197+ "@stylistic/no-extra-parens" : [ "error" , "all" , {
198+ nestedBinaryExpressions : false ,
199+ } ] ,
200+
201+ "@stylistic/no-mixed-operators" : [ "error" , { } ] ,
202+
203+ "@stylistic/no-multiple-empty-lines" : [ "error" , {
204+ max : 2 ,
205+ maxEOF : 0 ,
206+ maxBOF : 0 ,
207+ } ] ,
208+
209+ "@stylistic/no-trailing-spaces" : [ "error" , {
210+ skipBlankLines : true ,
211+ } ] ,
212+
213+ "@stylistic/object-curly-spacing" : [ "error" , "always" , {
214+ arraysInObjects : true ,
215+ objectsInObjects : true ,
216+ } ] ,
217+
218+ "@stylistic/quote-props" : [ "error" , "as-needed" ] ,
219+ "@stylistic/quotes" : [ "error" , "double" , { } ] ,
220+ "@stylistic/semi" : [ "error" , "always" ] ,
221+
222+ "@stylistic/semi-spacing" : [ "error" , {
223+ before : false ,
224+ after : false ,
225+ } ] ,
226+
227+ "@stylistic/spaced-comment" : [ "error" , "always" , { } ] ,
228+ "@stylistic/wrap-iife" : [ "error" , "outside" , { } ] ,
229+ "@stylistic/yield-star-spacing" : [ "error" , "after" ] ,
230+
231+ // switch on
232+
233+ "@stylistic/array-bracket-newline" : [ "error" , {
234+ minItems : 4 ,
235+ multiline : true ,
236+ } ] ,
237+
238+ "@stylistic/array-element-newline" : [ "error" , "consistent" ] ,
239+ "@stylistic/function-call-argument-newline" : [ "error" , "consistent" ] ,
240+ "@stylistic/function-call-spacing" : "error" ,
241+ "@stylistic/function-paren-newline" : [ "error" , "multiline-arguments" ] ,
242+
243+ "@stylistic/generator-star-spacing" : [ "error" , {
244+ before : false ,
245+ after : true ,
246+ } ] ,
247+
248+ "@stylistic/implicit-arrow-linebreak" : "error" ,
249+ "@stylistic/jsx-quotes" : [ "error" , "prefer-double" ] ,
250+ "@stylistic/linebreak-style" : "error" ,
251+
252+ "@stylistic/newline-per-chained-call" : [ "error" , {
253+ ignoreChainWithDepth : 3 ,
254+ } ] ,
255+
256+ "@stylistic/no-extra-semi" : "error" ,
257+ "@stylistic/nonblock-statement-body-position" : "error" ,
258+
259+ "@stylistic/object-curly-newline" : [ "error" , {
260+ "ObjectExpression" : { "multiline" : true , "minProperties" : 4 } ,
261+ "ObjectPattern" : { "multiline" : true , "minProperties" : 4 } ,
262+ "ImportDeclaration" : { "multiline" : true , "minProperties" : 4 } ,
263+ "ExportDeclaration" : { "multiline" : true , "minProperties" : 4 }
264+ } ] ,
265+
266+ "@stylistic/object-property-newline" : [ "error" , {
267+ allowAllPropertiesOnSameLine : true ,
268+ } ] ,
269+
270+ "@stylistic/semi-style" : "error" ,
271+ "@stylistic/switch-colon-spacing" : "error" ,
272+ "@stylistic/wrap-regex" : "error" ,
273+ }
274+ } ,
275+ importPlugin . flatConfigs . recommended ,
276+ importPlugin . flatConfigs . typescript ,
277+ {
278+ settings : {
279+ "import/resolver" : {
280+ "typescript" : true ,
281+ "node" : true ,
282+ }
283+ } ,
284+ rules : {
285+ // override
286+
287+ // switch on
288+
289+ "import/no-empty-named-blocks" : "error" ,
290+
291+ "import/no-extraneous-dependencies" : [ "error" , {
292+ devDependencies : [
293+ "tests/**/*" ,
294+ "**/*.test.ts" ,
295+ "**/*.spec.ts" ,
296+ ] ,
297+ } ] ,
298+
299+ "import/no-mutable-exports" : "error" ,
300+
301+ "import/no-unused-modules" : [ "warn" , {
302+ unusedExports : true ,
303+ src : [
304+ "src/**/*" ,
305+ ] ,
306+ ignoreExports : [
307+ "src/lib.ts" ,
308+ ] ,
309+ } ] ,
310+
311+ "import/no-absolute-path" : "error" ,
312+ "import/no-cycle" : "error" ,
313+ "import/no-self-import" : "error" ,
314+ "import/consistent-type-specifier-style" : [ "error" , "prefer-top-level" ] ,
315+ "import/first" : "error" ,
316+ "import/newline-after-import" : "error" ,
317+ "import/no-named-default" : "error" ,
318+ "import/no-namespace" : "warn" ,
319+
320+ "import/order" : [ "error" , {
321+ "newlines-between" : "always-and-inside-groups" ,
322+ alphabetize : {
323+ order : "asc" ,
324+ } ,
325+ warnOnUnassignedImports : true ,
326+ } ] ,
327+ }
328+ } ,
329+ { ignores : [ "eslint.config.mjs" , "dist/*" ] , } ,
330+ ) ;
0 commit comments