-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
115 lines (110 loc) · 2.74 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/** @typedef {import("typescript-eslint").Config} Config */
import baseConfig from "@acdh-oeaw/eslint-config";
import astroConfig from "@acdh-oeaw/eslint-config-astro";
import playwrightConfig from "@acdh-oeaw/eslint-config-playwright";
import reactConfig from "@acdh-oeaw/eslint-config-react";
import solidJsConfig from "@acdh-oeaw/eslint-config-solid";
import tailwindcssConfig from "@acdh-oeaw/eslint-config-tailwindcss";
import gitignore from "eslint-config-flat-gitignore";
// @ts-expect-error Missing type declaration.
import checkFilePlugin from "eslint-plugin-check-file";
import nodePlugin from "eslint-plugin-n";
const KEBAB_CASE = "+([a-z])*([a-z0-9])*(-+([a-z0-9]))";
const CAMEL_CASE = "+([a-z])*([a-z0-9])*([A-Z]*([a-z0-9]))";
const DYNAMIC_SEGMENTS = `\\[${CAMEL_CASE}\\]`;
const CATCH_ALL_SEGMENTS = `\\[...${CAMEL_CASE}\\]`;
const MIDDLE_EXTENSION = "*(.+([a-z0-9]))";
const reactFiles = [
"keystatic.config.@(ts|tsx)",
"**/content/**/*.@(ts|tsx)",
"**/keystatic/**/*.@(ts|tsx)",
];
/** @type {Config} */
const config = [
gitignore({ strict: false }),
...baseConfig,
...astroConfig,
...reactConfig.map((config) => {
return {
...config,
files: reactFiles,
};
}),
...solidJsConfig.map((config) => {
return {
...config,
files: ["**/components/**/*.@(ts|tsx)", "**/ui/**/*.@(ts|tsx)"],
ignores: reactFiles,
};
}),
...tailwindcssConfig,
{
settings: {
tailwindcss: {
classRegex: "^class(:list)$",
},
},
},
...playwrightConfig,
{
plugins: {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
"check-file": checkFilePlugin,
},
rules: {
"check-file/filename-naming-convention": [
"error",
{
"**/*": `@(${KEBAB_CASE}${MIDDLE_EXTENSION}|${DYNAMIC_SEGMENTS}|${CATCH_ALL_SEGMENTS}|404|500)`,
},
],
"check-file/folder-naming-convention": [
"error",
{
"**/": `@(${KEBAB_CASE}|${DYNAMIC_SEGMENTS}|${CATCH_ALL_SEGMENTS})`,
},
],
},
},
{
rules: {
"arrow-body-style": ["error", "always"],
// "@typescript-eslint/explicit-module-boundary-types": "error",
// "@typescript-eslint/require-array-sort-compare": "error",
// "@typescript-eslint/strict-boolean-expressions": "error",
},
},
{
plugins: {
n: nodePlugin,
},
rules: {
"n/prefer-node-protocol": "error",
},
},
{
files: ["!e2e/**"],
rules: {
"no-restricted-syntax": [
"error",
{
selector: 'MemberExpression[computed!=true][object.name="process"][property.name="env"]',
message: "Please use `@/config/env.config` instead.",
},
],
},
},
{
files: reactFiles,
rules: {
"react/jsx-sort-props": ["error", { reservedFirst: true }],
},
},
{
files: ["**/*.astro"],
rules: {
"astro/sort-attributes": "error",
},
},
];
export default config;