-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy patheslint.config.ts
117 lines (112 loc) · 2.78 KB
/
eslint.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import url from "node:url";
import markdown from "@eslint/markdown";
import * as configs from "@local/configs/eslint";
import pluginLocal from "@local/eslint-plugin-local";
import configFlatGitignore from "eslint-config-flat-gitignore";
import pluginVitest from "eslint-plugin-vitest";
import { globalIgnores } from "eslint/config";
import tseslint from "typescript-eslint";
const dirname = url.fileURLToPath(new URL(".", import.meta.url));
const GLOB_TS = ["*.{ts,tsx,cts,mts}", "**/*.{ts,tsx,cts,mts}"];
const GLOB_MD = ["*.md", "**/*.md"];
const GLOB_TEST = [
"**/*.spec.{ts,tsx,cts,mts}",
"**/*.test.{ts,tsx,cts,mts}",
"**/spec.{ts,tsx,cts,mts}",
"**/test.{ts,tsx,cts,mts}",
];
const GLOB_CONFIG = ["*.config.{ts,tsx,cts,mts}", "**/*.config.{ts,tsx,cts,mts}"];
const GLOB_SCRIPT = ["scripts/**/*.{ts,cts,mts}"];
const GLOB_IGNORES = [
...configFlatGitignore().ignores,
"apps",
"docs",
"test",
"examples",
"**/*.d.ts",
];
const packagesTsConfigs = [
"packages/*/tsconfig.json",
"packages/*/*/tsconfig.json",
];
export default tseslint.config(
globalIgnores(GLOB_IGNORES),
{
extends: [
markdown.configs.recommended,
],
files: GLOB_MD,
ignores: [
"**/README.md",
"packages/**/docs/**/*.md",
],
language: "markdown/gfm",
rules: {
"markdown/no-html": "warn",
"markdown/no-missing-label-refs": "off",
},
},
{
extends: [
...tseslint.configs.strictTypeChecked,
configs.typescript,
],
files: GLOB_TS,
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: packagesTsConfigs,
projectService: true,
tsconfigRootDir: dirname,
// warnOnUnsupportedTypeScriptVersion: false,
},
},
plugins: {
local: pluginLocal,
},
rules: {
// Part: local rules
"local/avoid-multiline-template-expression": "warn",
"local/no-shadow-underscore": "error",
"local/prefer-eqeq-nullish-comparison": "warn",
},
},
{
extends: [
configs.disableTypeChecked,
],
files: [...GLOB_SCRIPT, ...GLOB_CONFIG],
languageOptions: {
parserOptions: {
project: false,
projectService: false,
},
},
rules: {
"no-console": "off",
},
},
{
extends: [
pluginVitest.configs.recommended,
],
files: GLOB_TEST,
languageOptions: {
globals: {
...pluginVitest.environments.env.globals,
},
parserOptions: {
project: "tsconfig.json",
projectService: true,
tsconfigRootDir: dirname,
},
},
plugins: {
vitest: pluginVitest,
},
rules: {
"@typescript-eslint/no-empty-function": ["error", { allow: ["arrowFunctions"] }],
"local/avoid-multiline-template-expression": "off",
},
},
);