-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy patheslint.config.js
More file actions
87 lines (83 loc) · 3.37 KB
/
eslint.config.js
File metadata and controls
87 lines (83 loc) · 3.37 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
/**
* Copyright IBM Corp. 2025, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
/*
* This config file started as the base config file included by Vite when creating a new React application March 24th 2025.
* Where it differs from this default will be noted in comments.
*/
import pluginJs from '@eslint/js';
import importPlugin from 'eslint-plugin-import-x';
/* added (eslint-plugin-react) - as the most popular eslint plugin for React March 24th 2025 */
import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import pluginReactRefresh from 'eslint-plugin-react-refresh';
/* added (eslint-plugin-jsx-a11y) - ensures attributes needed for accessibility are added */
import eslintPluginJsxA11y from 'eslint-plugin-jsx-a11y';
import globals from 'globals';
/* added eslint-plugin-prettier to run prettier as an ESLint plugin April 15th 2025 */
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
/* added eslint-config-prettier to turn off conflicting rules April 15th 2025 */
import eslintConfigPrettier from 'eslint-config-prettier/flat';
export default [
{ ignores: ['dist', 'vite.config.js', 'node_modules/**'] },
{
files: ['**/*.{js,mjs,cjs,jsx}'],
ignores: ['dist', 'vite.config.js'],
languageOptions: {
/* added (globals.node) - for server side elements */
globals: { ...globals.browser, ...globals.node, ...globals.jest },
ecmaVersion: 'latest', // Support all modern ECMAScript features
parserOptions: {
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
settings: {
react: {
version: 'detect',
},
'import-x/resolver': {
node: {
extensions: ['.js', '.jsx'],
},
},
'import-x/ignore': ['node_modules'],
'import-x/parsers': {
espree: ['.js', '.cjs', '.mjs', '.jsx'],
},
'import-x/internal-regex': '^(@carbon|react)',
},
},
importPlugin.flatConfigs.recommended,
/* added (eslint-plugin-react) - popular recommended config March 24th 2025 */
pluginReact.configs.flat['jsx-runtime'],
pluginReactHooks.configs.flat.recommended,
pluginReactRefresh.configs.vite,
/* added (eslint-plugin-jsx-a11y) - ensures attributes needed for accessibility are added */
eslintPluginJsxA11y.flatConfigs.recommended,
/* added eslint-plugin-prettier to run prettier as an ESLint plugin April 15th 2025 */
eslintPluginPrettierRecommended,
/* added eslint-config-prettier to turn off conflicting rules April 15th 2025 */
eslintConfigPrettier,
{
rules: {
...pluginJs.configs.recommended.rules,
/* import named is off because @carbon/react uses default exports in some components April 10th 2025 */
'import-x/named': 'off',
/* no-unused-vars - ignore pattern for React component usage */
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
/* no-irregular-whitespace
- ignore to allow prettier of the text layout. April 10th 2025.
NOTE: Should be removable after https://github.com/Mikadv/carbon-react-starter/issues/32
*/
'no-irregular-whitespace': ['error', { skipJSXText: true }],
},
},
];