generated from idea2app/Next-shadcn-ts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.ts
More file actions
121 lines (114 loc) · 3.78 KB
/
eslint.config.ts
File metadata and controls
121 lines (114 loc) · 3.78 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
import cspellPlugin from "@cspell/eslint-plugin";
import eslint from "@eslint/js";
import nextPlugin from "@next/eslint-plugin-next";
import stylistic from "@stylistic/eslint-plugin";
import eslintConfigPrettier from "eslint-config-prettier";
import react from "eslint-plugin-react";
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
import globals from "globals";
import tsEslint from "typescript-eslint";
import { fileURLToPath } from "url";
/**
* @see{@link https://github.com/typescript-eslint/typescript-eslint/blob/main/eslint.config.mjs}
* @see{@link https://github.com/vercel/next.js/issues/71763#issuecomment-2476838298}
*/
const tsconfigRootDir = fileURLToPath(new URL(".", import.meta.url));
export default tsEslint.config(
// register all of the plugins up-front
{
plugins: {
"@typescript-eslint": tsEslint.plugin,
"@next/next": nextPlugin,
react,
"@stylistic": stylistic,
"simple-import-sort": simpleImportSortPlugin,
"@cspell": cspellPlugin,
},
},
{
// config with just ignores is the replacement for `.eslintignore`
ignores: ["**/node_modules/**", "**/public/**", "**/.next/**"],
},
// extends ...
eslint.configs.recommended,
...tsEslint.configs.recommended,
// base config
{
languageOptions: {
globals: { ...globals.es2020, ...globals.browser, ...globals.node },
parserOptions: {
projectService: true,
tsconfigRootDir,
warnOnUnsupportedTypeScriptVersion: false,
},
},
rules: {
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs["core-web-vitals"].rules,
"arrow-body-style": ["error", "as-needed"],
"no-empty-pattern": "warn",
"no-console": ["error", { allow: ["warn", "error", "info"] }],
"consistent-return": "warn",
"prefer-destructuring": ["error", { object: true, array: true }],
// next
"@next/next/no-sync-scripts": "warn",
// react
"react/no-unescaped-entities": "off",
"react/self-closing-comp": ["error", { component: true, html: true }],
"react/jsx-curly-brace-presence": [
"error",
{ props: "never", children: "never" },
],
"react/jsx-no-target-blank": "warn",
"react/jsx-sort-props": [
"error",
{
reservedFirst: true,
callbacksLast: true,
noSortAlphabetically: true,
},
],
// typescript
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
// @typescript-eslint + eslint, works together
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"no-restricted-syntax": [
"error",
{
selector: "TSPropertySignature[key.name='children']",
message:
"Please use PropsWithChildren<T> instead of defining children manually",
},
],
// stylistic
"@stylistic/padding-line-between-statements": [
"error",
{ blankLine: "always", prev: "*", next: "return" },
{ blankLine: "always", prev: "directive", next: "*" },
{ blankLine: "any", prev: "directive", next: "directive" },
{
blankLine: "always",
prev: "*",
next: ["enum", "interface", "type"],
},
],
// simple-import-sort
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error",
// spellchecker
"@cspell/spellchecker": [
"warn",
{
cspell: {
language: "en",
dictionaries: ["typescript", "node", "next", "css", "bash", "npm"],
},
},
],
},
},
eslintConfigPrettier,
);