Skip to content

Commit 230b5c0

Browse files
committed
Simplify local eslint config
1 parent 55a54c0 commit 230b5c0

File tree

21 files changed

+486
-453
lines changed

21 files changed

+486
-453
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
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
}

apps/website/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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.4",
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",

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
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.4",
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",

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"@eslint-react/eslint-plugin": "workspace:*",
1919
"@eslint/config-inspector": "^1.3.0",
2020
"@eslint/js": "^9.39.1",
21-
"@tsconfig/node22": "^22.0.4",
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",

examples/with-babel-eslint-parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@eslint/js": "^9.39.1",
2424
"@types/babel__core": "~7.20.5",
2525
"@types/babel__preset-env": "~7.10.0",
26-
"@types/react": "^19.2.5",
26+
"@types/react": "^19.2.6",
2727
"@types/react-dom": "^19.2.3",
2828
"@vitejs/plugin-react": "^5.1.1",
2929
"eslint": "^9.39.1",

0 commit comments

Comments
 (0)