-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
116 lines (107 loc) · 3.37 KB
/
eslint.config.mjs
File metadata and controls
116 lines (107 loc) · 3.37 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
import storybook from "eslint-plugin-storybook";
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTypescript from "eslint-config-next/typescript";
import stylistic from "@stylistic/eslint-plugin";
import unicorn from "eslint-plugin-unicorn";
import checkFile from "eslint-plugin-check-file";
export default defineConfig([
...nextVitals,
...nextTypescript,
globalIgnores([".next/**", "out/**", "build/**", "next-env.d.ts"]),
...storybook.configs["flat/recommended"],
{
plugins: {
"@stylistic": stylistic,
unicorn,
"check-file": checkFile,
},
rules: {
// Ban let -- use const always
"no-restricted-syntax": [
"error",
{
selector: "VariableDeclaration[kind='let']",
message:
"Use const instead of let. If mutation is needed, extract to a sub-function that returns the value.",
},
],
// Blank lines around control flow statements
"@stylistic/padding-line-between-statements": [
"error",
{ blankLine: "always", prev: "*", next: "return" },
{ blankLine: "always", prev: "*", next: "if" },
{ blankLine: "always", prev: "if", next: "*" },
{ blankLine: "always", prev: "*", next: "for" },
{ blankLine: "always", prev: "for", next: "*" },
{ blankLine: "always", prev: "*", next: "switch" },
{ blankLine: "always", prev: "switch", next: "*" },
{ blankLine: "always", prev: "*", next: "try" },
{ blankLine: "always", prev: "try", next: "*" },
{ blankLine: "always", prev: "*", next: "while" },
{ blankLine: "always", prev: "while", next: "*" },
],
// No abbreviated variable names
"unicorn/prevent-abbreviations": [
"error",
{
allowList: {
props: true,
Props: true,
ref: true,
Ref: true,
params: true,
args: true,
env: true,
Env: true,
src: true,
db: true,
DB: true,
i18n: true,
e2e: true,
id: true,
ID: true,
url: true,
URL: true,
api: true,
API: true,
svg: true,
SVG: true,
html: true,
HTML: true,
css: true,
CSS: true,
dom: true,
DOM: true,
json: true,
JSON: true,
pdf: true,
PDF: true,
cms: true,
CMS: true,
},
checkFilenames: false,
},
],
// No any
"@typescript-eslint/no-explicit-any": "error",
// Enforce import type for type-only imports
"@typescript-eslint/consistent-type-imports": [
"error",
{ prefer: "type-imports", fixStyle: "inline-type-imports" },
],
// Prevent accidental waterfall loops
"no-await-in-loop": "error",
// No console.log (allow warn and error)
"no-console": ["warn", { allow: ["warn", "error"] }],
// Prefer const (built-in)
"prefer-const": "error",
// Kebab-case filenames
"check-file/filename-naming-convention": [
"error",
{ "**/*.{ts,tsx}": "KEBAB_CASE" },
{ ignoreMiddleExtensions: true },
],
},
},
]);