-
Notifications
You must be signed in to change notification settings - Fork 5
/
eslint.config.mjs
133 lines (131 loc) · 3.19 KB
/
eslint.config.mjs
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
import eslint from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
import reactPlugin from 'eslint-plugin-react';
import globals from 'globals';
import {
config,
parser,
configs as tsConfigs,
plugin as tsPlugin,
} from 'typescript-eslint';
// require('eslint-plugin-react/configs/recommended') does the right thing but can't be imported
// and the .configs.recommended export adds flatconfig-invalid .plugins and .parserOptions .. remove
const reactConfig = {
...reactPlugin.configs.recommended,
plugins: { react: reactPlugin }, // fix for plugins: ['react']
};
delete reactConfig.parserOptions;
export default config(
eslint.configs.recommended,
reactConfig,
...tsConfigs.recommended,
...tsConfigs.stylistic,
prettierConfig,
{
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
plugins: {
'@typescript-eslint': tsPlugin,
react: reactPlugin,
},
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
parser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
},
},
settings: {
react: {
version: 'detect',
},
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
rules: {
curly: ['error', 'all'],
'eol-last': ['error', 'always'],
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
],
'@typescript-eslint/consistent-type-imports': [
'error',
{ fixStyle: 'inline-type-imports' },
],
'no-restricted-imports': [
'error',
{
paths: [
{
importNames: [
'Alert',
'Breadcrumb',
'Chip',
'ChipGroup',
'ClipboardCopy',
'ClipboardCopyButton',
'FileUpload',
'Icon',
'LabelGroup',
'LoginForm',
'NavList',
'Pagination',
'Popover',
'SearchInput',
'Spinner',
'Tooltip',
],
message: 'Import from src/components instead.',
name: '@patternfly/react-core',
},
],
},
],
},
},
{
files: ['config/*.js'],
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['src/components/patternfly-wrappers/*.{js,jsx,ts,tsx}'],
rules: {
'no-restricted-imports': 'off',
},
},
{
files: ['cypress/**/*.{js,jsx,ts,tsx}'],
languageOptions: {
globals: {
...globals.node,
Cypress: 'readonly',
after: 'readonly',
before: 'readonly',
beforeEach: 'readonly',
cy: 'readonly',
describe: 'readonly',
expect: 'readonly',
it: 'readonly',
},
},
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
},
);