-
Notifications
You must be signed in to change notification settings - Fork 5
/
eslint.config.js
97 lines (90 loc) · 2.54 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
96
97
// @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",
"**/.vercel",
"**/.astro",
"**/.github",
],
},
eslint.configs.recommended,
// Maybe enable it one day when I feel like fixing all the errors
// ...tseslint.configs.strictTypeChecked,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parser: tsParser,
parserOptions: {
// projectService: true, // Ecosystem is not ready for this yet.
project: ["./tsconfig.json"],
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
"@typescript-eslint": typescriptEslint,
},
rules: {
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
// Cause a weird error in the Tailwind config I don't understand
"@typescript-eslint/unbound-method": "off",
},
},
// Astro
...eslintPluginAstro.configs.recommended,
// Remove some safety rules around any for various reasons
{
files: [
"**/*.astro", // Disabled because eslint-plugin-astro doesn't type Astro.props correctly in some contexts, so a bunch of things ends up being any
"api/add/script.js", // Script is in JSDoc and interact with an API, some things are any because I can't be bothered
"scripts/**/*.ts", // Interact with untyped APIs a bunch, can't be bothered
],
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,
},
// Those files run in the browser and need the browser globals
{
files: ["src/assets/scripts/*", "api/**/*.js"],
languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.node).map(([key]) => [key, "off"])),
...globals.browser,
},
},
},
);