eslint-config-vylda-vanilla-react 5.2.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +44 -0
- package/README.md +151 -75
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +119 -0
- package/dist/rules/a11y.d.ts +4 -0
- package/dist/rules/a11y.d.ts.map +1 -0
- package/dist/rules/a11y.js +293 -0
- package/dist/rules/best-practices.d.ts +4 -0
- package/dist/rules/best-practices.d.ts.map +1 -0
- package/dist/rules/best-practices.js +40 -0
- package/dist/rules/constants.d.ts +6 -0
- package/dist/rules/constants.d.ts.map +1 -0
- package/dist/rules/constants.js +6 -0
- package/dist/rules/hooks.d.ts +4 -0
- package/dist/rules/hooks.d.ts.map +1 -0
- package/dist/rules/hooks.js +106 -0
- package/dist/rules/imports.d.ts +6 -0
- package/dist/rules/imports.d.ts.map +1 -0
- package/dist/rules/imports.js +10 -0
- package/dist/rules/index.d.ts +9 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +10 -0
- package/dist/rules/jsx-extension.d.ts +4 -0
- package/dist/rules/jsx-extension.d.ts.map +1 -0
- package/dist/rules/jsx-extension.js +30 -0
- package/dist/rules/react.d.ts +4 -0
- package/dist/rules/react.d.ts.map +1 -0
- package/dist/rules/react.js +499 -0
- package/dist/rules/refresh.d.ts +4 -0
- package/dist/rules/refresh.d.ts.map +1 -0
- package/dist/rules/refresh.js +9 -0
- package/dist/rules/stylistic.d.ts +4 -0
- package/dist/rules/stylistic.d.ts.map +1 -0
- package/dist/rules/stylistic.js +122 -0
- package/dist/utils/legacyContext.d.ts +5 -0
- package/dist/utils/legacyContext.d.ts.map +1 -0
- package/dist/utils/legacyContext.js +47 -0
- package/dist/utils/typeGuards.d.ts +5 -0
- package/dist/utils/typeGuards.d.ts.map +1 -0
- package/dist/utils/typeGuards.js +14 -0
- package/package.json +50 -19
- package/.editorconfig +0 -12
- package/.gitlab-ci.yml +0 -13
- package/.husky/pre-commit +0 -1
- package/.husky/pre-push +0 -1
- package/.vscode/extensions.json +0 -8
- package/.vscode/settings.json +0 -6
- package/emptyjsxfile.jsx +0 -0
- package/eslint.config.mjs +0 -55
- package/index.d.ts +0 -45
- package/index.js +0 -149
- package/rules/a11y.mjs +0 -333
- package/rules/best-practices.mjs +0 -57
- package/rules/constants.mjs +0 -20
- package/rules/hooks.mjs +0 -129
- package/rules/imports.mjs +0 -12
- package/rules/index.mjs +0 -36
- package/rules/react.mjs +0 -610
- package/rules/refresh.mjs +0 -10
- package/rules/stylistic.mjs +0 -140
package/Changelog.md
CHANGED
|
@@ -4,6 +4,50 @@ All notable changes to this component will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [6.0.0] - 2026-09-20
|
|
8
|
+
### Added
|
|
9
|
+
- Rules
|
|
10
|
+
- react-hooks/exhaustive-effect-dependencies [Vilda Lipold]
|
|
11
|
+
- react-hooks/memo-dependencies [Vilda Lipold]
|
|
12
|
+
- `defaults` export: vanilla rule sets plus import rules (with the jsx-aware granular option), unmapped to files, for partial composition [Vilda Lipold]
|
|
13
|
+
- `jsxExtension` export: the `react/jsx-filename-extension` rule plus the JSX syntax option, mapped to every JavaScript file instead of `reactFiles` [Vilda Lipold]
|
|
14
|
+
- npm `overrides` block pinning `eslint-plugin-react`'s `eslint` peer to the root one. The plugin still declares `^9.7`, which makes `npm ci` fail here, where `eslint` is a direct dependency. It does not reach consumers: npm honours `overrides` only in the root project, and there the plugin is transitive, so npm nests a copy of ESLint 9 for it on its own [Vilda Lipold]
|
|
15
|
+
### Fixed
|
|
16
|
+
- `getImportConfig()` was a bare re-export of the vanilla package's own function, so calling it with no arguments silently skipped this package's jsx-aware `importExtensionsRuleGranularOption` (contrary to the README, which documents it as using "the same default values as the package") [Vilda Lipold]
|
|
17
|
+
- `importResolverAlias` was accepted by `getConfig()`/`getImportConfig()`'s option types (inherited from vanilla) but silently dropped instead of forwarded, so path aliases never actually resolved [Vilda Lipold]
|
|
18
|
+
- `defaultImportResolverNodeExtensions` was a fresh hardcoded array instead of vanilla's own list extended with `.jsx`, so it silently dropped `.svg` [Vilda Lipold]
|
|
19
|
+
- `react/forward-ref-uses-ref` and `react/jsx-filename-extension` crashed on load under ESLint 10 with `context.getSourceCode is not a function` and `context.getFilename is not a function`. eslint-plugin-react 7.37.5 reaches for both removed accessors without the fallback the rest of its rules use, so the plugin's rules now run behind a proxy that serves the removed `context` accessors from the properties that replaced them. The proxy only fills in what the context does not already have, so on ESLint 9 nothing changes [Vilda Lipold]
|
|
20
|
+
- `react/jsx-filename-extension` could never report anything. It was mapped to `reactFiles` (`**/*.jsx`), where its `noJSXWithExtension` branch is unreachable because the extension is always an allowed one, while its `extensionOnlyForJSX` branch needs `allow: 'as-needed'`, which was not set -- so `ignoreFilesWithoutCode: true` was dead too, since the plugin only reads it inside that branch. `extensions: ['.jsx']` was the rule's own default as well, leaving the rule fully inert [Vilda Lipold]
|
|
21
|
+
### Changed
|
|
22
|
+
- Rewrite to Typescript [Vilda Lipold]
|
|
23
|
+
- `eslint` moved from `dependencies` to `devDependencies`; the published package needs it only for types, so it no longer pulls a second copy of ESLint into consuming projects [Vilda Lipold]
|
|
24
|
+
- Repository moved from `gitlab.com/Vylda/eslint-config-vylda-vanilla-react` to `gitlab.com/eslint-configs/eslint-config-vylda-vanilla-react`; `package.json`'s `bugs`, `repository` and `homepage` fields and the git remote updated to match [Vilda Lipold]
|
|
25
|
+
- Rules
|
|
26
|
+
- `react/jsx-filename-extension` moved out of the `react` config into the new `jsxExtension` config, which is mapped to every JavaScript file, and switched to `allow: 'as-needed'` [Vilda Lipold]
|
|
27
|
+
### Removed
|
|
28
|
+
- Rules
|
|
29
|
+
- react-hooks/component-hook-factories [Vilda Lipold]
|
|
30
|
+
### Updated
|
|
31
|
+
- Packages
|
|
32
|
+
- eslint-config-vylda-vanilla to 6.0.0 [Vilda Lipold]
|
|
33
|
+
- eslint to 10.10.0 [Vilda Lipold]
|
|
34
|
+
- eslint-plugin-react-hooks to 7.1.1 (adds ESLint 10 support) [Vilda Lipold]
|
|
35
|
+
- eslint-plugin-react-refresh to 0.5.7 [Vilda Lipold]
|
|
36
|
+
- globals to 17.12.0 [Vilda Lipold]
|
|
37
|
+
- @eslint/config-inspector to 3.5.0 [Vilda Lipold]
|
|
38
|
+
- baseline-browser-mapping to 2.11.25 [Vilda Lipold]
|
|
39
|
+
- Readme
|
|
40
|
+
- Setup and Customization chapters rewritten for import-x/jsx-a11y-x, added a dedicated "Using path aliases" chapter, fixed a wrong package name and a missing comma in the custom-extensions example [Vilda Lipold]
|
|
41
|
+
- Partial ESLint config example: fixed wrong package name and an array-of-arrays bug (`[bestPractices, es6, ...]` instead of `[...bestPractices, ...es6, ...]`) that made `mapFiles` throw "Unexpected key \"0\" found"; added the react-only pieces to the example [Vilda Lipold]
|
|
42
|
+
- "What you can import from this package": fixed the descriptions of `defaultImportExtensionsRuleGranularOption`, `defaultImportNoExtraneousDependenciesDevDependencies` and `defaultImportResolverNodeExtensions`, which were each describing the wrong constant (cyclically shifted by one); updated every source link (now `./src/...` for our own files, the vanilla gitlab repo's `src/...` for re-exported ones) and every renamed plugin's documentation link; added the missing `defaults` and `defaultImportResolverAlias` entries [Vilda Lipold]
|
|
43
|
+
### BREAKING
|
|
44
|
+
- `eslint` is no longer a dependency of this package, so it is not installed transitively any more. A consuming project has to have its own `eslint`; the README's setup instructions already install it explicitly. This package is built and tested against ESLint 10. [Vilda Lipold]
|
|
45
|
+
- `react/jsx-filename-extension` now reports, where before it was inert. JSX in a `.js`, `.cjs` or `.mjs` file is an error, and a `.jsx` file holding no JSX is an error as well; empty `.jsx` files stay exempt through `ignoreFilesWithoutCode`. The JSX syntax is now enabled on every JavaScript file, so a `.js` file with JSX reports this rule instead of failing to parse. Code that passed on 5.2.0 can fail now: rename such files to `.jsx`, or drop the extra `.jsx` extension from files that hold no JSX. [Vilda Lipold]
|
|
46
|
+
- The rule is no longer part of the `react` config. Anyone composing the config by hand has to add the new `jsxExtension` config mapped to `files`, as the README's partial config example now shows; keeping only `react` silently drops the rule. [Vilda Lipold]
|
|
47
|
+
- Replaced eslint-plugin-jsx-a11y with eslint-plugin-jsx-a11y-x (ESLint 10-ready fork). Plugin key changed from `jsx-a11y` to `jsx-a11y-x`, and rule ids changed from `jsx-a11y/*` to `jsx-a11y-x/*`. If you overrode any `jsx-a11y/*` rule in your own config, rename it to `jsx-a11y-x/*`. [Vilda Lipold]
|
|
48
|
+
- Upgraded eslint-config-vylda-vanilla to 6.0.0, which switched from eslint-plugin-import to eslint-plugin-import-x. Effective rule ids changed from `import/*` to `import-x/*`. If you overrode any `import/*` rule in your own config, rename it to `import-x/*`. [Vilda Lipold]
|
|
49
|
+
- Renamed `refreshFiles` to `reactFiles` (export and `getConfig` option). It always covered all react/hooks/a11y/refresh/reactStylistic configs, not just react-refresh, so the old name was misleading. Rename `refreshFiles` to `reactFiles` wherever you import or pass it. [Vilda Lipold]
|
|
50
|
+
|
|
7
51
|
## [5.2.0] - 2026-01-21
|
|
8
52
|
### Changed
|
|
9
53
|
- Perfectionist only from eslint-config-vylda-vanilla [Vilda Lipold]
|
package/README.md
CHANGED
|
@@ -11,13 +11,13 @@ npm install eslint eslint-config-vylda-vanilla-react --save-dev
|
|
|
11
11
|
|
|
12
12
|
### 2. Configure ESLint
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Create `eslint.config.mjs` file in project root. You can also use any other supported flat config file name, such as `eslint.config.js`, `eslint.config.cjs`, `eslint.config.ts`, `eslint.config.mts`, or `eslint.config.cts`; see the [ESLint configuration file documentation](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file).
|
|
15
15
|
|
|
16
16
|
```javascript
|
|
17
17
|
// eslint.config.mjs
|
|
18
18
|
import { files, getConfig } from 'eslint-config-vylda-vanilla-react';
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const config = [
|
|
21
21
|
...getConfig(),
|
|
22
22
|
{
|
|
23
23
|
files,
|
|
@@ -25,23 +25,14 @@ const eslintConfig = [
|
|
|
25
25
|
rules: {
|
|
26
26
|
// Add custom rules here
|
|
27
27
|
},
|
|
28
|
-
settings: {
|
|
29
|
-
'import/resolver': {
|
|
30
|
-
alias: {
|
|
31
|
-
map: [
|
|
32
|
-
['@', './src'],
|
|
33
|
-
['@assets', './src/assets'],
|
|
34
|
-
['@utils', './src/utils'],
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
28
|
},
|
|
40
29
|
];
|
|
41
30
|
|
|
42
|
-
export default
|
|
31
|
+
export default config;
|
|
43
32
|
```
|
|
44
33
|
|
|
34
|
+
If you use path aliases (e.g. `@/...`), see [Using path aliases](#using-path-aliases) below.
|
|
35
|
+
|
|
45
36
|
### 3. Run ESLint
|
|
46
37
|
|
|
47
38
|
Open a terminal to the root of your project, and run the following command:
|
|
@@ -66,7 +57,38 @@ You can also add custom rules to the `rules` property.
|
|
|
66
57
|
|
|
67
58
|
### Customize extensions for ESLint import rules
|
|
68
59
|
You can customize extensions for ESLint import rules by using getConfig function.
|
|
69
|
-
You can extend these default extensions and dependecies with your own extensions. It is used for import plugin settings, `import/extensions` and `import/no-extraneous-dependencies` rules.
|
|
60
|
+
You can extend these default extensions and dependecies with your own extensions. It is used for import plugin settings, `import-x/extensions` and `import-x/no-extraneous-dependencies` rules.
|
|
61
|
+
|
|
62
|
+
### Using path aliases
|
|
63
|
+
|
|
64
|
+
Not every project needs path aliases, so the basic setup above doesn't include them. If you use aliases (e.g. `@/...`), use `getConfig` instead of the default export and pass the `importResolverAlias` option:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
// eslint.config.mjs
|
|
68
|
+
import { files, getConfig } from 'eslint-config-vylda-vanilla-react';
|
|
69
|
+
|
|
70
|
+
const config = getConfig({
|
|
71
|
+
// relative paths are resolved against process.cwd()
|
|
72
|
+
importResolverAlias: {
|
|
73
|
+
'@': ['./src'],
|
|
74
|
+
'@assets': ['./src/assets'],
|
|
75
|
+
'@utils': ['./src/utils'],
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const eslintConfig = [
|
|
80
|
+
...config,
|
|
81
|
+
{
|
|
82
|
+
files,
|
|
83
|
+
name: 'my-rules',
|
|
84
|
+
rules: {
|
|
85
|
+
// Add custom rules here
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
export default eslintConfig;
|
|
91
|
+
```
|
|
70
92
|
|
|
71
93
|
### Default values
|
|
72
94
|
|
|
@@ -74,37 +96,48 @@ You can extend these default extensions and dependecies with your own extensions
|
|
|
74
96
|
// default file pattern for all rules (https://eslint.org/docs/latest/use/configure/configuration-files#configuration-objects)
|
|
75
97
|
export const files = ['**/*.{cjs,js,jsx,mjs}'];
|
|
76
98
|
|
|
99
|
+
// default file pattern for the react/hooks/a11y/refresh/reactStylistic configs
|
|
100
|
+
export const reactFiles = ['**/*.jsx'];
|
|
101
|
+
|
|
102
|
+
// default file pattern for barrel files
|
|
103
|
+
export const barrelsFiles = ['**/index.{js,mjs}'];
|
|
104
|
+
|
|
77
105
|
// default plugins used in this config
|
|
78
106
|
export const plugins = {
|
|
79
107
|
'@stylistic': stylisticPlugin,
|
|
80
|
-
'import': importPlugin,
|
|
108
|
+
'import-x': importPlugin,
|
|
81
109
|
n: nodePlugin,
|
|
82
110
|
perfectionist,
|
|
83
|
-
'jsx-a11y': jsxA11yPlugin,
|
|
111
|
+
'jsx-a11y-x': jsxA11yPlugin,
|
|
84
112
|
react: reactPlugin,
|
|
85
113
|
'react-hooks': reactHooks,
|
|
86
114
|
'react-refresh': reactRefresh,
|
|
87
115
|
};
|
|
88
116
|
|
|
89
|
-
// default value for import/
|
|
90
|
-
export const defaultImportExtensions = ['.js', '.
|
|
117
|
+
// default value for import-x/extensions module settings (https://github.com/un-ts/eslint-plugin-import-x?tab=readme-ov-file#import-xextensions)
|
|
118
|
+
export const defaultImportExtensions = ['.js', '.mjs', '.jsx'];
|
|
119
|
+
|
|
120
|
+
// default value for the built-in node resolver's extensions (https://github.com/un-ts/eslint-plugin-import-x?tab=readme-ov-file#resolvers)
|
|
121
|
+
export const defaultImportResolverNodeExtensions = ['.js', '.json', '.mjs', '.svg', '.jsx'];
|
|
91
122
|
|
|
92
|
-
// default value for import/resolver
|
|
93
|
-
export const
|
|
123
|
+
// default value for import-x/resolver-next path alias map (empty by default, see Using path aliases)
|
|
124
|
+
export const defaultImportResolverAlias = {};
|
|
94
125
|
|
|
95
|
-
// default value for import/extensions rule granular option (https://github.com/
|
|
126
|
+
// default value for import-x/extensions rule granular option (https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/extensions.md#rule-details)
|
|
96
127
|
export const defaultImportExtensionsRuleGranularOption = {
|
|
97
128
|
js: 'never',
|
|
98
|
-
jsx: 'never',
|
|
99
129
|
json: 'always',
|
|
100
130
|
svg: 'always',
|
|
131
|
+
jsx: 'never',
|
|
101
132
|
};
|
|
102
133
|
|
|
103
|
-
// default value for import/no-extraneous-dependencies rule devDependencies option (https://github.com/
|
|
134
|
+
// default value for import-x/no-extraneous-dependencies rule devDependencies option (https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-extraneous-dependencies.md#dependency-options)
|
|
104
135
|
export const defaultImportNoExtraneousDependenciesDevDependencies = [
|
|
136
|
+
'espree/**', // espree parser
|
|
105
137
|
'test/**', // tape, common npm pattern
|
|
106
138
|
'tests/**', // also common npm pattern
|
|
107
139
|
'spec/**', // mocha, rspec-like pattern
|
|
140
|
+
'@testing-library/**', // testing-library patterns
|
|
108
141
|
'**/__tests__/**', // jest pattern
|
|
109
142
|
'**/__mocks__/**', // jest pattern
|
|
110
143
|
'test.{js,jsx}', // repos with a single test file
|
|
@@ -125,8 +158,9 @@ export const defaultImportNoExtraneousDependenciesDevDependencies = [
|
|
|
125
158
|
'**/protractor.conf.js', // protractor config
|
|
126
159
|
'**/protractor.conf.*.js', // protractor config
|
|
127
160
|
'**/karma.conf.js', // karma config
|
|
161
|
+
'**/eslint.config.cjs', // eslint config
|
|
162
|
+
'**/eslint.config.js', // eslint config
|
|
128
163
|
'**/eslint.config.mjs', // eslint config
|
|
129
|
-
'./rules/*.mjs', // eslint config
|
|
130
164
|
'**/vitest.config.mjs', // vitest config
|
|
131
165
|
'**/vitestSetup.mjs', // vitest setup
|
|
132
166
|
'**/tailwind.config.mjs', // tailwind config
|
|
@@ -134,6 +168,8 @@ export const defaultImportNoExtraneousDependenciesDevDependencies = [
|
|
|
134
168
|
'**/vite.config.mjs', // vite config
|
|
135
169
|
'**/vite.config.*.js', // vite config
|
|
136
170
|
'**/vite.config*.mjs', // vite config
|
|
171
|
+
'**/vitest.config.mjs', // vitest config
|
|
172
|
+
'**/vitest.config.js', // vitest config
|
|
137
173
|
];
|
|
138
174
|
```
|
|
139
175
|
|
|
@@ -151,7 +187,7 @@ import {
|
|
|
151
187
|
files as defaultFiles,
|
|
152
188
|
getConfig,
|
|
153
189
|
plugins as defaultPlugins,
|
|
154
|
-
|
|
190
|
+
} from 'eslint-config-vylda-vanilla-react';
|
|
155
191
|
import myPlugin from 'path-to-my-plugin';
|
|
156
192
|
|
|
157
193
|
const importExtensions = [
|
|
@@ -181,7 +217,7 @@ const files = [
|
|
|
181
217
|
|
|
182
218
|
const plugins = {
|
|
183
219
|
...defaultPlugins,
|
|
184
|
-
'my
|
|
220
|
+
'my-plugin': myPlugin,
|
|
185
221
|
};
|
|
186
222
|
|
|
187
223
|
const basicConfig = getConfig({
|
|
@@ -189,7 +225,7 @@ const basicConfig = getConfig({
|
|
|
189
225
|
importExtensions,
|
|
190
226
|
importExtensionsRuleGranularOption,
|
|
191
227
|
importResolverNodeExtensions,
|
|
192
|
-
importNoExtraneousDependenciesDevDependencies
|
|
228
|
+
importNoExtraneousDependenciesDevDependencies,
|
|
193
229
|
plugins,
|
|
194
230
|
});
|
|
195
231
|
|
|
@@ -197,9 +233,9 @@ const config = [
|
|
|
197
233
|
...basicConfig,
|
|
198
234
|
{
|
|
199
235
|
files,
|
|
200
|
-
name: 'my
|
|
236
|
+
name: 'my-plugin rules',
|
|
201
237
|
rules: {
|
|
202
|
-
|
|
238
|
+
'my-plugin/rule': 'error',
|
|
203
239
|
},
|
|
204
240
|
},
|
|
205
241
|
];
|
|
@@ -210,34 +246,46 @@ export default config;
|
|
|
210
246
|
## Partial ESLint config
|
|
211
247
|
You can also use the package as a partial ESLint config. This is useful if you want to use only some of the rules from the package.
|
|
212
248
|
|
|
213
|
-
If you can use import plugin, you must use `getImportConfig` function to get the config for the import plugin and import `plugins` object.
|
|
214
|
-
This function uses the same default values as the package, except `files` and `plugins` in option object.
|
|
249
|
+
If you can use the import plugin, you must use the `getImportConfig` function to get the config for the import plugin and import the `plugins` object.
|
|
250
|
+
This function uses the same default values as the package, except `files` and `plugins` in the option object.
|
|
215
251
|
|
|
216
252
|
```javascript
|
|
217
253
|
// eslint.config.mjs
|
|
218
254
|
import {
|
|
219
|
-
barrels, barrelsFiles, bestPractices, es6,
|
|
220
|
-
|
|
221
|
-
} from 'eslint-config-vylda-vanilla';
|
|
255
|
+
a11y, barrels, barrelsFiles, bestPractices, es6, getImportConfig, hooks, jsxExtension, files, mapFiles, plugins, react, reactStylistic, refresh, reactFiles,
|
|
256
|
+
} from 'eslint-config-vylda-vanilla-react';
|
|
222
257
|
|
|
223
258
|
const configs = [
|
|
224
|
-
bestPractices,
|
|
225
|
-
es6,
|
|
226
|
-
// you can add custom options object to the function
|
|
227
|
-
// optional parameters: importExtensions, importExtensionsRuleGranularOption, importResolverNodeExtensions,importNoExtraneousDependenciesDevDependencies
|
|
228
|
-
getImportConfig()
|
|
259
|
+
...bestPractices,
|
|
260
|
+
...es6,
|
|
261
|
+
// you can add a custom options object to the getImportConfig function
|
|
262
|
+
// optional parameters: importExtensions, importExtensionsRuleGranularOption, importResolverAlias, importResolverNodeExtensions, importNoExtraneousDependenciesDevDependencies
|
|
263
|
+
...getImportConfig(),
|
|
264
|
+
];
|
|
265
|
+
|
|
266
|
+
// the react-only pieces are mapped to their own files, same as the default export does
|
|
267
|
+
const reactConfigs = [
|
|
268
|
+
...a11y,
|
|
269
|
+
...hooks,
|
|
270
|
+
...react,
|
|
271
|
+
...reactStylistic,
|
|
272
|
+
...refresh,
|
|
229
273
|
];
|
|
230
274
|
|
|
231
275
|
const configWithFiles = mapFiles(configs, files);
|
|
276
|
+
const reactConfigWithFiles = mapFiles(reactConfigs, reactFiles);
|
|
277
|
+
const jsxExtensionWithFiles = mapFiles(jsxExtension, files);
|
|
232
278
|
const barrelsWithFiles = mapFiles(barrels, barrelsFiles);
|
|
233
279
|
|
|
234
280
|
const config = [
|
|
235
281
|
{
|
|
236
282
|
plugins,
|
|
237
|
-
}
|
|
283
|
+
},
|
|
238
284
|
...configWithFiles,
|
|
285
|
+
...reactConfigWithFiles,
|
|
286
|
+
...jsxExtensionWithFiles,
|
|
239
287
|
...barrelsWithFiles,
|
|
240
|
-
]
|
|
288
|
+
];
|
|
241
289
|
|
|
242
290
|
export default config;
|
|
243
291
|
```
|
|
@@ -248,39 +296,67 @@ All rules are without `files` property, so you can use them as a partial ESLint
|
|
|
248
296
|
You can use `files` property to specify the files for the rule.
|
|
249
297
|
You can also use `mapFiles` function to map files for all rules.
|
|
250
298
|
|
|
251
|
-
- `default export` - default ESLint config
|
|
252
|
-
- `a11y` - ESLint config with rules for accessibility in React components ([source](./rules/a11y.
|
|
253
|
-
- `barrels` - ESLint config with rules for barrel files ([source](https://gitlab.com/
|
|
254
|
-
- `barrelsFiles` - default file pattern for barrel files ([
|
|
255
|
-
- `bestPractices` - ESLint config with rules for best practices ([source](./rules/best-practices.
|
|
256
|
-
- `constants` - Constants for some ESLint rules ([source](./rules/constants.
|
|
257
|
-
- `customs` - ESLint config with my custom rules ([source](https://gitlab.com/
|
|
258
|
-
- `defaultImportExtensions` - default value for import/
|
|
259
|
-
- `defaultImportExtensionsRuleGranularOption` - default value for import/
|
|
260
|
-
- `defaultImportNoExtraneousDependenciesDevDependencies` - default value for import/
|
|
261
|
-
- `
|
|
262
|
-
- `
|
|
263
|
-
- `
|
|
264
|
-
- `
|
|
265
|
-
- `
|
|
266
|
-
- `
|
|
267
|
-
- `
|
|
268
|
-
- `
|
|
269
|
-
- `
|
|
270
|
-
- `
|
|
271
|
-
- `
|
|
272
|
-
- `
|
|
273
|
-
- `
|
|
274
|
-
- `
|
|
275
|
-
- `
|
|
276
|
-
- `
|
|
277
|
-
- `
|
|
278
|
-
- `
|
|
279
|
-
- `
|
|
280
|
-
- `
|
|
281
|
-
- `
|
|
282
|
-
- `
|
|
283
|
-
- `
|
|
299
|
+
- `default export` - default ESLint config
|
|
300
|
+
- `a11y` - ESLint config with rules for accessibility in React components ([source](./src/rules/a11y.ts), [documentation](https://github.com/es-tooling/eslint-plugin-jsx-a11y-x#readme))
|
|
301
|
+
- `barrels` - ESLint config with rules for barrel files ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/rules/barrels.ts), [documentation](https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/prefer-default-export.md))
|
|
302
|
+
- `barrelsFiles` - default file pattern for barrel files ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/index.ts), [documentation](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-objects))
|
|
303
|
+
- `bestPractices` - ESLint config with rules for best practices, extended with React lifecycle methods for `class-methods-use-this` ([source](./src/rules/best-practices.ts), [documentation (js)](https://eslint.org/docs/latest/rules), [documentation (stylistic)](https://eslint.style/packages/js#rules))
|
|
304
|
+
- `constants` - Constants for some ESLint rules ([source](./src/rules/constants.ts))
|
|
305
|
+
- `customs` - ESLint config with my custom rules ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/rules/customs.ts))
|
|
306
|
+
- `defaultImportExtensions` - default value for import-x/extensions module settings ([source](./src/rules/imports.ts), [documentation](https://github.com/un-ts/eslint-plugin-import-x?tab=readme-ov-file#import-xextensions))
|
|
307
|
+
- `defaultImportExtensionsRuleGranularOption` - default value for import-x/extensions rule granular option ([source](./src/rules/imports.ts), [documentation](https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/extensions.md#rule-details))
|
|
308
|
+
- `defaultImportNoExtraneousDependenciesDevDependencies` - default value for import-x/no-extraneous-dependencies rule devDependencies option ([source](./src/rules/imports.ts), [documentation](https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-extraneous-dependencies.md#dependency-options))
|
|
309
|
+
- `defaultImportResolverAlias` - default value for the `importResolverAlias` option (empty object, no aliases), see [Using path aliases](#using-path-aliases) ([source](./src/rules/imports.ts))
|
|
310
|
+
- `defaultImportResolverNodeExtensions` - default value for the built-in node resolver's extensions ([source](./src/rules/imports.ts), [documentation](https://github.com/un-ts/eslint-plugin-import-x?tab=readme-ov-file#resolvers))
|
|
311
|
+
- `defaults` - vanilla rule sets plus import rules (with the jsx-aware granular option), unmapped to files, for partial composition ([source](./src/index.ts))
|
|
312
|
+
- `errors` - ESLint config with rules for errors ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/rules/errors.ts), [documentation](https://eslint.org/docs/latest/rules))
|
|
313
|
+
- `es6` - ESLint config with rules for ES6 ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/rules/es6.ts), [documentation (js)](https://eslint.org/docs/latest/rules), [documentation (stylistic)](https://eslint.style/packages/js#rules))
|
|
314
|
+
- `files` - default file pattern for all rules ([source](./src/index.ts), [documentation](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-objects))
|
|
315
|
+
- `getConfig` - function to get ESLint config with custom options ([source](./src/index.ts))
|
|
316
|
+
- `getImportConfig` - function to get ESLint config for the import plugin, using this package's own jsx-aware defaults ([source](./src/index.ts))
|
|
317
|
+
- `hooks` - ESLint config with rules for hooks ([source](./src/rules/hooks.ts), [documentation](https://react.dev/reference/eslint-plugin-react-hooks))
|
|
318
|
+
- `ignores` - ESLint config with global ignored folder patterns ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/ignores.ts), [documentation](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files))
|
|
319
|
+
- `jsxExtension` - ESLint config restricting which file extensions may hold JSX, and enabling the JSX syntax; mapped to every JavaScript file rather than to `reactFiles` ([source](./src/rules/jsx-extension.ts), [documentation](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md))
|
|
320
|
+
- `mapFiles` - helper function to map files for all configs ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/mapFiles.ts))
|
|
321
|
+
- `node` - ESLint config with rules for Node.js ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/rules/node.ts), [documentation](https://github.com/eslint-community/eslint-plugin-n/?tab=readme-ov-file#-rules))
|
|
322
|
+
- `perfectionist` - ESLint config with rules for perfectionist ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/rules/perfectionist.ts), [documentation](https://perfectionist.dev/rules))
|
|
323
|
+
- `plugins` - default plugins used in this config ([source](./src/index.ts))
|
|
324
|
+
- `plus` - ESLint config with rules for extended rules ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/rules/plus.ts), [documentation](https://eslint.style/packages/plus))
|
|
325
|
+
- `react` - ESLint config with rules for React ([source](./src/rules/react.ts), [documentation](https://github.com/jsx-eslint/eslint-plugin-react#readme))
|
|
326
|
+
- `reactConfigs` - ESLint config with rules for React only ([source](./src/index.ts))
|
|
327
|
+
- `reactFiles` - default file pattern for the react/hooks/a11y/refresh/reactStylistic configs ([source](./src/index.ts))
|
|
328
|
+
- `reactPlugins` - ESLint plugins used for React only ([source](./src/index.ts))
|
|
329
|
+
- `reactStylistic` - ESLint config with stylistic rules for React ([source](./src/rules/stylistic.ts), [documentation](https://eslint.style/packages/jsx))
|
|
330
|
+
- `refresh` - ESLint config with rules for React refresh ([source](./src/rules/refresh.ts), [documentation](https://github.com/ArnaudBarre/eslint-plugin-react-refresh#readme))
|
|
331
|
+
- `strict` - ESLint config with rules for strict mode ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/rules/strict.ts), [documentation](https://eslint.org/docs/latest/rules))
|
|
332
|
+
- `stylistic` - ESLint config with vanilla stylistic rules ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/rules/stylistic.ts), [documentation](https://eslint.style/packages/js#rules))
|
|
333
|
+
- `TConfig` - TypeScript type for an ESLint flat config array (`Array<Linter.Config>`) ([source](./src/index.ts))
|
|
334
|
+
- `TGetConfigOptions` - TypeScript type for the options object accepted by `getConfig` ([source](./src/index.ts))
|
|
335
|
+
- `TGetImportConfigOptions` - TypeScript type for the options object accepted by `getImportConfig` ([source](./src/index.ts))
|
|
336
|
+
- `TPlugin` - TypeScript type alias for a single ESLint plugin (`ESLint.Plugin`) ([source](./src/index.ts))
|
|
337
|
+
- `TPlugins` - TypeScript type alias for a map of plugins (`Record<string, TPlugin>`) ([source](./src/index.ts))
|
|
338
|
+
- `vanillaConfigs` - ESLint configuration for vanilla javascript only (without import rules) ([source](./src/index.ts))
|
|
339
|
+
- `variables` - ESLint config with rules for variables ([source](https://gitlab.com/eslint-configs/eslint-config-vylda-vanilla/-/blob/main/src/rules/variables.ts), [documentation](https://eslint.org/docs/latest/rules))
|
|
340
|
+
|
|
341
|
+
## ESLint 10 compatibility
|
|
342
|
+
|
|
343
|
+
`eslint-plugin-react` has had no release since 7.37.5 (2025-04-03) and still declares a peer range of `^9.7`. Two of its rules reach for accessors that ESLint 10 removed, without the fallback the rest of its rules use, and crash on load:
|
|
344
|
+
|
|
345
|
+
| rule | call | removed in favour of |
|
|
346
|
+
| --- | --- | --- |
|
|
347
|
+
| `react/forward-ref-uses-ref` | `context.getSourceCode()` | `context.sourceCode` |
|
|
348
|
+
| `react/jsx-filename-extension` | `context.getFilename()` | `context.filename` |
|
|
349
|
+
|
|
350
|
+
This package works around both, so there is nothing to do on your side:
|
|
351
|
+
|
|
352
|
+
- the plugin's rules run behind a proxy ([source](./src/utils/legacyContext.ts)) that serves the removed `context` accessors from the properties that replaced them. It only fills in what the context does not already have, so on ESLint 9 nothing changes.
|
|
353
|
+
- an `overrides` block in `package.json` pins the plugin's `eslint` peer to the root one. That block applies to this repository only: npm honours `overrides` from the root project, and in your project the plugin is a transitive dependency, where npm resolves the peer on its own.
|
|
354
|
+
|
|
355
|
+
### TODO: re-check on the next eslint-plugin-react release
|
|
356
|
+
|
|
357
|
+
- Drop `withLegacyContextRules` from [src/index.ts](./src/index.ts) and run `npm test`. The test `react rules that call the context API removed in ESLint 10 still run` fails for as long as the proxy is needed. Once it passes without it, delete [src/utils/legacyContext.ts](./src/utils/legacyContext.ts), its test and the call.
|
|
358
|
+
- Once the plugin's peer range covers ESLint 10, drop the `overrides` block from `package.json` and verify with `npm ci`, not `npm install` -- the latter only warns.
|
|
359
|
+
- `react/jsx-curly-spacing`, `react/jsx-equals-spacing`, `react/jsx-one-expression-per-line`, `react/jsx-space-before-closing` and `react/jsx-tag-spacing` crash on `sourceCode.isSpaceBetweenTokens`, which the proxy cannot reach because it is a `SourceCode` method rather than a `context` accessor. All five are `off` (`@stylistic` covers them), so nothing depends on this today.
|
|
284
360
|
|
|
285
361
|
## Additional Documentation
|
|
286
362
|
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { barrels, barrelsFiles, customs, errors, es6, ignores, mapFiles, node, perfectionist, plus, strict, stylistic, type TGetImportConfigOptions as TVanillaGetImportConfigOptions, variables } from 'eslint-config-vylda-vanilla';
|
|
2
|
+
import bestPractices from './rules/best-practices.js';
|
|
3
|
+
import * as constants from './rules/constants.js';
|
|
4
|
+
import { defaultImportExtensions, defaultImportExtensionsRuleGranularOption, defaultImportNoExtraneousDependenciesDevDependencies, defaultImportResolverAlias, defaultImportResolverNodeExtensions } from './rules/imports.js';
|
|
5
|
+
import { a11y, hooks, jsxExtension, react, reactStylistic, refresh } from './rules/index.js';
|
|
6
|
+
import type { ESLint, Linter } from 'eslint';
|
|
7
|
+
export type TConfig = Array<Linter.Config>;
|
|
8
|
+
export type TGetConfigOptions = TGetImportConfigOptions & {
|
|
9
|
+
barrelsFiles?: Array<string>;
|
|
10
|
+
files?: Array<string>;
|
|
11
|
+
plugins?: TPlugins;
|
|
12
|
+
reactFiles?: Array<string>;
|
|
13
|
+
};
|
|
14
|
+
export type TGetImportConfigOptions = TVanillaGetImportConfigOptions;
|
|
15
|
+
export type TPlugin = ESLint.Plugin;
|
|
16
|
+
export type TPlugins = Record<string, TPlugin>;
|
|
17
|
+
export declare const files: Array<string>;
|
|
18
|
+
export declare const reactFiles: Array<string>;
|
|
19
|
+
export declare const reactPlugins: TPlugins;
|
|
20
|
+
export declare const plugins: TPlugins;
|
|
21
|
+
export declare const getImportConfig: (options?: TGetImportConfigOptions) => TConfig;
|
|
22
|
+
declare const reactConfigs: TConfig;
|
|
23
|
+
export declare const getConfig: (options?: TGetConfigOptions) => TConfig;
|
|
24
|
+
export declare const vanillaConfigs: TConfig;
|
|
25
|
+
export declare const defaults: TConfig;
|
|
26
|
+
declare const config: TConfig;
|
|
27
|
+
export { a11y, barrels, barrelsFiles, bestPractices, constants, customs, defaultImportExtensions, defaultImportExtensionsRuleGranularOption, defaultImportNoExtraneousDependenciesDevDependencies, defaultImportResolverAlias, defaultImportResolverNodeExtensions, errors, es6, hooks, ignores, jsxExtension, mapFiles, node, perfectionist, plus, react, reactConfigs, reactStylistic, refresh, strict, stylistic, variables, };
|
|
28
|
+
export default config;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EACpE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EACtC,KAAK,uBAAuB,IAAI,8BAA8B,EACQ,SAAS,EAChF,MAAM,6BAA6B,CAAC;AAMrC,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,yCAAyC,EACzC,oDAAoD,EACpD,0BAA0B,EAC1B,mCAAmC,EACpC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAC1D,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE7C,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC3C,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GAAG;IACxD,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAErE,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;AAEpC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,MAAM,CAA6B,CAAC;AAC9D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,MAAM,CAAgB,CAAC;AAatD,eAAO,MAAM,YAAY,EAAE,QAK1B,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,QAGrB,CAAC;AASF,eAAO,MAAM,eAAe,GAAI,UAAS,uBAA4B,KAAG,OAgBvE,CAAC;AAcF,QAAA,MAAM,YAAY,EAAE,OAMnB,CAAC;AAyCF,eAAO,MAAM,SAAS,GAAI,UAAS,iBAAkC,KAAG,OA8BvE,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,OAAkC,CAAC;AAUhE,eAAO,MAAM,QAAQ,EAAE,OAAoD,CAAC;AAE5E,QAAA,MAAM,MAAM,EAAE,OAAqB,CAAC;AAEpC,OAAO,EACL,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,aAAa,EACb,SAAS,EACT,OAAO,EACP,uBAAuB,EACvB,yCAAyC,EACzC,oDAAoD,EACpD,0BAA0B,EAC1B,mCAAmC,EACnC,MAAM,EACN,GAAG,EACH,KAAK,EACL,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,aAAa,EACb,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,cAAc,EACd,OAAO,EACP,MAAM,EACN,SAAS,EACT,SAAS,GACV,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { barrels, barrelsFiles, customs, errors, es6, ignores, mapFiles, node, perfectionist, plus, strict, stylistic, getImportConfig as vanillaGetImportConfig, plugins as vanillaPlugins, variables, } from 'eslint-config-vylda-vanilla';
|
|
2
|
+
import jsxA11y from 'eslint-plugin-jsx-a11y-x';
|
|
3
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
4
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
5
|
+
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
6
|
+
// eslint-disable-next-line import-x/no-rename-default
|
|
7
|
+
import bestPractices from './rules/best-practices.js';
|
|
8
|
+
import * as constants from './rules/constants.js';
|
|
9
|
+
import { defaultImportExtensions, defaultImportExtensionsRuleGranularOption, defaultImportNoExtraneousDependenciesDevDependencies, defaultImportResolverAlias, defaultImportResolverNodeExtensions, } from './rules/imports.js';
|
|
10
|
+
import { a11y, hooks, jsxExtension, react, reactStylistic, refresh, } from './rules/index.js';
|
|
11
|
+
import { withLegacyContextRules } from './utils/legacyContext.js';
|
|
12
|
+
export const files = ['**/*.{cjs,js,jsx,mjs}'];
|
|
13
|
+
export const reactFiles = ['**/*.jsx'];
|
|
14
|
+
const jsxA11yPlugin = jsxA11y.configs.strict.plugins['jsx-a11y-x'];
|
|
15
|
+
// `configs` is dropped instead of typed: react-hooks in particular ships a `configs.flat` shape
|
|
16
|
+
// that eslint's own `Plugin.configs` type does not accept, and nothing here reads `configs`.
|
|
17
|
+
const { configs: droppedReactPluginConfigs, ...reactPluginWithoutConfigs } = reactPlugin;
|
|
18
|
+
const { configs: droppedReactHooksConfigs, ...reactHooksWithoutConfigs } = reactHooks;
|
|
19
|
+
// eslint-plugin-react 7.37.5 still calls `context` accessors that ESLint 10 removed, so its rules
|
|
20
|
+
// run behind a compatibility proxy. The other three plugins already declare ESLint 10 support.
|
|
21
|
+
const reactPluginWithLegacyContext = withLegacyContextRules(reactPluginWithoutConfigs);
|
|
22
|
+
export const reactPlugins = {
|
|
23
|
+
'jsx-a11y-x': jsxA11yPlugin,
|
|
24
|
+
react: reactPluginWithLegacyContext,
|
|
25
|
+
'react-hooks': reactHooksWithoutConfigs,
|
|
26
|
+
'react-refresh': reactRefresh,
|
|
27
|
+
};
|
|
28
|
+
export const plugins = {
|
|
29
|
+
...vanillaPlugins,
|
|
30
|
+
...reactPlugins,
|
|
31
|
+
};
|
|
32
|
+
const dineddd = defaultImportNoExtraneousDependenciesDevDependencies;
|
|
33
|
+
const diergo = defaultImportExtensionsRuleGranularOption;
|
|
34
|
+
const diralias = defaultImportResolverAlias;
|
|
35
|
+
// Wraps vanilla's `getImportConfig` so it defaults to this package's own import settings
|
|
36
|
+
// (including the jsx-aware `importExtensionsRuleGranularOption`) instead of vanilla's plain
|
|
37
|
+
// ones -- matching what the README documents ("uses the same default values as the package").
|
|
38
|
+
export const getImportConfig = (options = {}) => {
|
|
39
|
+
const { importExtensions: ie = defaultImportExtensions, importExtensionsRuleGranularOption: iergo = diergo, importNoExtraneousDependenciesDevDependencies: ineddd = dineddd, importResolverAlias: ira = diralias, importResolverNodeExtensions: irne = defaultImportResolverNodeExtensions, } = options;
|
|
40
|
+
return vanillaGetImportConfig({
|
|
41
|
+
importExtensions: ie,
|
|
42
|
+
importExtensionsRuleGranularOption: iergo,
|
|
43
|
+
importNoExtraneousDependenciesDevDependencies: ineddd,
|
|
44
|
+
importResolverAlias: ira,
|
|
45
|
+
importResolverNodeExtensions: irne,
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const defaultOptions = {
|
|
49
|
+
barrelsFiles,
|
|
50
|
+
files,
|
|
51
|
+
importExtensions: defaultImportExtensions,
|
|
52
|
+
importExtensionsRuleGranularOption: diergo,
|
|
53
|
+
importNoExtraneousDependenciesDevDependencies: dineddd,
|
|
54
|
+
importResolverAlias: diralias,
|
|
55
|
+
importResolverNodeExtensions: defaultImportResolverNodeExtensions,
|
|
56
|
+
plugins,
|
|
57
|
+
reactFiles,
|
|
58
|
+
};
|
|
59
|
+
const reactConfigs = [
|
|
60
|
+
...a11y,
|
|
61
|
+
...hooks,
|
|
62
|
+
...react,
|
|
63
|
+
...reactStylistic,
|
|
64
|
+
...refresh,
|
|
65
|
+
];
|
|
66
|
+
const createVanillaConfigs = (importConfigs) => [
|
|
67
|
+
...importConfigs,
|
|
68
|
+
...es6,
|
|
69
|
+
...strict,
|
|
70
|
+
...stylistic,
|
|
71
|
+
...bestPractices,
|
|
72
|
+
...errors,
|
|
73
|
+
...node,
|
|
74
|
+
...variables,
|
|
75
|
+
...customs,
|
|
76
|
+
...perfectionist,
|
|
77
|
+
...plus,
|
|
78
|
+
];
|
|
79
|
+
const createReactConfig = (customFiles, customBarrelsFiles, customReactFiles, customPlugins, vanillaBaseConfigs) => {
|
|
80
|
+
const configsWithFiles = mapFiles(vanillaBaseConfigs, customFiles);
|
|
81
|
+
const reactConfigWithFiles = mapFiles(reactConfigs, customReactFiles);
|
|
82
|
+
const jsxExtensionWithFiles = mapFiles(jsxExtension, customFiles);
|
|
83
|
+
const barrelsConfigWithFiles = mapFiles(barrels, customBarrelsFiles);
|
|
84
|
+
return [
|
|
85
|
+
{
|
|
86
|
+
name: 'vanilla-react/base',
|
|
87
|
+
plugins: customPlugins,
|
|
88
|
+
},
|
|
89
|
+
...configsWithFiles,
|
|
90
|
+
...reactConfigWithFiles,
|
|
91
|
+
...jsxExtensionWithFiles,
|
|
92
|
+
...barrelsConfigWithFiles,
|
|
93
|
+
...ignores,
|
|
94
|
+
];
|
|
95
|
+
};
|
|
96
|
+
export const getConfig = (options = defaultOptions) => {
|
|
97
|
+
const { barrelsFiles: customBarrelsFiles = barrelsFiles, files: customFiles = files, importExtensions: ie = defaultImportExtensions, importExtensionsRuleGranularOption: iergo = diergo, importNoExtraneousDependenciesDevDependencies: ineddd = dineddd, importResolverAlias: ira = diralias, importResolverNodeExtensions: irne = defaultImportResolverNodeExtensions, plugins: customPlugins = plugins, reactFiles: customReactFiles = reactFiles, } = options;
|
|
98
|
+
const importConfigs = getImportConfig({
|
|
99
|
+
importExtensions: ie,
|
|
100
|
+
importExtensionsRuleGranularOption: iergo,
|
|
101
|
+
importNoExtraneousDependenciesDevDependencies: ineddd,
|
|
102
|
+
importResolverAlias: ira,
|
|
103
|
+
importResolverNodeExtensions: irne,
|
|
104
|
+
});
|
|
105
|
+
const vanillaConfigsForOptions = createVanillaConfigs(importConfigs);
|
|
106
|
+
return createReactConfig(customFiles, customBarrelsFiles, customReactFiles, customPlugins, vanillaConfigsForOptions);
|
|
107
|
+
};
|
|
108
|
+
export const vanillaConfigs = createVanillaConfigs([]);
|
|
109
|
+
const defaultImportConfigs = getImportConfig({
|
|
110
|
+
importExtensions: defaultImportExtensions,
|
|
111
|
+
importExtensionsRuleGranularOption: diergo,
|
|
112
|
+
importNoExtraneousDependenciesDevDependencies: dineddd,
|
|
113
|
+
importResolverAlias: diralias,
|
|
114
|
+
importResolverNodeExtensions: defaultImportResolverNodeExtensions,
|
|
115
|
+
});
|
|
116
|
+
export const defaults = createVanillaConfigs(defaultImportConfigs);
|
|
117
|
+
const config = getConfig();
|
|
118
|
+
export { a11y, barrels, barrelsFiles, bestPractices, constants, customs, defaultImportExtensions, defaultImportExtensionsRuleGranularOption, defaultImportNoExtraneousDependenciesDevDependencies, defaultImportResolverAlias, defaultImportResolverNodeExtensions, errors, es6, hooks, ignores, jsxExtension, mapFiles, node, perfectionist, plus, react, reactConfigs, reactStylistic, refresh, strict, stylistic, variables, };
|
|
119
|
+
export default config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y.d.ts","sourceRoot":"","sources":["../../src/rules/a11y.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAmGrC,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAqOhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|