-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
95 lines (88 loc) · 2.17 KB
/
eslint.config.js
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
// @ts-check
import eslint from "@eslint/js";
import eslintPluginAstro from "eslint-plugin-astro";
import globals from "globals";
import tseslint from "typescript-eslint";
const typescriptEslint = tseslint.plugin;
const tsParser = tseslint.parser;
export default tseslint.config(
{
ignores: [
"**/node_modules",
"**/dist",
"dist/**/*",
"**/node_modules",
"**/target",
"**/.astro",
"**/.github",
],
},
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parser: tsParser,
parserOptions: {
project: ["./tsconfig.json"],
tsconfigRootDir: ".",
},
},
plugins: {
"@typescript-eslint": typescriptEslint,
},
rules: {
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
},
},
...eslintPluginAstro.configs.recommended,
// Disabled because eslint-plugin-astro doesn't type Astro.props correctly in some contexts
{
files: ["**/*.astro"],
rules: {
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
},
},
// Disable typed rules for scripts inside Astro files
// https://github.com/ota-meshi/eslint-plugin-astro/issues/240
{
files: ["**/*.astro/*.ts"],
languageOptions: {
parserOptions: {
project: null,
},
},
...tseslint.configs.disableTypeChecked,
},
{
files: ["src/env.d.ts"],
rules: {
"@typescript-eslint/consistent-type-definitions": ["off"],
"@typescript-eslint/triple-slash-reference": ["off"],
},
},
// Those files run in the browser and need the browser globals
{
files: ["src/assets/scripts/*"],
languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.node).map(([key]) => [key, "off"])),
...globals.browser,
},
},
},
);