Skip to content

Commit ed9e31b

Browse files
authored
Simplify local eslint config (#1324)
1 parent 69dcdba commit ed9e31b

File tree

28 files changed

+865
-821
lines changed

28 files changed

+865
-821
lines changed

.pkgs/configs/eslint.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ export declare const GLOB_TESTS: string[];
66
export declare const GLOB_CONFIGS: string[];
77
export declare const GLOB_SCRIPTS: string[];
88
export declare const GLOB_IGNORES: readonly ["**/node_modules", "**/dist", "**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml", "**/bun.lockb", "**/output", "**/coverage", "**/temp", "**/.temp", "**/tmp", "**/.tmp", "**/.history", "**/.vitepress/cache", "**/.nuxt", "**/.next", "**/.vercel", "**/.changeset", "**/.idea", "**/.cache", "**/.output", "**/.vite-inspect", "**/.yarn", "**/storybook-static", "**/.eslint-config-inspector", "**/playwright-report", "**/.astro", "**/.vinxi", "**/app.config.timestamp_*.js", "**/.tanstack", "**/.nitro", "**/CHANGELOG*.md", "**/*.min.*", "**/LICENSE*", "**/__snapshots__", "**/auto-import?(s).d.ts", "**/components.d.ts", "**/vite.config.ts.*.mjs", "**/*.gen.*", "!.storybook"];
9+
export declare function buildIgnoreConfig(gitignore: string, ...rest: string[]): readonly [never, import("eslint/config").Config];
10+
export declare function buildParserOptions(tsconfigRootDir?: string): {
11+
readonly projectService: true;
12+
readonly tsconfigRootDir: string;
13+
};
914
export declare const strictTypeChecked: Linter.Config[];
1015
export declare const disableTypeChecked: Linter.Config[];
1116
/**

.pkgs/configs/eslint.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { includeIgnoreFile } from "@eslint/compat";
12
import js from "@eslint/js";
23
import stylistic from "@stylistic/eslint-plugin";
34
import pluginDeMorgan from "eslint-plugin-de-morgan";
@@ -6,7 +7,7 @@ import { jsdoc } from "eslint-plugin-jsdoc";
67
import pluginPerfectionist from "eslint-plugin-perfectionist";
78
import pluginRegexp from "eslint-plugin-regexp";
89
import pluginUnicorn from "eslint-plugin-unicorn";
9-
import { defineConfig } from "eslint/config";
10+
import { defineConfig, globalIgnores } from "eslint/config";
1011
import tseslint from "typescript-eslint";
1112
export const GLOB_JS = ["**/*.{js,jsx,cjs,mjs}"];
1213
export const GLOB_TS = ["**/*.{ts,tsx,cts,mts}"];
@@ -88,6 +89,21 @@ const p11tGroups = {
8889
},
8990
groups: ["id", "type", "meta", "alias", "rules", "unknown"],
9091
};
92+
export function buildIgnoreConfig(gitignore, ...rest) {
93+
return [
94+
includeIgnoreFile(gitignore, "Imported .gitignore patterns"),
95+
globalIgnores([
96+
...GLOB_IGNORES,
97+
...rest,
98+
]),
99+
];
100+
}
101+
export function buildParserOptions(tsconfigRootDir = ".") {
102+
return {
103+
projectService: true,
104+
tsconfigRootDir,
105+
};
106+
}
91107
export const strictTypeChecked = defineConfig({
92108
ignores: GLOB_JS,
93109
}, {

.pkgs/configs/eslint.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { includeIgnoreFile } from "@eslint/compat";
12
import js from "@eslint/js";
23
import stylistic from "@stylistic/eslint-plugin";
34
import type { Linter } from "eslint";
@@ -7,7 +8,7 @@ import { jsdoc } from "eslint-plugin-jsdoc";
78
import pluginPerfectionist from "eslint-plugin-perfectionist";
89
import pluginRegexp from "eslint-plugin-regexp";
910
import pluginUnicorn from "eslint-plugin-unicorn";
10-
import { defineConfig } from "eslint/config";
11+
import { defineConfig, globalIgnores } from "eslint/config";
1112
import tseslint from "typescript-eslint";
1213

1314
export const GLOB_JS = ["**/*.{js,jsx,cjs,mjs}"];
@@ -98,6 +99,23 @@ const p11tGroups = {
9899
groups: ["id", "type", "meta", "alias", "rules", "unknown"],
99100
};
100101

102+
export function buildIgnoreConfig(gitignore: string, ...rest: string[]) {
103+
return [
104+
includeIgnoreFile(gitignore, "Imported .gitignore patterns") as never,
105+
globalIgnores([
106+
...GLOB_IGNORES,
107+
...rest,
108+
]),
109+
] as const;
110+
}
111+
112+
export function buildParserOptions(tsconfigRootDir: string = ".") {
113+
return {
114+
projectService: true,
115+
tsconfigRootDir,
116+
} as const;
117+
}
118+
101119
export const strictTypeChecked: Linter.Config[] = defineConfig(
102120
{
103121
ignores: GLOB_JS,

.pkgs/configs/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@
2222
"@eslint/js": "^9.39.1",
2323
"@stylistic/eslint-plugin": "^5.5.0",
2424
"eslint-plugin-de-morgan": "^2.0.0",
25-
"eslint-plugin-function": "^0.0.34",
26-
"eslint-plugin-function-rule": "^0.0.16",
25+
"eslint-plugin-function": "^0.0.35",
26+
"eslint-plugin-function-rule": "^0.0.17",
2727
"eslint-plugin-jsdoc": "^61.2.1",
2828
"eslint-plugin-perfectionist": "^4.15.1",
2929
"eslint-plugin-regexp": "^2.10.0",
3030
"eslint-plugin-unicorn": "^62.0.0",
31-
"typescript-eslint": "^8.46.4"
31+
"typescript-eslint": "^8.47.0"
3232
},
3333
"peerDependencies": {
3434
"eslint": "^9.39.1",
35+
"typedoc": "0.28.14",
36+
"typedoc-plugin-markdown": "^4.9.0",
37+
"typedoc-plugin-mdn-links": "^5.0.10",
3538
"typescript": "^5.9.3"
3639
}
3740
}

.pkgs/function-rules/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
"lint:ts": "tsc --noEmit"
2222
},
2323
"dependencies": {
24-
"eslint-plugin-function-rule": "^0.0.16"
24+
"eslint-plugin-function-rule": "^0.0.17"
2525
},
2626
"devDependencies": {
2727
"eslint": "^9.39.1",
28-
"tsdown": "^0.16.4"
28+
"tsdown": "^0.16.5"
2929
},
3030
"peerDependencies": {
3131
"eslint": "^9.39.1",

apps/website/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
"@eslint-react/eff": "workspace:*",
1414
"bsky-react-post": "^0.1.7",
1515
"clsx": "^2.1.1",
16-
"effect": "^3.19.3",
17-
"fumadocs-core": "16.0.11",
16+
"effect": "^3.19.4",
17+
"fumadocs-core": "16.0.13",
1818
"fumadocs-docgen": "3.0.4",
19-
"fumadocs-mdx": "13.0.8",
19+
"fumadocs-mdx": "14.0.1",
2020
"fumadocs-twoslash": "3.1.10",
2121
"fumadocs-typescript": "4.0.13",
22-
"fumadocs-ui": "16.0.11",
23-
"lucide-react": "^0.553.0",
22+
"fumadocs-ui": "16.0.13",
23+
"lucide-react": "^0.554.0",
2424
"next": "^16.0.3",
2525
"next-view-transitions": "^0.3.4",
2626
"react": "^19.2.0",
@@ -38,12 +38,12 @@
3838
"@tailwindcss/postcss": "^4.1.17",
3939
"@theguild/remark-mermaid": "^0.3.0",
4040
"@tsconfig/next": "^2.0.4",
41-
"@tsconfig/node22": "^22.0.3",
41+
"@tsconfig/node22": "^22.0.5",
4242
"@tsconfig/strictest": "^2.0.8",
4343
"@types/hast": "^3.0.4",
4444
"@types/mdx": "^2.0.13",
4545
"@types/node": "^24.10.1",
46-
"@types/react": "^19.2.5",
46+
"@types/react": "^19.2.6",
4747
"@types/react-dom": "^19.2.3",
4848
"dedent": "^1.7.0",
4949
"eslint": "^9.39.1",
@@ -55,6 +55,6 @@
5555
"tailwindcss": "^4.1.17",
5656
"tailwindcss-animated": "^2.0.0",
5757
"typescript": "^5.9.3",
58-
"typescript-eslint": "^8.46.4"
58+
"typescript-eslint": "^8.47.0"
5959
}
6060
}

eslint.config.ts

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { fileURLToPath } from "node:url";
22

3-
import { includeIgnoreFile } from "@eslint/compat";
43
import {
54
GLOB_CONFIGS,
6-
GLOB_IGNORES,
75
GLOB_SCRIPTS,
86
GLOB_TESTS,
97
GLOB_TS,
8+
buildIgnoreConfig,
9+
buildParserOptions,
1010
disableProblematicEslintJsRules,
1111
disableTypeChecked,
1212
strictTypeChecked,
@@ -15,22 +15,22 @@ import { nullishComparison, templateExpression } from "@local/function-rules";
1515
import { recommended as fastImportRecommended } from "eslint-plugin-fast-import";
1616
import { functionRule } from "eslint-plugin-function-rule";
1717
import pluginVitest from "eslint-plugin-vitest";
18-
import { defineConfig, globalIgnores } from "eslint/config";
18+
import { defineConfig } from "eslint/config";
1919
import tseslint from "typescript-eslint";
2020

21-
const dirname = fileURLToPath(new URL(".", import.meta.url));
22-
const gitignore = fileURLToPath(new URL(".gitignore", import.meta.url));
21+
const ignoreConfig = buildIgnoreConfig(
22+
fileURLToPath(new URL(".gitignore", import.meta.url)),
23+
"apps",
24+
"docs",
25+
"test",
26+
"examples",
27+
"**/*.d.ts",
28+
);
29+
30+
const parserOptions = buildParserOptions(fileURLToPath(new URL(".", import.meta.url)));
2331

2432
export default defineConfig(
25-
includeIgnoreFile(gitignore, "Imported .gitignore patterns") as never,
26-
globalIgnores([
27-
...GLOB_IGNORES,
28-
"apps",
29-
"docs",
30-
"test",
31-
"examples",
32-
"**/*.d.ts",
33-
]),
33+
...ignoreConfig,
3434
{
3535
extends: [
3636
tseslint.configs.strictTypeChecked,
@@ -41,25 +41,11 @@ export default defineConfig(
4141
files: GLOB_TS,
4242
languageOptions: {
4343
parser: tseslint.parser,
44-
parserOptions: {
45-
projectService: true,
46-
tsconfigRootDir: dirname,
47-
},
44+
parserOptions,
4845
},
4946
plugins: {
5047
"function-rule-1": functionRule(templateExpression()),
5148
"function-rule-2": functionRule(nullishComparison()),
52-
53-
custom: functionRule((context) => ({
54-
CallExpression(node) {
55-
if (context.sourceCode.getText(node.callee) === "Date.now") {
56-
context.report({
57-
node,
58-
message: "Don't use 'Date.now()'.",
59-
});
60-
}
61-
},
62-
})),
6349
},
6450
rules: {
6551
"fast-import/no-unused-exports": "off",
@@ -91,10 +77,7 @@ export default defineConfig(
9177
globals: {
9278
...pluginVitest.environments.env.globals,
9379
},
94-
parserOptions: {
95-
projectService: true,
96-
tsconfigRootDir: dirname,
97-
},
80+
parserOptions,
9881
},
9982
plugins: {
10083
vitest: pluginVitest,

examples/next/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
"@eslint/js": "^9.39.1",
2222
"@next/eslint-plugin-next": "^16.0.3",
2323
"@tsconfig/next": "^2.0.4",
24-
"@tsconfig/node22": "^22.0.3",
24+
"@tsconfig/node22": "^22.0.5",
2525
"@tsconfig/strictest": "^2.0.8",
2626
"@types/node": "^24.10.1",
27-
"@types/react": "^19.2.5",
27+
"@types/react": "^19.2.6",
2828
"@types/react-dom": "^19.2.3",
2929
"eslint": "^9.39.1",
3030
"eslint-plugin-react-hooks": "^7.0.1",
3131
"eslint-plugin-react-refresh": "^0.4.24",
3232
"typescript": "^5.9.3",
33-
"typescript-eslint": "^8.46.4"
33+
"typescript-eslint": "^8.47.0"
3434
},
3535
"engines": {
3636
"node": ">=20.19.0"

examples/react-dom-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@eslint-react/eslint-plugin": "workspace:*",
1919
"@eslint/config-inspector": "^1.3.0",
2020
"@eslint/js": "^9.39.1",
21-
"@types/react": "^19.2.5",
21+
"@types/react": "^19.2.6",
2222
"@types/react-dom": "^19.2.3",
2323
"@vitejs/plugin-react": "^5.1.1",
2424
"eslint": "^9.39.1",

examples/react-dom/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
"@eslint-react/eslint-plugin": "workspace:*",
1919
"@eslint/config-inspector": "^1.3.0",
2020
"@eslint/js": "^9.39.1",
21-
"@tsconfig/node22": "^22.0.3",
21+
"@tsconfig/node22": "^22.0.5",
2222
"@tsconfig/strictest": "^2.0.8",
2323
"@tsconfig/vite-react": "^7.0.2",
24-
"@types/react": "^19.2.5",
24+
"@types/react": "^19.2.6",
2525
"@types/react-dom": "^19.2.3",
2626
"@vitejs/plugin-react": "^5.1.1",
2727
"eslint": "^9.39.1",
2828
"eslint-plugin-react-hooks": "^7.0.1",
2929
"eslint-plugin-react-refresh": "^0.4.24",
3030
"typescript": "^5.9.3",
31-
"typescript-eslint": "^8.46.4",
31+
"typescript-eslint": "^8.47.0",
3232
"vite": "^7.2.2"
3333
},
3434
"engines": {

0 commit comments

Comments
 (0)