Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
129 lines (125 loc) · 4.65 KB
/
Copy patheslint.config.js
File metadata and controls
129 lines (125 loc) · 4.65 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
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
import storybook from 'eslint-plugin-storybook';
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintReact from '@eslint-react/eslint-plugin';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import unusedImports from 'eslint-plugin-unused-imports';
import globals from 'globals';
import acronisPatterns from './tools/eslint-rules/index.js';
export default tseslint.config(
// Base ESLint recommended rules
js.configs.recommended, // TypeScript ESLint recommended rules
...tseslint.configs.recommended, // Vue 3 recommended rules
{
ignores: [
'**/dist/**',
'**/node_modules/**',
'**/storybook-static/**',
'**/.storybook/**',
'**/coverage/**',
'**/*.config.js',
'**/*.config.ts',
'vite.config.*.ts',
'**/next-env.d.ts',
// Next.js build output and Fumadocs generated source (apps/docs).
'**/.next/**',
'**/.source/**',
// Generated, committed token artifacts (built by tools/style-dictionary).
'packages/tokens/**',
],
}, // General configuration for all files
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
...globals.es2021,
},
},
}, // TypeScript files - additional rules
{
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
plugins: {
'unused-imports': unusedImports,
},
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'error',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-empty-object-type': [
'error',
{
allowObjectTypes: 'always',
},
],
},
},
// React — @eslint-react. Replaces eslint-plugin-react, whose latest (7.37.5)
// uses APIs removed in ESLint 10 (`context.getFilename`) and has no v10 release,
// which was pinning eslint to 9.x. `recommended-typescript` is @eslint-react's
// modern React rule set for TS projects (no type-checking required).
{
...eslintReact.configs['recommended-typescript'],
files: ['**/*.jsx', '**/*.tsx'],
},
{
files: ['**/*.jsx', '**/*.tsx'],
plugins: {
'react-hooks': pluginReactHooks,
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
rules: {
// react-hooks 7's full recommended set — the React Compiler rules (refs,
// purity, immutability, set-state-in-render, static-components, use-memo, …).
// The codebase already complies with 14 of the 17; two are overridden below.
...pluginReactHooks.configs['recommended-latest'].rules,
// `set-state-in-effect` is owned by @eslint-react (adopted with per-site
// justifications); turn off the react-hooks duplicate to avoid double-reports.
'react-hooks/set-state-in-effect': 'off',
// Advisory "React Compiler will skip memoizing this" (TanStack Table/Virtual).
// Informational, not a defect — and this repo doesn't run the React Compiler.
'react-hooks/incompatible-library': 'off',
// @eslint-react's recommended-typescript rules are adopted as-is, with three
// deliberate exceptions (the code is compliant with the rest):
'@eslint-react/no-forward-ref': 'off', // ui-react deliberately uses React.forwardRef
'@eslint-react/rules-of-hooks': 'off', // covered by react-hooks/rules-of-hooks
'@eslint-react/exhaustive-deps': 'off', // covered by react-hooks/exhaustive-deps
},
},
storybook.configs['flat/recommended'],
// Usage-pattern enforcement (local plugin). Scoped to application code, where
// ad-hoc compositions tend to creep in; the library + its demos compose the
// real components. Each rule encodes a `ui-spec/patterns/*` anti-pattern.
{
files: ['apps/**/*.{jsx,tsx}'],
plugins: { 'acronis-patterns': acronisPatterns },
rules: {
'acronis-patterns/no-adhoc-sheet': 'error',
// "prefer-*" composite rules are warn-first: they steer toward the
// opinionated composites without blocking, with the ledger/overrides as
// the pressure valve (proposal §6).
'acronis-patterns/prefer-confirm-dialog': 'warn',
'acronis-patterns/prefer-stat-row': 'warn',
},
}
);