Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
156 lines (144 loc) · 5.34 KB
/
Copy patheslint.config.mjs
File metadata and controls
156 lines (144 loc) · 5.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import nextCoreWebVitals from 'eslint-config-next/core-web-vitals'
import prettierConfig from 'eslint-config-prettier'
import prettierPlugin from 'eslint-plugin-prettier'
import simpleImportSort from 'eslint-plugin-simple-import-sort'
import storybookPlugin from 'eslint-plugin-storybook'
import unicorn from 'eslint-plugin-unicorn'
import tseslint from 'typescript-eslint'
const config = [
// Keep `eslint .` scoped to the working copy: git worktrees, build output, and IDE
// folders are not ignored by default and make lint appear "stuck" (duplicate src + .next).
{
ignores: ['**/*worktree*/**', '**/.next/**', '.cursor/**', '.eslintcache'],
},
...nextCoreWebVitals,
prettierConfig,
{
plugins: { prettier: prettierPlugin },
rules: {
'prettier/prettier': 'error',
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',
},
},
...storybookPlugin.configs['flat/recommended'],
{
ignores: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx', '**/*.stories.tsx'],
},
{
rules: {
semi: [2, 'never'],
quotes: 'off',
'object-curly-spacing': [2, 'always'],
'eol-last': [2, 'always'],
'react-hooks/set-state-in-effect': 'off',
'react-hooks/purity': 'off',
'react-hooks/refs': 'off',
'react-hooks/preserve-manual-memoization': 'off',
'react-hooks/incompatible-library': 'off',
'react-hooks/static-components': 'off',
'react-hooks/immutability': 'off',
'react/jsx-pascal-case': 'error',
},
},
// -----------------------------------------------------------------------
// Import sorting (auto-fixable via `eslint --fix` or editor save)
// [TechDebt] Set to 'warn' to avoid breaking CI on existing files.
// Promote to 'error' once cleanup epic is complete.
// -----------------------------------------------------------------------
{
plugins: { 'simple-import-sort': simpleImportSort },
rules: {
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
},
// -----------------------------------------------------------------------
// Unicorn – modern JS/TS best-practice rules (eslint-plugin-unicorn)
// [TechDebt] Starting at 'warn' to avoid breaking CI.
// Promote individual rules to 'error' once violations are fixed.
// -----------------------------------------------------------------------
{
plugins: { unicorn },
rules: {
'unicorn/no-useless-undefined': 'warn', // TODO: fix violations and promote to 'error' in a separate PR
// 'unicorn/no-negated-condition': 'warn',
'unicorn/no-lonely-if': 'warn', // TODO: fix violations and promote to 'error' in a separate PR
// 'unicorn/prefer-optional-catch-binding': 'warn',
'unicorn/prefer-string-replace-all': 'warn', // TODO: fix violations and promote to 'error' in a separate PR
'unicorn/error-message': 'warn', // TODO: fix violations and promote to 'error' in a separate PR
'unicorn/no-for-loop': 'warn', // TODO: fix violations and promote to 'error' in a separate PR
// 'unicorn/no-typeof-undefined': 'warn', // disabled: flags legitimate `typeof window` SSR checks
},
},
// -----------------------------------------------------------------------
// Import sorting (auto-fixable via `eslint --fix` or editor save)
// [TechDebt] Set to 'warn' to avoid breaking CI on existing files.
// Promote to 'error' once cleanup epic is complete.
// -----------------------------------------------------------------------
{
plugins: { 'simple-import-sort': simpleImportSort },
rules: {
'simple-import-sort/imports': 'warn',
'simple-import-sort/exports': 'warn',
},
},
{
files: ['**/*.ts', '**/*.tsx'],
plugins: {
'@typescript-eslint': tseslint.plugin,
},
languageOptions: {
parser: tseslint.parser,
},
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/member-ordering': [
'error',
{
default: 'never',
interfaces: {
optionalityOrder: 'required-first',
},
typeLiterals: {
optionalityOrder: 'required-first',
},
},
],
// Enforce PascalCase or camelCase on function declarations (blocks ALLCAPS names like RANDOMCOMPONENT)
'@typescript-eslint/naming-convention': [
'warn',
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
],
'@typescript-eslint/no-restricted-types': [
'error',
{
types: {
FC: {
message:
'Do not use FC. Type the component as (props: Props) => JSX.Element and use (props: Props) in the parameter.',
},
FunctionComponent: {
message:
'Do not use FunctionComponent. Type the component as (props: Props) => JSX.Element and use (props: Props) in the parameter.',
},
},
},
],
},
},
]
export default config