-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy patheslint.config.ts
More file actions
85 lines (80 loc) · 2.3 KB
/
eslint.config.ts
File metadata and controls
85 lines (80 loc) · 2.3 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
import { browser } from "globals"
import { defineConfig } from "eslint/config"
import importPlugin from "eslint-plugin-import"
import js from "@eslint/js"
import next from "@next/eslint-plugin-next"
import react from "eslint-plugin-react"
import reactHooks from "eslint-plugin-react-hooks"
import stylistic from "@stylistic/eslint-plugin"
import tseslint from "typescript-eslint"
import type { Linter } from "eslint"
const stylisticConfig = stylistic.configs.customize({
indent: 2,
quotes: "double",
})
const stylisticRulesAsWarnings: Record<string, Linter.RuleEntry>
= Object.entries(stylisticConfig.rules || {}).reduce(
(acc, [ruleName, ruleConfig]) => {
if (Array.isArray(ruleConfig)) {
// Rule has configuration options: ["error", { options }] -> ["warn", { options }]
acc[ruleName] = ["warn", ...ruleConfig.slice(1)]
}
else {
// Rule is just a severity level: "error" -> "warn"
acc[ruleName] = "warn"
}
return acc
},
{} as Record<string, Linter.RuleEntry>,
)
export default defineConfig([
{
ignores: [
"**/dist/**",
"node_modules/**",
"__registry__/index.tsx",
"apps/docs/.next/**",
"apps/docs/.source/**",
"apps/docs/next-env.d.ts",
],
},
{
extends: [
importPlugin.flatConfigs.recommended,
js.configs.recommended,
react.configs.flat["jsx-runtime"],
reactHooks.configs["recommended-latest"],
...tseslint.configs.recommended,
],
files: ["**/*.{ts,tsx}", "apps/docs/**/*.{ts,tsx}"],
languageOptions: {
...react.configs.flat.recommended.languageOptions,
ecmaVersion: "latest",
globals: {
...browser,
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
// @ts-expect-error: @next/eslint-plugin-next doesn’t export types correctly
"@next/next": next.flatConfig.recommended.plugins["@next/next"],
react,
"@stylistic": stylistic,
},
// @ts-expect-error: @next/eslint-plugin-next doesn’t export types correctly
rules: {
...stylisticRulesAsWarnings,
...next.flatConfig.coreWebVitals.rules,
...next.flatConfig.recommended.rules,
},
settings: {
"import/resolver": {
typescript: true,
},
},
},
])