-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
79 lines (77 loc) · 2.14 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
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import stylistic from "@stylistic/eslint-plugin";
import astroParser from "astro-eslint-parser";
import astro from "eslint-plugin-astro";
const stylisticRules = {
"@stylistic/indent": ["error", "tab"],
"@stylistic/eol-last": ["error", "always"],
"@stylistic/no-trailing-spaces": ["error"],
};
export default tseslint.config(
eslint.configs.recommended,
{
files: ["src/**/*.astro"],
plugins: {
astro,
"@stylistic": stylistic,
},
languageOptions: {
globals: {
// enable the standard global variables available in Astro components
node: true,
"astro/astro": true,
es2020: true,
},
parser: astroParser,
parserOptions: {
parser: "@typescript-eslint/parser",
extraFileExtensions: [".astro"],
// the script frontmatter in Astro components uses ESM
sourceType: "module",
},
},
extends: [
...tseslint.configs.recommended,
],
rules: {
"@stylistic/indent": ["error", "tab"],
"@stylistic/eol-last": ["error", "always"],
"@stylistic/no-trailing-spaces": ["error"],
...astro.configs.all.rules,
// this sometimes errors even when the class is used in the same file
"astro/no-unused-css-selector": ["off"],
// this errors when the class is just set to a single string via a variable
"astro/prefer-class-list-directive": ["off"],
},
},
{
files: ["src/**/*.{ts,tsx}"],
extends: [
...tseslint.configs.recommended,
],
plugins: {
"@stylistic": stylistic
},
rules: {
// Astro uses a triple slash reference in the env.d.ts file it automatically
// creates, so just disable the rule to avoid trying to change that
"@typescript-eslint/triple-slash-reference": ["off"],
...stylisticRules,
// this rule expects the tags in a .astro file to be indented at least
// one level, but we want the outermost tag to start at column 0. so
// only enable it in .tsx files, not .astro.
"@stylistic/jsx-indent": ["error", "tab"],
}
},
{
files: ["src/**/*.{js,jsx}"],
plugins: {
"@stylistic": stylistic
},
rules: {
...stylisticRules,
"@stylistic/jsx-indent": ["error", "tab"],
}
}
);