Skip to content

Commit 6a9135d

Browse files
committed
Chore: EsLint tsconfig project setup
1 parent 0c90487 commit 6a9135d

File tree

11 files changed

+71
-69
lines changed

11 files changed

+71
-69
lines changed

configs/eslint-config-custom/eslint.config.typescript.js

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,59 @@ import eslint from "@eslint/js";
66
import tseslint from "typescript-eslint";
77
import baseConfig from "./eslint.config.base.js";
88

9-
export default tseslint.config(
10-
// == Typescript =============================================================
11-
eslint.configs.recommended,
12-
...tseslint.configs.recommended,
13-
// ...tseslint.configs.recommendedTypeChecked,
14-
// ...tseslint.configs.stylisticTypeChecked,
15-
{
16-
languageOptions: {
17-
parserOptions: {
18-
project: ["tsconfig.json", "tsconfig.node.json"],
19-
tsconfigRootDir: cwd(),
20-
EXPERIMENTAL_useProjectService: true,
21-
// EXPERIMENTAL_useProjectService: {
22-
// // default is 8
23-
// // https://typescript-eslint.io/packages/typescript-estree/
24-
// maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: 100
25-
// },
9+
/** @typedef {import("typescript-eslint").InfiniteDepthConfigWithExtends} TSConfig */
10+
/** @typedef {import("typescript-eslint").ConfigArray} ConfigArray */
2611

27-
ecmaVersion: "latest",
28-
sourceType: "module",
29-
globals: {
30-
...globals.nodeBuiltin,
31-
...globals.es2025
12+
/**
13+
* @export
14+
* @type {(userConfigs?: TSConfig) => ConfigArray}
15+
*/
16+
export function eslintConfig(userConfigs = []) {
17+
return tseslint.config(
18+
// == Typescript =============================================================
19+
eslint.configs.recommended,
20+
...tseslint.configs.recommended,
21+
// ...tseslint.configs.recommendedTypeChecked,
22+
// ...tseslint.configs.stylisticTypeChecked,
23+
{
24+
languageOptions: {
25+
parserOptions: {
26+
project: ["tsconfig.json"],
27+
tsconfigRootDir: cwd(),
28+
projectService: true,
29+
30+
ecmaVersion: "latest",
31+
sourceType: "module",
32+
globals: {
33+
...globals.nodeBuiltin,
34+
...globals.es2025
35+
}
3236
}
37+
},
38+
rules: {
39+
"@typescript-eslint/no-unused-vars": [
40+
"error",
41+
{
42+
args: "all",
43+
argsIgnorePattern: "^_",
44+
caughtErrors: "all",
45+
caughtErrorsIgnorePattern: "^_",
46+
destructuredArrayIgnorePattern: "^_",
47+
varsIgnorePattern: "^_",
48+
ignoreRestSiblings: true
49+
}
50+
]
3351
}
3452
},
35-
rules: {
36-
"@typescript-eslint/no-unused-vars": [
37-
"error",
38-
{
39-
args: "all",
40-
argsIgnorePattern: "^_",
41-
caughtErrors: "all",
42-
caughtErrorsIgnorePattern: "^_",
43-
destructuredArrayIgnorePattern: "^_",
44-
varsIgnorePattern: "^_",
45-
ignoreRestSiblings: true
46-
}
47-
]
48-
}
49-
},
5053

51-
// == Javascript =============================================================
52-
{
53-
files: ["*.js"],
54-
extends: [tseslint.configs.disableTypeChecked]
55-
},
54+
// == Javascript =============================================================
55+
{
56+
files: ["*.js", "*.cjs", "*.mjs"],
57+
extends: [tseslint.configs.disableTypeChecked]
58+
},
59+
60+
...baseConfig,
5661

57-
...baseConfig
58-
);
62+
...(Array.isArray(userConfigs) ? userConfigs : [userConfigs ?? {}])
63+
);
64+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export default {
2-
"$schema": "https://json.schemastore.org/prettierrc",
3-
"parser": "typescript",
4-
"trailingComma": "none",
5-
"tabWidth": 2,
6-
"semi": true,
7-
"bracketSpacing": true,
8-
"arrowParens": "always"
9-
}
2+
$schema: "https://json.schemastore.org/prettierrc",
3+
parser: "typescript",
4+
trailingComma: "none",
5+
tabWidth: 2,
6+
semi: true,
7+
bracketSpacing: true,
8+
arrowParens: "always"
9+
};
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
// @ts-check
2-
3-
export { default } from "eslint-config-custom/typescript";
1+
import { eslintConfig } from "eslint-config-custom/typescript";
2+
export default eslintConfig();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "tsconfig-custom/tsconfig.json",
3-
"include": ["vite.config.ts"]
3+
"include": ["vite.config.ts", "eslint.config.js"],
44
}

packages/css/eslint.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
// @ts-check
2-
3-
export { default } from "eslint-config-custom/typescript";
1+
import { eslintConfig } from "eslint-config-custom/typescript";
2+
export default eslintConfig();

packages/css/tsconfig.node.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "tsconfig-custom/tsconfig.json",
3-
"include": ["vite.config.ts"]
3+
"include": ["vite.config.ts", "eslint.config.js"],
44
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
// @ts-check
2-
3-
export { default } from "eslint-config-custom/typescript";
1+
import { eslintConfig } from "eslint-config-custom/typescript";
2+
export default eslintConfig();

packages/debug-log/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"baseUrl": "./"
55
},
6-
"include": ["src/**/*.ts", "__tests__/**/*.ts"],
6+
"include": ["src/**/*.ts", "__tests__/**/*.ts", "importMeta.d.ts"],
77
"exclude": ["dist", "_release"],
88
"references": [{ "path": "tsconfig.node.json" }]
99
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "tsconfig-custom/tsconfig.json",
3-
"include": ["vite.config.ts"]
3+
"include": ["vite.config.ts", "eslint.config.js"],
44
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
// @ts-check
2-
3-
export { default } from "eslint-config-custom/typescript";
1+
import { eslintConfig } from "eslint-config-custom/typescript";
2+
export default eslintConfig();

0 commit comments

Comments
 (0)