Skip to content

Commit 8f356fd

Browse files
committed
chore: clean up ESLint configuration and remove unused dependencies
1 parent f89db48 commit 8f356fd

File tree

7 files changed

+65
-149
lines changed

7 files changed

+65
-149
lines changed

eslint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import * as importx from "importx";
44

5-
// eslint-disable-next-line no-restricted-syntax
65
const mod = await importx.import("./eslint.config.ts", {
76
cache: true,
87
loader: "native",

eslint.config.ts

Lines changed: 63 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,59 @@
1+
/* eslint-disable simple-import-sort/imports */
12
import url from "node:url";
23

3-
import eslint from "@eslint/js";
4-
import stylisticJs from "@stylistic/eslint-plugin-js";
5-
import safeTsPlugin from "@susisu/eslint-plugin-safe-typescript";
6-
import local from "@workspace/eslint-plugin-local";
74
import { Record } from "effect";
8-
import type { Linter } from "eslint";
9-
import gitignore from "eslint-config-flat-gitignore";
5+
import eslintJs from "@eslint/js";
6+
import eslintPluginImport from "eslint-plugin-import-x";
7+
import eslintPluginJsdoc from "eslint-plugin-jsdoc";
8+
import eslintPluginLocal from "@workspace/eslint-plugin-local";
9+
import eslintPluginPerfectionist from "eslint-plugin-perfectionist";
10+
import eslintPluginRegexp from "eslint-plugin-regexp";
11+
import eslintPluginSafeTypeScript from "@susisu/eslint-plugin-safe-typescript";
12+
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
13+
import eslintPluginUnicorn from "eslint-plugin-unicorn";
14+
import eslintPluginVitest from "eslint-plugin-vitest";
1015
// @ts-expect-error - missing types
11-
import pluginBetterMutation from "eslint-plugin-better-mutation";
16+
import eslintPluginBetterMutation from "eslint-plugin-better-mutation";
1217
// @ts-expect-error - missing types
13-
import eslintCommentsPlugin from "eslint-plugin-eslint-comments";
14-
// @ts-expect-error - missing types
15-
import eslintPluginPlugin from "eslint-plugin-eslint-plugin";
16-
import importPlugin from "eslint-plugin-import-x";
17-
import jsdocPlugin from "eslint-plugin-jsdoc";
18-
import perfectionist from "eslint-plugin-perfectionist";
19-
import regexpPlugin from "eslint-plugin-regexp";
20-
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
21-
import unicornPlugin from "eslint-plugin-unicorn";
22-
import vitest from "eslint-plugin-vitest";
23-
// import { isCI } from "std-env";
18+
import eslintPluginEslintPlugin from "eslint-plugin-eslint-plugin";
19+
import eslintConfigFlatGitignore from "eslint-config-flat-gitignore";
2420
import tseslint from "typescript-eslint";
2521

2622
const dirname = url.fileURLToPath(new URL(".", import.meta.url));
2723

28-
const GLOB_JS = ["*.{js,jsx,cjs,mjs}", "**/*.{js,jsx,cjs,mjs}"] as const;
29-
const GLOB_TS = ["*.{ts,tsx,cts,mts}", "**/*.{ts,tsx,cts,mts}"] as const;
24+
const GLOB_JS = ["*.{js,jsx,cjs,mjs}", "**/*.{js,jsx,cjs,mjs}"];
25+
const GLOB_TS = ["*.{ts,tsx,cts,mts}", "**/*.{ts,tsx,cts,mts}"];
3026
const GLOB_TEST = [
3127
"**/*.spec.{ts,tsx,cts,mts}",
3228
"**/*.test.{ts,tsx,cts,mts}",
3329
"**/spec.{ts,tsx,cts,mts}",
3430
"**/test.{ts,tsx,cts,mts}",
35-
] as const;
36-
// const GLOB_YAML = ["*.{yaml,yml}", "**/*.{yaml,yml}"] as const;
37-
const GLOB_CONFIG = ["*.config.{ts,tsx,cts,mts}", "**/*.config.{ts,tsx,cts,mts}"] as const;
38-
const GLOB_SCRIPT = ["scripts/**/*.{ts,cts,mts}"] as const;
31+
];
32+
// const GLOB_YAML = ["*.{yaml,yml}", "**/*.{yaml,yml}"];
33+
const GLOB_CONFIG = ["*.config.{ts,tsx,cts,mts}", "**/*.config.{ts,tsx,cts,mts}"];
34+
const GLOB_SCRIPT = ["scripts/**/*.{ts,cts,mts}"];
3935

4036
const templateIndentAnnotations = [
4137
"outdent",
4238
"dedent",
4339
"html",
4440
"tsx",
4541
"ts",
46-
] as const;
42+
];
4743

4844
const packagesTsConfigs = [
4945
"packages/*/tsconfig.json",
5046
"packages/*/*/tsconfig.json",
51-
] as const;
47+
];
5248

5349
const rootTsConfigs = [
5450
"tsconfig.json",
55-
] as const;
51+
];
5652

5753
const p11tOptions = {
5854
type: "natural",
5955
ignoreCase: false,
60-
} as const;
56+
};
6157

6258
const p11tGroups = {
6359
customGroups: {
@@ -73,7 +69,7 @@ const p11tGroups = {
7369
rules: ["^node$", "^messageId$"],
7470
},
7571
groups: ["id", "type", "meta", "alias", "rules", "unknown"],
76-
} as const;
72+
};
7773

7874
const disableTypeCheckedRules = {
7975
...tseslint.configs.disableTypeChecked.rules,
@@ -96,9 +92,10 @@ const typeCheckedRules = {
9692
"@typescript-eslint/switch-exhaustiveness-check": "off",
9793
} as const;
9894

99-
export default [
100-
gitignore(),
95+
export default tseslint.config(
96+
eslintConfigFlatGitignore(),
10197
{
98+
name: "global-ignores",
10299
ignores: [
103100
"docs",
104101
"examples",
@@ -107,32 +104,16 @@ export default [
107104
],
108105
},
109106
{
110-
// register all of the plugins up-front
111-
// note - intentionally uses computed syntax to make it easy to sort the keys
112-
plugins: {
113-
["@stylistic/js"]: stylisticJs,
114-
["@susisu/safe-typescript"]: safeTsPlugin,
115-
["@typescript-eslint"]: tseslint.plugin,
116-
["better-mutation"]: pluginBetterMutation,
117-
["eslint-comments"]: eslintCommentsPlugin,
118-
["eslint-plugin"]: eslintPluginPlugin,
119-
["import-x"]: importPlugin,
120-
["jsdoc"]: jsdocPlugin,
121-
["local"]: local,
122-
["simple-import-sort"]: simpleImportSortPlugin,
123-
["unicorn"]: unicornPlugin,
124-
},
125-
settings: {},
126-
},
127-
eslint.configs.recommended,
128-
...tseslint.configs.strict,
129-
perfectionist.configs["recommended-natural"],
130-
regexpPlugin.configs["flat/recommended"],
131-
jsdocPlugin.configs["flat/recommended-typescript-error"],
132-
eslintPluginPlugin.configs["flat/all-type-checked"],
133-
// base ts language options
134-
{
135-
files: GLOB_TS,
107+
files: [...GLOB_JS, ...GLOB_TS],
108+
// eslint-disable-next-line perfectionist/sort-objects
109+
extends: [
110+
eslintJs.configs.recommended,
111+
tseslint.configs.strict,
112+
eslintPluginPerfectionist.configs["recommended-natural"],
113+
eslintPluginRegexp.configs["flat/recommended"],
114+
eslintPluginJsdoc.configs["flat/recommended-typescript-error"],
115+
eslintPluginEslintPlugin.configs["flat/all-type-checked"],
116+
],
136117
languageOptions: {
137118
parser: tseslint.parser,
138119
parserOptions: {
@@ -143,50 +124,37 @@ export default [
143124
warnOnUnsupportedTypeScriptVersion: false,
144125
},
145126
},
127+
plugins: {
128+
["@susisu/safe-typescript"]: eslintPluginSafeTypeScript,
129+
["better-mutation"]: eslintPluginBetterMutation,
130+
["import-x"]: eslintPluginImport,
131+
["local"]: eslintPluginLocal,
132+
["simple-import-sort"]: eslintPluginSimpleImportSort,
133+
["unicorn"]: eslintPluginUnicorn,
134+
},
146135
},
147-
// base config
148136
{
149137
files: [...GLOB_JS, ...GLOB_TS],
150138
rules: {
151-
// Part: eslint rules
152-
curly: "off",
139+
...eslintPluginBetterMutation.configs.recommended.rules,
153140
eqeqeq: ["error", "always"],
154-
"logical-assignment-operators": "error",
155-
"max-depth": ["warn", 3],
141+
"max-depth": ["warn", 4],
156142
"no-console": "error",
157-
"no-constant-binary-expression": "off", // esbuild will remove these at build time
158143
"no-else-return": "error",
159144
"no-fallthrough": ["error", { commentPattern: ".*intentional fallthrough.*" }],
160-
"no-mixed-operators": "error",
145+
"no-mixed-operators": "warn",
161146
"no-process-exit": "error",
147+
"no-undef": "off",
148+
"one-var": ["error", "never"],
149+
"prefer-object-has-own": "error",
150+
// Part: custom rules
162151
"no-restricted-syntax": [
163152
"error",
164153
{
165154
message: "no optional",
166155
selector: "TSPropertySignature[optional=true]",
167156
},
168-
{
169-
message: "no promise",
170-
selector: "CallExpression[callee.object.name='Promise']",
171-
},
172-
{
173-
message: "no promise",
174-
selector: "CallExpression[callee.property.name='then']",
175-
},
176-
{
177-
message: "no async/await",
178-
selector: ":function[async=true]",
179-
},
180-
{
181-
message: "no async/await",
182-
selector: "AwaitExpression",
183-
},
184157
],
185-
"no-undef": "off",
186-
"one-var": ["error", "never"],
187-
"prefer-object-has-own": "error",
188-
// Part: stylistic-js rules
189-
"@stylistic/js/no-extra-parens": "warn",
190158
// Part: typescript-eslint rules
191159
"@typescript-eslint/ban-ts-comment": [
192160
"error",
@@ -202,11 +170,8 @@ export default [
202170
"@typescript-eslint/consistent-type-imports": "error",
203171
"@typescript-eslint/explicit-function-return-type": "off",
204172
"@typescript-eslint/no-empty-object-type": "off",
205-
"@typescript-eslint/no-explicit-any": "error",
206173
"@typescript-eslint/no-misused-promises": "off",
207174
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn",
208-
"@typescript-eslint/no-unnecessary-template-expression": "off",
209-
"@typescript-eslint/no-unnecessary-type-parameters": "warn",
210175
"@typescript-eslint/no-unused-vars": [
211176
"warn",
212177
{
@@ -215,11 +180,9 @@ export default [
215180
varsIgnorePattern: "^_",
216181
},
217182
],
218-
// Part: type-checked rules
219183
...typeCheckedRules,
220184
// Part: functional rules
221185
"functional/no-return-void": "off",
222-
...pluginBetterMutation.configs.recommended.rules,
223186
// Part: jsdoc rules
224187
"jsdoc/check-param-names": "warn",
225188
"jsdoc/check-tag-names": "warn",
@@ -285,25 +248,6 @@ export default [
285248
tags: templateIndentAnnotations,
286249
},
287250
],
288-
// Part: eslint-comments rules
289-
"eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
290-
"eslint-comments/no-aggregating-enable": "error",
291-
"eslint-comments/no-duplicate-disable": "error",
292-
"eslint-comments/no-unlimited-disable": "error",
293-
"eslint-comments/no-unused-disable": "error",
294-
"eslint-comments/no-unused-enable": "error",
295-
"eslint-comments/no-use": [
296-
"error",
297-
{
298-
allow: [
299-
"eslint-disable",
300-
"eslint-disable-line",
301-
"eslint-disable-next-line",
302-
"eslint-enable",
303-
"global",
304-
],
305-
},
306-
],
307251
// Part: eslint-plugin rules
308252
"eslint-plugin/meta-property-ordering": "off",
309253
"eslint-plugin/no-property-in-node": "off",
@@ -321,6 +265,12 @@ export default [
321265
},
322266
{
323267
files: GLOB_JS,
268+
languageOptions: {
269+
parserOptions: {
270+
project: false,
271+
projectService: false,
272+
},
273+
},
324274
rules: {
325275
...disableTypeCheckedRules,
326276
"@typescript-eslint/no-var-requires": "off",
@@ -330,7 +280,7 @@ export default [
330280
files: GLOB_TEST,
331281
languageOptions: {
332282
globals: {
333-
...vitest.environments.env.globals,
283+
...eslintPluginVitest.environments.env.globals,
334284
},
335285
parser: tseslint.parser,
336286
parserOptions: {
@@ -342,11 +292,11 @@ export default [
342292
},
343293
},
344294
plugins: {
345-
vitest,
295+
vitest: eslintPluginVitest,
346296
},
347297
rules: {
348298
...disableTypeCheckedRules,
349-
...vitest.configs.recommended.rules,
299+
...eslintPluginVitest.configs.recommended.rules,
350300
"@typescript-eslint/no-empty-function": ["error", { allow: ["arrowFunctions"] }],
351301
"import-x/no-extraneous-dependencies": "off",
352302
"local/avoid-multiline-template-expression": "off",
@@ -380,4 +330,4 @@ export default [
380330
"import-x/no-extraneous-dependencies": "off",
381331
},
382332
},
383-
] satisfies Linter.Config[];
333+
);

packages/plugins/eslint-plugin-react-dom/src/rules/no-unknown-property.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable eslint-comments/no-unlimited-disable, @typescript-eslint/ban-ts-comment */
1+
/* eslint-disable @typescript-eslint/ban-ts-comment */
22
// @ts-nocheck
33
/* eslint-disable */
44
// Ported from https://github.com/jsx-eslint/eslint-plugin-react/blob/master/tests/lib/rules/no-unknown-property.js

packages/plugins/eslint-plugin-react-dom/src/rules/no-unknown-property.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable eslint-comments/no-unlimited-disable, @typescript-eslint/ban-ts-comment */
1+
/* eslint-disable @typescript-eslint/ban-ts-comment */
22
// @ts-nocheck
33
/* eslint-disable */
44
// Ported from https://github.com/jsx-eslint/eslint-plugin-react/blob/master/lib/rules/no-unknown-property.js

0 commit comments

Comments
 (0)