-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy patheslint.config.mjs
More file actions
162 lines (161 loc) · 5 KB
/
eslint.config.mjs
File metadata and controls
162 lines (161 loc) · 5 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
157
158
159
160
161
162
// Flat config rewrite: remove legacy extends/env/overrides, explicitly compose plugin configs
import js from '@eslint/js';
import * as ts from 'typescript-eslint';
import storybook from 'eslint-plugin-storybook';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import jest from 'eslint-plugin-jest';
import importPlugin from 'eslint-plugin-import';
import globals from 'globals';
import * as emotion from '@emotion/eslint-plugin';
import { fixupPluginRules } from '@eslint/compat';
export default [
{
ignores: [
'node_modules/**',
'**/out/**',
'**/dist-storybook/**',
'**/dist/**',
'dist/**',
'**/esm/**',
'**/build/**',
'*.css.d.ts',
'public/**',
'.cache/**',
'tsup.config.ts',
'**/__testfixtures__',
'**/.next/**',
'**/.turbo/**',
'**/chunks/**',
'**/next-env.d.ts',
],
},
js.configs.recommended,
...ts.configs.recommended,
...storybook.configs['flat/recommended'],
jsxA11y.flatConfigs.recommended,
jest.configs['flat/recommended'],
jest.configs['flat/style'],
{
plugins: {
'@emotion': fixupPluginRules(emotion),
react,
'react-hooks': reactHooks,
import: importPlugin,
jest,
},
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},
},
settings: {
react: { version: 'detect' },
'import/extensions': ['.js', '.ts', '.tsx'],
},
rules: {
'no-console': 'warn',
'react/prop-types': 'off',
'react/prefer-stateless-function': [
'off',
{ ignorePureComponents: true },
],
'react/jsx-filename-extension': ['off', { extensions: ['.js', '.tsx'] }],
'react/forbid-prop-types': 'off',
'react/destructuring-assignment': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/sort-comp': 'off',
'react/jsx-wrap-multilines': 'off',
'function-paren-newline': 'off',
'react/button-has-type': 'error',
'react/jsx-no-target-blank': 'error',
'react/jsx-no-bind': ['error', { allowArrowFunctions: true }],
'react/no-access-state-in-setstate': 'error',
'react/react-in-jsx-scope': 'off',
'react/no-children-prop': 'off',
'react/jsx-handler-names': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true },
],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-empty-function': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'import/named': 'error',
'import/no-default-export': 'warn',
'import/no-extraneous-dependencies': 'error',
},
},
// allow specific rules in example files so there are no eslint-disable comments in code playgrounds
{
files: ['**/examples/**/*'],
rules: { 'jsx-a11y/no-autofocus': 'off', 'no-console': 'off' },
},
// Typed rules needing full TypeScript program (source only, avoids dist/ declarations)
{
files: ['**/packages/**/src/**/*.{ts,tsx,mts,cts}'],
languageOptions: {
parser: ts.parser,
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: process.cwd(),
},
},
rules: {
'@typescript-eslint/no-for-in-array': 'error',
},
},
// story files can default export
{
files: ['**/*.stories.*'],
rules: {
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'import/no-default-export': 'off',
'react/jsx-handler-names': 'off',
// Allow looser prototyping inside Storybook stories
'@typescript-eslint/no-explicit-any': 'off',
},
},
// JS-only files environment
{
files: ['**/*.js', '**/*.jsx'],
languageOptions: { globals: { ...globals.node, ...globals.browser } },
},
// turn off default export rule for component packages examples/tools
{
files: [
'**/forma-36-react-components/tools/**/*',
'**/packages/components/**/*',
'**/packages/**/examples/**',
],
rules: { 'import/no-default-export': 'off' },
},
// places where extraneous deps are allowed
{
files: [
'**/*.stories.*',
'**/*.test.*',
'**/examples/**',
'**/packages/**/__testfixtures__/**',
],
rules: { 'import/no-extraneous-dependencies': 'off' },
},
// codemods allowed to console
{
files: ['**/packages/forma-36-codemod/**/*'],
rules: { 'no-console': 'off' },
},
];