-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy patheslint.config.js
More file actions
130 lines (121 loc) · 3.59 KB
/
Copy patheslint.config.js
File metadata and controls
130 lines (121 loc) · 3.59 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
import js from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import reactPlugin from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import storybook from 'eslint-plugin-storybook';
import testingLibrary from 'eslint-plugin-testing-library';
import unicorn from 'eslint-plugin-unicorn';
import globals from 'globals';
import tseslint from 'typescript-eslint';
/** Stories must not import the library barrel — see README “Storybook styles”. */
const noLibraryBarrelInStories = {
'no-restricted-imports': [
'error',
{
paths: [
{
name: '~/src/index',
message:
'Import the component from its source file (e.g. ./button). Global styles load via .storybook/preview.js → entry-styles.ts.',
},
],
patterns: [
{
group: ['~/src/index', '~/src/index.ts'],
message:
'Import the component from its source file (e.g. ./button). Global styles load via .storybook/preview.js → entry-styles.ts.',
},
],
},
],
};
export default tseslint.config(
{
ignores: [
'dist/**',
'dist-storybook/**',
'.storybook/**',
'coverage/**',
'.eslintcache',
'node_modules/**',
'.yarn/**',
'*.config.js',
],
},
// Base JS & TS Recommended
js.configs.recommended,
tseslint.configs.recommendedTypeChecked,
tseslint.configs.stylisticTypeChecked,
importPlugin.flatConfigs.recommended,
// A11y
jsxA11y.flatConfigs.recommended,
// React
reactPlugin.configs.flat.recommended,
// Add this if using React 17+ JSX transform
reactPlugin.configs.flat['jsx-runtime'],
// Testing Library
testingLibrary.configs['flat/react'],
// Unicorn & Storybook
unicorn.configs.recommended,
storybook.configs['flat/recommended'],
// Prettier always last
prettierConfig,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
'react-hooks': reactHooks,
'testing-library': testingLibrary,
},
settings: {
react: { version: '19' },
// Tell eslint-plugin-import how to resolve TS/JS files.
'import/resolver': {
typescript: {
project: './tsconfig.json',
},
},
},
rules: {
// Add your custom overrides here
'no-console': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' },
],
'unicorn/prevent-abbreviations': 'off', // Airbnb was less strict than Unicorn
'unicorn/null-data-property': 'off',
'unicorn/no-null': 'off',
// Prefer concise prop JSDoc (`/** ... */`) over forced multiline blocks.
'unicorn/single-line-block-comment-style': 'off',
'react/prop-types': 'off', // Using TypeScript, so don't use PropTypes.
// Resolver cannot resolve Vite/tsconfig path aliases or @cfpb/cfpb-design-system src subpaths.
'import/no-unresolved': [
'error',
{ ignore: ['^@cfpb/cfpb-design-system/', '^~/'] },
],
},
},
// Overrides for Tests
{
files: ['**/*.test.ts?(x)'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
// Stories: import components from source, not the library barrel (MDX: same convention; see README).
{
files: ['**/*.stories.ts?(x)'],
rules: noLibraryBarrelInStories,
},
);