-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
142 lines (137 loc) · 3.34 KB
/
eslint.config.js
File metadata and controls
142 lines (137 loc) · 3.34 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// @ts-check
import eslint from "@eslint/js";
import eslintJsonc from "eslint-plugin-jsonc";
import eslintPerfectionist from "eslint-plugin-perfectionist";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import eslintPluginUnicorn from "eslint-plugin-unicorn";
import eslintPluginYml from "eslint-plugin-yml";
import tsEslint from "typescript-eslint";
const Constants = {
abbreviations: {
dev: false,
dir: false,
dirs: false,
env: false,
envs: false,
prod: false,
prop: false,
props: false,
stg: false,
},
ignoreFiles: [
"**/?(.)cache/",
"**/public/",
"**/dist/",
"**/target/",
".yarn/",
"node_modules/",
"apps/recorder/assets/sw.js",
"apps/app/src/gatsby-types.d.ts",
],
jsConfigFiles: ["eslint.config.js"],
jsoncFiles: ["**/*.json?(c)"],
tsEslintFiles: ["**/*.?(c|m)@(j|t)s?(x)"],
ymlFiles: ["**/*.y?(a)ml"],
};
/**
* @param {(string[] | undefined)} files
* @param {string[]} [ignores]
* @returns {import("@typescript-eslint/utils").TSESLint.FlatConfig.ConfigArray}
*/
const withFiles = (configs, files, ignores = []) => {
return configs.map((config) => ({
...config,
files,
ignores,
}));
};
/* eslint-disable @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access, @typescript-eslint/ban-ts-comment */
export default tsEslint.config(
{
ignores: Constants.ignoreFiles,
},
eslint.configs.recommended,
...withFiles(tsEslint.configs.stylistic, Constants.tsEslintFiles),
...withFiles(
tsEslint.configs.strictTypeChecked,
Constants.tsEslintFiles,
Constants.jsConfigFiles,
),
eslintPluginUnicorn.configs["flat/recommended"],
// @ts-ignore
eslintPerfectionist.configs["recommended-alphabetical"],
{
files: Constants.tsEslintFiles,
ignores: Constants.ignoreFiles,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
project: [
"./tsconfig.eslint.json",
"./apps/*/tsconfig.json",
"./etc/*/tsconfig.json",
"./libs/*/tsconfig.json",
"./app/tsconfig.json",
],
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
react,
"react-hooks": reactHooks,
},
rules: {
...react.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowNullish: true,
allowNumber: true,
},
],
"array-element-newline": ["error", "always"],
"react-hooks/exhaustive-deps": "error",
"react/no-unknown-property": ["error", { ignore: ["css"] }],
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"unicorn/prevent-abbreviations": [
"error",
{
replacements: Constants.abbreviations,
},
],
},
settings: {
react: {
version: "detect",
},
},
},
...withFiles(eslintJsonc.configs["flat/recommended-with-jsonc"], [
...Constants.jsoncFiles,
]),
...withFiles(eslintPluginYml.configs["flat/standard"], Constants.ymlFiles),
{
files: Constants.ymlFiles,
rules: {
"unicorn/prevent-abbreviations": [
"error",
{
replacements: Constants.abbreviations,
},
],
},
},
eslintPluginPrettierRecommended,
);