Skip to content

Commit 928b213

Browse files
committed
build: update project eslint config
1 parent 84634ff commit 928b213

File tree

2 files changed

+34
-107
lines changed

2 files changed

+34
-107
lines changed

eslint.config.mjs

Lines changed: 33 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import { FlatCompat } from "@eslint/eslintrc";
66
import eslint from "@eslint/js";
77
import eslintCommentsPlugin from "eslint-plugin-eslint-comments";
88
import eslintPluginPlugin from "eslint-plugin-eslint-plugin";
9+
import gitignore from "eslint-config-flat-gitignore";
10+
import jsdocPlugin from "eslint-plugin-jsdoc";
911
import perfectionist from "eslint-plugin-perfectionist";
1012
import perfectionistNatural from "eslint-plugin-perfectionist/configs/recommended-natural";
11-
import jsdocPlugin from "eslint-plugin-jsdoc";
1213
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
1314
import tseslint from "typescript-eslint";
14-
import gitignore from "eslint-config-flat-gitignore";
15+
import vitest from "eslint-plugin-vitest";
1516

1617
const dirname = url.fileURLToPath(new URL(".", import.meta.url));
1718
// const compat = new FlatCompat({ baseDirectory: dirname });
@@ -40,11 +41,6 @@ export default tseslint.config(
4041
languageOptions: {
4142
parserOptions: {
4243
allowAutomaticSingleRunInference: true,
43-
cacheLifetime: {
44-
// we pretty well never create/change tsconfig structure - so no need to ever evict the cache
45-
// in the rare case that we do - just need to manually restart their IDE.
46-
glob: "Infinity",
47-
},
4844
project: [
4945
"tsconfig.json",
5046
"packages/*/tsconfig.json",
@@ -67,35 +63,12 @@ export default tseslint.config(
6763
minimumDescriptionLength: 5,
6864
},
6965
],
70-
"@typescript-eslint/consistent-type-imports": [
71-
"error",
72-
{ prefer: "type-imports", disallowTypeAnnotations: true },
73-
],
66+
"@typescript-eslint/consistent-type-imports": ["error", {
67+
prefer: "type-imports",
68+
disallowTypeAnnotations: true,
69+
}],
7470
"@typescript-eslint/explicit-function-return-type": "off",
7571
"@typescript-eslint/no-explicit-any": "error",
76-
"no-constant-condition": "off",
77-
"@typescript-eslint/no-unnecessary-condition": [
78-
"error",
79-
{ allowConstantLoopConditions: true },
80-
],
81-
"@typescript-eslint/no-var-requires": "off",
82-
"@typescript-eslint/prefer-literal-enum-member": [
83-
"error",
84-
{
85-
allowBitwiseExpressions: true,
86-
},
87-
],
88-
"@typescript-eslint/unbound-method": "off",
89-
"@typescript-eslint/restrict-template-expressions": [
90-
"error",
91-
{
92-
allowNumber: true,
93-
allowBoolean: true,
94-
allowAny: true,
95-
allowNullish: true,
96-
allowRegExp: true,
97-
},
98-
],
9972
"@typescript-eslint/no-unused-vars": [
10073
"error",
10174
{
@@ -112,28 +85,20 @@ export default tseslint.config(
11285
},
11386
],
11487

115-
//
116-
// eslint-base
117-
//
118-
119-
eqeqeq: [
120-
"error",
121-
"always",
122-
],
88+
"array-callback-return": "off",
89+
"eslint-plugin/require-meta-docs-url": "off",
12390
"logical-assignment-operators": "error",
91+
"max-depth": ["warn", 3],
92+
"no-console": "error",
12493
"no-else-return": "error",
94+
"no-fallthrough": ["error", { commentPattern: ".*intentional fallthrough.*" }],
12595
"no-mixed-operators": "error",
126-
"no-console": "error",
12796
"no-process-exit": "error",
128-
"no-fallthrough": [
129-
"error",
130-
{ commentPattern: ".*intentional fallthrough.*" },
131-
],
97+
"no-undef": "off",
13298
"one-var": ["error", "never"],
133-
"array-callback-return": "off",
99+
"prefer-object-has-own": "error",
134100
curly: "off",
135-
"eslint-plugin/require-meta-docs-url": "off",
136-
"max-depth": ["warn", 3],
101+
eqeqeq: ["error", "always"],
137102
"no-restricted-syntax": [
138103
"error",
139104
{
@@ -153,8 +118,6 @@ export default tseslint.config(
153118
selector: 'ImportDeclaration[source.value="."]',
154119
},
155120
],
156-
"no-undef": "off",
157-
"prefer-object-has-own": "error",
158121

159122
"perfectionist/sort-exports": "off",
160123
"perfectionist/sort-imports": "off",
@@ -188,28 +151,12 @@ export default tseslint.config(
188151
},
189152
],
190153

191-
//
192-
// eslint-plugin-eslint-comment
193-
//
194-
195-
// require a eslint-enable comment for every eslint-disable comment
196-
"eslint-comments/disable-enable-pair": [
197-
"error",
198-
{
199-
allowWholeFile: true,
200-
},
201-
],
202-
// disallow a eslint-enable comment for multiple eslint-disable comments
154+
"eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
203155
"eslint-comments/no-aggregating-enable": "error",
204-
// disallow duplicate eslint-disable comments
205156
"eslint-comments/no-duplicate-disable": "error",
206-
// disallow eslint-disable comments without rule names
207157
"eslint-comments/no-unlimited-disable": "error",
208-
// disallow unused eslint-disable comments
209158
"eslint-comments/no-unused-disable": "error",
210-
// disallow unused eslint-enable comments
211159
"eslint-comments/no-unused-enable": "error",
212-
// disallow ESLint directive-comments
213160
"eslint-comments/no-use": [
214161
"error",
215162
{
@@ -223,12 +170,7 @@ export default tseslint.config(
223170
},
224171
],
225172

226-
// enforce a sort order across the codebase
227-
"simple-import-sort/imports": "error",
228-
229-
//
230-
// eslint-plugin-jsdoc
231-
//
173+
"simple-import-sort/imports": "warn",
232174

233175
"jsdoc/check-tag-names": "off",
234176
"jsdoc/check-param-names": "off",
@@ -238,64 +180,49 @@ export default tseslint.config(
238180
"jsdoc/require-returns": "off",
239181
"jsdoc/require-yields": "off",
240182
"jsdoc/tag-lines": "off",
241-
// "jsdoc/informative-docs": "error",
183+
"jsdoc/informative-docs": "warn",
242184
},
243185
},
244186
{
245187
files: ["**/*.js"],
246188
extends: [tseslint.configs.disableTypeChecked],
247189
rules: {
248-
// turn off other type-aware rules
249-
"deprecation/deprecation": "off",
250-
"@typescript-eslint/internal/no-poorly-typed-ts-props": "off",
251-
252190
// turn off rules that don't apply to JS code
253-
"@typescript-eslint/explicit-function-return-type": "off",
254191
},
255192
},
256-
// test file specific configuration
257193
{
258194
files: [
259-
"packages/*/tests/**/*.spec.{ts,tsx,cts,mts}",
260-
"packages/*/tests/**/*.test.{ts,tsx,cts,mts}",
261-
"packages/*/tests/**/spec.{ts,tsx,cts,mts}",
262-
"packages/*/tests/**/test.{ts,tsx,cts,mts}",
263-
"packages/parser/tests/**/*.{ts,tsx,cts,mts}",
264-
"packages/integration-tests/tools/integration-test-base.ts",
265-
"packages/integration-tests/tools/pack-packages.ts",
195+
"**/*.spec.{ts,tsx,cts,mts}",
196+
"**/*.test.{ts,tsx,cts,mts}",
197+
"**/spec.{ts,tsx,cts,mts}",
198+
"**/test.{ts,tsx,cts,mts}",
266199
],
200+
plugins: {
201+
vitest,
202+
},
267203
rules: {
268-
"@typescript-eslint/no-empty-function": [
269-
"error",
270-
{ allow: ["arrowFunctions"] },
271-
],
204+
// @ts-ignore
205+
...vitest.configs.recommended.rules,
206+
"@typescript-eslint/no-empty-function": ["error", { allow: ["arrowFunctions"] }],
272207
"@typescript-eslint/no-non-null-assertion": "off",
273208
"@typescript-eslint/no-unsafe-assignment": "off",
274209
"@typescript-eslint/no-unsafe-call": "off",
275210
"@typescript-eslint/no-unsafe-member-access": "off",
276211
"@typescript-eslint/no-unsafe-return": "off",
277212
},
278-
},
279-
//
280-
// tools and tests
281-
//
282-
{
283-
files: [
284-
"**/tools/**/*.{ts,tsx,cts,mts}",
285-
"**/tests/**/*.{ts,tsx,cts,mts}",
286-
],
287-
rules: {
288-
// allow console logs in tools and tests
289-
"no-console": "off",
213+
languageOptions: {
214+
globals: {
215+
...vitest.environments.env.globals,
216+
},
290217
},
291218
},
292219
gitignore(),
293220
{
294221
ignores: [
295-
"eslint.config.mjs",
296222
"docs",
297223
"examples",
298224
"website",
225+
"eslint.config.mjs",
299226
],
300227
},
301228
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"lint:examples": "pnpm -r -F './examples/*' run --parallel lint",
4646
"lint:publish": "pnpm -r run --parallel lint:publish",
4747
"lint:spell": "cspell lint --relative --no-progress '**'",
48-
"lint:ts": "eslint --max-warnings 0 --cache .",
48+
"lint:ts": "eslint --cache .",
4949
"lint:type": "pnpm -r run --parallel lint:type",
5050
"lint:website": "cd website && pnpm run lint",
5151
"prepare": "husky install && pnpm run build",

0 commit comments

Comments
 (0)