eslint-config-vylda-vanilla-react 4.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/.editorconfig +12 -0
- package/.gitlab-ci.yml +13 -0
- package/.husky/pre-commit +1 -0
- package/.husky/pre-push +1 -0
- package/.vscode/extensions.json +8 -0
- package/.vscode/settings.json +6 -0
- package/Changelog.md +112 -0
- package/LICENSE +24 -0
- package/README.md +294 -0
- package/eslint.config.mjs +55 -0
- package/index.js +150 -0
- package/package.json +43 -0
- package/rules/a11y.mjs +333 -0
- package/rules/best-practices.mjs +57 -0
- package/rules/constants.mjs +20 -0
- package/rules/hooks.mjs +129 -0
- package/rules/imports.mjs +12 -0
- package/rules/index.mjs +37 -0
- package/rules/perfectionist.mjs +33 -0
- package/rules/react.mjs +610 -0
- package/rules/refresh.mjs +10 -0
- package/rules/stylistic.mjs +154 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# EditorConfig is awesome: http://EditorConfig.org
|
|
2
|
+
|
|
3
|
+
# top-most EditorConfig file
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
# Unix-style newlines with a newline ending every file
|
|
7
|
+
[*.{css,js,json,mjs,svg,ts,tsx}]
|
|
8
|
+
indent_style = space
|
|
9
|
+
end_of_line = lf
|
|
10
|
+
charset = utf-8
|
|
11
|
+
insert_final_newline = true
|
|
12
|
+
indent_size = 2
|
package/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# You can override the included template(s) by including variable overrides
|
|
2
|
+
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
|
|
3
|
+
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/pipeline/#customization
|
|
4
|
+
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
|
|
5
|
+
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
|
|
6
|
+
# Note that environment variables can be set in several places
|
|
7
|
+
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
|
|
8
|
+
stages:
|
|
9
|
+
- test
|
|
10
|
+
sast:
|
|
11
|
+
stage: test
|
|
12
|
+
include:
|
|
13
|
+
- template: Security/SAST.gitlab-ci.yml
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm test
|
package/.husky/pre-push
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm test
|
package/Changelog.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this component will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [4.0.0] - 2025-11-01
|
|
8
|
+
### Added
|
|
9
|
+
- Rules (some rules are not officially documented)
|
|
10
|
+
- react-hooks/automatic-effect-dependencies [Vilda Lipold]
|
|
11
|
+
- react-hooks/capitalized-calls [Vilda Lipold]
|
|
12
|
+
- react-hooks/component-hook-factories [Vilda Lipold]
|
|
13
|
+
- react-hooks/config [Vilda Lipold]
|
|
14
|
+
- react-hooks/error-boundaries [Vilda Lipold]
|
|
15
|
+
- react-hooks/fbt [Vilda Lipold]
|
|
16
|
+
- react-hooks/fire [Vilda Lipold]
|
|
17
|
+
- react-hooks/gating [Vilda Lipold]
|
|
18
|
+
- react-hooks/globals [Vilda Lipold]
|
|
19
|
+
- react-hooks/hooks [Vilda Lipold]
|
|
20
|
+
- react-hooks/immutability [Vilda Lipold]
|
|
21
|
+
- react-hooks/incompatible-library [Vilda Lipold]
|
|
22
|
+
- react-hooks/invariant [Vilda Lipold]
|
|
23
|
+
- react-hooks/memoized-effect-dependencies [Vilda Lipold]
|
|
24
|
+
- react-hooks/no-deriving-state-in-effects [Vilda Lipold]
|
|
25
|
+
- react-hooks/preserve-manual-memoization [Vilda Lipold]
|
|
26
|
+
- react-hooks/purity [Vilda Lipold]
|
|
27
|
+
- react-hooks/refs [Vilda Lipold]
|
|
28
|
+
- react-hooks/rule-suppression [Vilda Lipold]
|
|
29
|
+
- react-hooks/set-state-in-effect [Vilda Lipold]
|
|
30
|
+
- react-hooks/set-state-in-render [Vilda Lipold]
|
|
31
|
+
- react-hooks/static-components [Vilda Lipold]
|
|
32
|
+
- react-hooks/syntax [Vilda Lipold]
|
|
33
|
+
- react-hooks/todo [Vilda Lipold]
|
|
34
|
+
- react-hooks/unsupported-syntax [Vilda Lipold]
|
|
35
|
+
- react-hooks/use-memo [Vilda Lipold]
|
|
36
|
+
- react-hooks/void-use-memo [Vilda Lipold]
|
|
37
|
+
### Removed
|
|
38
|
+
- Rules
|
|
39
|
+
- jsx-props-no-multi-spaces [Vilda Lipold]
|
|
40
|
+
### Updated
|
|
41
|
+
- Packages [Vilda Lipold]
|
|
42
|
+
- Rules
|
|
43
|
+
- react/jsx-props-no-multi-spaces [Vilda Lipold]
|
|
44
|
+
|
|
45
|
+
## [3.1.1] - 2025-06-02
|
|
46
|
+
### Added
|
|
47
|
+
- BarrelsFiles [Vilda Lipold]
|
|
48
|
+
- Constants for some ESLint rules [Vilda Lipold]
|
|
49
|
+
- Rules
|
|
50
|
+
- barrels [Vilda Lipold]
|
|
51
|
+
- import/no-unassigned-import [Vilda Lipold]
|
|
52
|
+
- perfectionist [Vilda Lipold]
|
|
53
|
+
### Changed
|
|
54
|
+
- Rules
|
|
55
|
+
- import/no-unassigned-import [Vilda Lipold]
|
|
56
|
+
- perfectionist/sort-jsx-props [Vilda Lipold]
|
|
57
|
+
|
|
58
|
+
## [3.1.0] - 2025-05-27
|
|
59
|
+
### Added
|
|
60
|
+
- perfectionist plugin [Vilda Lipold]
|
|
61
|
+
- Rules
|
|
62
|
+
- plus
|
|
63
|
+
### Changed
|
|
64
|
+
- @stylistic/jsx to @stylistic [Vilda Lipold]
|
|
65
|
+
|
|
66
|
+
## [3.0.0] - 2025-05-20
|
|
67
|
+
### Added
|
|
68
|
+
- Best practices for React [Vilda Lipold]
|
|
69
|
+
### Changed
|
|
70
|
+
- Refactored the package [Vilda Lipold]
|
|
71
|
+
### Removed
|
|
72
|
+
- Rules
|
|
73
|
+
- jsx-quotes (deprecated) [Vilda Lipold]
|
|
74
|
+
- @stylistic/jsx/jsx-indent (deprecated) [Vilda Lipold]
|
|
75
|
+
### Updated
|
|
76
|
+
- Packages [Vilda Lipold]
|
|
77
|
+
- Readme [Vilda Lipold]
|
|
78
|
+
|
|
79
|
+
## [2.1.0] - 2025-05-13
|
|
80
|
+
### Added
|
|
81
|
+
- Config names [Vilda Lipold]
|
|
82
|
+
### Updated
|
|
83
|
+
- Packages [Vilda Lipold]
|
|
84
|
+
|
|
85
|
+
## [2.0.1] - 2025-04-021
|
|
86
|
+
### Updated
|
|
87
|
+
- Packages [Vilda Lipold]
|
|
88
|
+
|
|
89
|
+
## [2.0.0] - 2025-04-02
|
|
90
|
+
### Added
|
|
91
|
+
- eslint-plugin-react-refresh [Vilda Lipold]
|
|
92
|
+
### Updated
|
|
93
|
+
- Import settings for jsx files [Vilda Lipold]
|
|
94
|
+
- Readme [Vilda Lipold]
|
|
95
|
+
|
|
96
|
+
## [1.0.3] - 2025-03-26
|
|
97
|
+
### Updated
|
|
98
|
+
- Vanilla package [Vilda Lipold]
|
|
99
|
+
|
|
100
|
+
## [1.0.2] - 2025-03-26
|
|
101
|
+
### Updated
|
|
102
|
+
- Readme - install script [Vilda Lipold]
|
|
103
|
+
|
|
104
|
+
## [1.0.1] - 2025-03-26
|
|
105
|
+
### Added
|
|
106
|
+
- Ignored folders [Vilda Lipold]
|
|
107
|
+
- Globals package [Vilda Lipold]
|
|
108
|
+
- Packages update [Vilda Lipold]
|
|
109
|
+
|
|
110
|
+
## [1.0.0] - 2025-03-26
|
|
111
|
+
### Added
|
|
112
|
+
- First release [Vilda Lipold]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Vilem Lipold <vilem.lipold@studentagency.cz>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
|
6
|
+
obtaining a copy of this software and associated documentation
|
|
7
|
+
files (the "Software"), to deal in the Software without
|
|
8
|
+
restriction, including without limitation the rights to use,
|
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the
|
|
11
|
+
Software is furnished to do so, subject to the following
|
|
12
|
+
conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# eslint-config-vylda-vanilla-react
|
|
2
|
+
|
|
3
|
+
Enhances Vylda's ESLint config for Vanilla React
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
### 1. Install dependencies
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install eslint eslint-config-vylda-vanilla-react --save-dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### 2. Configure ESLint
|
|
13
|
+
|
|
14
|
+
create `eslint.config.mjs` file in project root
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
// eslint.config.mjs
|
|
18
|
+
import config, { files } from 'eslint-config-vylda-vanilla-react';
|
|
19
|
+
|
|
20
|
+
const eslintConfig = [
|
|
21
|
+
...config,
|
|
22
|
+
{
|
|
23
|
+
files,
|
|
24
|
+
name: 'my-rules',
|
|
25
|
+
rules: {
|
|
26
|
+
// Add custom rules here
|
|
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
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export default eslintConfig;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 3. Run ESLint
|
|
46
|
+
|
|
47
|
+
Open a terminal to the root of your project, and run the following command:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx eslint .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
or
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx eslint ./src/
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
ESLint will lint all `.js`, `.jsx`, `mjs` and `.cjs` files within the current or `./src` folder , and output results to your terminal.
|
|
60
|
+
|
|
61
|
+
You can also get results in realtime inside most IDEs via a plugin.
|
|
62
|
+
|
|
63
|
+
## Customization
|
|
64
|
+
You can customize all rules with `rules` property in the `eslint.config.mjs` file.
|
|
65
|
+
You can also add custom rules to the `rules` property.
|
|
66
|
+
|
|
67
|
+
### Customize extensions for ESLint import rules
|
|
68
|
+
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.
|
|
70
|
+
|
|
71
|
+
### Default values
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
// default file pattern for all rules (https://eslint.org/docs/latest/use/configure/configuration-files#configuration-objects)
|
|
75
|
+
export const files = ['**/*.{cjs,js,jsx,mjs}'];
|
|
76
|
+
|
|
77
|
+
// default plugins used in this config
|
|
78
|
+
export const plugins = {
|
|
79
|
+
'@stylistic': stylisticPlugin,
|
|
80
|
+
'import': importPlugin,
|
|
81
|
+
n: nodePlugin,
|
|
82
|
+
perfectionist,
|
|
83
|
+
'jsx-a11y': jsxA11yPlugin,
|
|
84
|
+
react: reactPlugin,
|
|
85
|
+
'react-hooks': reactHooks,
|
|
86
|
+
'react-refresh': reactRefresh,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// default value for import/extension module settings (https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#importextensions)
|
|
90
|
+
export const defaultImportExtensions = ['.js', '.jsx', '.mjs'];
|
|
91
|
+
|
|
92
|
+
// default value for import/resolver settings with node resolution (https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#resolvers)
|
|
93
|
+
export const defaultImportResolverNodeExtensions = ['.js', '.jsx', '.json', '.mjs'];
|
|
94
|
+
|
|
95
|
+
// default value for import/extensions rule granular option (https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md#rule-details)
|
|
96
|
+
export const defaultImportExtensionsRuleGranularOption = {
|
|
97
|
+
js: 'never',
|
|
98
|
+
jsx: 'never',
|
|
99
|
+
json: 'always',
|
|
100
|
+
svg: 'always',
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// default value for import/no-extraneous-dependencies rule devDependencies option (https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md#rule-details)
|
|
104
|
+
export const defaultImportNoExtraneousDependenciesDevDependencies = [
|
|
105
|
+
'test/**', // tape, common npm pattern
|
|
106
|
+
'tests/**', // also common npm pattern
|
|
107
|
+
'spec/**', // mocha, rspec-like pattern
|
|
108
|
+
'**/__tests__/**', // jest pattern
|
|
109
|
+
'**/__mocks__/**', // jest pattern
|
|
110
|
+
'test.{js,jsx}', // repos with a single test file
|
|
111
|
+
'test-*.{js,jsx}', // repos with multiple top-level test files
|
|
112
|
+
'**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test
|
|
113
|
+
'**/jest.config.js', // jest config
|
|
114
|
+
'**/jest.setup.js', // jest setup
|
|
115
|
+
'**/vue.config.js', // vue-cli config
|
|
116
|
+
'**/webpack.config.js', // webpack config
|
|
117
|
+
'**/webpack.config.*.js', // webpack config
|
|
118
|
+
'**/webpack.config.mjs', // webpack config
|
|
119
|
+
'**/webpack.config.*.mjs', // webpack config
|
|
120
|
+
'**/rollup.config.js', // rollup config
|
|
121
|
+
'**/rollup.config.*.js', // rollup config
|
|
122
|
+
'**/gulpfile.js', // gulp config
|
|
123
|
+
'**/gulpfile.*.js', // gulp config
|
|
124
|
+
'**/Gruntfile{,.js}', // grunt config
|
|
125
|
+
'**/protractor.conf.js', // protractor config
|
|
126
|
+
'**/protractor.conf.*.js', // protractor config
|
|
127
|
+
'**/karma.conf.js', // karma config
|
|
128
|
+
'**/eslint.config.mjs', // eslint config
|
|
129
|
+
'./rules/*.mjs', // eslint config
|
|
130
|
+
'**/vitest.config.mjs', // vitest config
|
|
131
|
+
'**/vitestSetup.mjs', // vitest setup
|
|
132
|
+
'**/tailwind.config.mjs', // tailwind config
|
|
133
|
+
'**/vite.config.js', // vite config
|
|
134
|
+
'**/vite.config.mjs', // vite config
|
|
135
|
+
'**/vite.config.*.js', // vite config
|
|
136
|
+
'**/vite.config*.mjs', // vite config
|
|
137
|
+
];
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
All default values are optional and can be overridden in the `eslint.config.mjs` file.
|
|
141
|
+
|
|
142
|
+
### Example of ESLint config with custom extensions
|
|
143
|
+
```javascript
|
|
144
|
+
// eslint.config.mjs
|
|
145
|
+
import {
|
|
146
|
+
defaultImportExtensions,
|
|
147
|
+
defaultImportExtensionsRuleGranularOption,
|
|
148
|
+
defaultImportResolverNodeExtensions,
|
|
149
|
+
defaultImportNoExtraneousDependenciesDevDependencies,
|
|
150
|
+
files as defaultFiles,
|
|
151
|
+
getConfig,
|
|
152
|
+
plugins as defaultPlugins,
|
|
153
|
+
} from 'eslint-config-vylda-vanilla';
|
|
154
|
+
import myPlugin from 'path-to-my-plugin';
|
|
155
|
+
|
|
156
|
+
const importExtensions = [
|
|
157
|
+
...defaultImportExtensions,
|
|
158
|
+
'.jsm',
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
const importExtensionsRuleGranularOption = {
|
|
162
|
+
...defaultImportExtensionsRuleGranularOption,
|
|
163
|
+
jsm: 'never',
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const importResolverNodeExtensions = [
|
|
167
|
+
...defaultImportResolverNodeExtensions,
|
|
168
|
+
'.jsm',
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
const importNoExtraneousDependenciesDevDependencies = [
|
|
172
|
+
...defaultImportNoExtraneousDependenciesDevDependencies,
|
|
173
|
+
'**/my-plugin.jsm',
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
const files = [
|
|
177
|
+
...defaultFiles,
|
|
178
|
+
'**/*.jsm',
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
const plugins = {
|
|
182
|
+
...defaultPlugins,
|
|
183
|
+
'my/plugin': myPlugin,
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const rjConfig = getConfig({
|
|
187
|
+
files,
|
|
188
|
+
importExtensions,
|
|
189
|
+
importExtensionsRuleGranularOption,
|
|
190
|
+
importResolverNodeExtensions,
|
|
191
|
+
importNoExtraneousDependenciesDevDependencies
|
|
192
|
+
plugins,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const config = [
|
|
196
|
+
...rjConfig,
|
|
197
|
+
{
|
|
198
|
+
files,
|
|
199
|
+
name: 'my/plugin',
|
|
200
|
+
rules: {
|
|
201
|
+
"my/plugin/rule": "error",
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
];
|
|
205
|
+
|
|
206
|
+
export default config;
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Partial ESLint config
|
|
210
|
+
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.
|
|
211
|
+
|
|
212
|
+
If you can use import plugin, you must use `getImportConfig` function to get the config for the import plugin and import `plugins` object.
|
|
213
|
+
This function uses the same default values as the package, except `files` and `plugins` in option object.
|
|
214
|
+
|
|
215
|
+
```javascript
|
|
216
|
+
// eslint.config.mjs
|
|
217
|
+
import {
|
|
218
|
+
barrels, barrelsFiles, bestPractices, es6,
|
|
219
|
+
getImportConfig, files, mapFiles, plugins,
|
|
220
|
+
} from 'eslint-config-vylda-vanilla';
|
|
221
|
+
|
|
222
|
+
const configs = [
|
|
223
|
+
bestPractices,
|
|
224
|
+
es6,
|
|
225
|
+
// you can add custom options object to the function getConfig
|
|
226
|
+
// optional parameters: importExtensions, importExtensionsRuleGranularOption, importResolverNodeExtensions,importNoExtraneousDependenciesDevDependencies
|
|
227
|
+
getImportConfig();
|
|
228
|
+
];
|
|
229
|
+
|
|
230
|
+
const configWithFiles = mapFiles(configs, files);
|
|
231
|
+
const barrelsWithFiles = mapFiles(barrels, barrelsFiles);
|
|
232
|
+
|
|
233
|
+
const config = [
|
|
234
|
+
{
|
|
235
|
+
plugins,
|
|
236
|
+
}
|
|
237
|
+
...configWithFiles,
|
|
238
|
+
...barrelsWithFiles,
|
|
239
|
+
]
|
|
240
|
+
|
|
241
|
+
export default config;
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## What you can import from this package
|
|
245
|
+
|
|
246
|
+
All rules are without `files` property, so you can use them as a partial ESLint config.
|
|
247
|
+
You can use `files` property to specify the files for the rule.
|
|
248
|
+
You can also use `mapFiles` function to map files for all rules.
|
|
249
|
+
|
|
250
|
+
- `default export` - default ESLint config ([source](./eslint.config.mjs#L38))
|
|
251
|
+
- `a11y` - ESLint config with rules for accessibility in React components ([source](./rules/a11y.mjs), [documentation](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme))
|
|
252
|
+
- `barrels` - ESLint config with rules for barrel files ([source](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/rules/barrels.mjs), [documentation](https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md))
|
|
253
|
+
- `barrelsFiles` - default file pattern for barrel files ([default values](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/eslint.config.mjs#L12), [documentation](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-objects))
|
|
254
|
+
- `bestPractices` - ESLint config with rules for best practices ([source](./rules/best-practices.mjs), [documentation (js)](https://eslint.org/docs/latest/rules), [documentation (stylistic)](https://eslint.style/packages/js#rules))
|
|
255
|
+
- `constants` - Constants for some ESLint rules ([source](./rules/constants.mjs))
|
|
256
|
+
- `customs` - ESLint config with my custom rules ([source](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/rules/customs.mjs))
|
|
257
|
+
- `defaultImportExtensions` - default value for import/extension module settings ([default values](./rules/imports.mjs#L7), [documentation](https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#importextensions))
|
|
258
|
+
- `defaultImportExtensionsRuleGranularOption` - default value for import/resolver settings with node resolution ([default values](./rules/imports.mjs#L8), [documentation](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md#rule-details))
|
|
259
|
+
- `defaultImportNoExtraneousDependenciesDevDependencies` - default value for import/extensions rule granular option ([default values](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/rules/imports.mjs?ref_type=heads#L8), [documentation](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md#rule-details))
|
|
260
|
+
- `defaultImportResolverNodeExtensions` - default value for import/no-extraneous-dependencies rule devDependencies option ([default values](./rules/imports.mjs#L13), [documentation](https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#resolvers))
|
|
261
|
+
- `errors` - ESLint config with rules for errors ([source](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/rules/errors.mjs), [documentation](https://eslint.org/docs/latest/rules))
|
|
262
|
+
- `es6` - ESLint config with rules for ES6 ([source](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/rules/es6.mjs), [documentation (js)](https://eslint.org/docs/latest/rules), [documentation (stylistic)](https://eslint.style/packages/js#rules))
|
|
263
|
+
- `files` - default file pattern for all rules ([default values](./eslint.config.mjs#L11), [documentation](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-objects))
|
|
264
|
+
- `getConfig` - function to get ESLint config with custom options ([source](./index.js#L59))
|
|
265
|
+
- `getImportConfig` - function to get ESLint config for import plugin ([source](./rules/imports.mjs#L25))
|
|
266
|
+
- `hooks` - ESLint config with rules for hooks ([source](./rules/hooks.mjs), [documentation](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks#readme))
|
|
267
|
+
- `ignores` - ESLint config with global ignored folder patterns ([default values](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/ignores.mjs#L4), [documentation](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files))
|
|
268
|
+
- `mapFiles` - helper function to map files for all configs ([source](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/mapFiles.mjs))
|
|
269
|
+
- `node` - ESLint config with rules for Node.js ([source](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/rules/node.mjs), [documentation](https://github.com/eslint-community/eslint-plugin-n/?tab=readme-ov-file#-rules))
|
|
270
|
+
- `perfectionist` - ESLint config with rules for perfectionist ([source](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/rules/perfectionist.mjs), [documentation](https://perfectionist.dev/rules))
|
|
271
|
+
- `plugins` - default plugins used in this config ([source](./eslint.config.mjs#L22))
|
|
272
|
+
- `plus` - ESLint config with rules for extended rules ([source](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/rules/plus.mjs), [documentation](https://eslint.style/packages/plus))
|
|
273
|
+
- `react` - ESLint config with rules for React ([source](./rules/react.mjs), [documentation](https://github.com/jsx-eslint/eslint-plugin-react#readme))
|
|
274
|
+
- `reactConfigs` - ESlint config with rules for React only ([source](./index.js#L51))
|
|
275
|
+
- `reactPlugins` - ESLint plugins used for React only ([source](./eslint.config.mjs#L15))
|
|
276
|
+
- `reactStylistic` - ESLint config with stylistic rules for React ([source](./rules/stylistic.mjs), [documentation](https://eslint.style/packages/jsx))
|
|
277
|
+
- `refresh` - ESLint config with rules for React refresh ([source](./rules/refresh.mjs), [documentation](https://github.com/ArnaudBarre/eslint-plugin-react-refresh#readme))
|
|
278
|
+
- `refreshFiles` - default file patterns for React refresh config ([source](./eslint.config.mjs#L11))
|
|
279
|
+
- `strict` - ESLint config with rules for strict mode ([source](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/rules/strict.mjs), [documentation](https://eslint.org/docs/latest/rules))
|
|
280
|
+
- `stylistic` - ESLint config with React stylistic rules ([source](./rules/stylistic.mjs), [documentation](https://eslint.style/packages/jsx))
|
|
281
|
+
- `vanillaConfigs` - Eslint configuration for vanilla javascript only (without import rules) ([source](./index.js#L32))
|
|
282
|
+
- `variables` - ESLint config with rules for variables ([source](https://gitlab.com/Vylda/eslint-config-vylda-vanilla/-/blob/main/rules/variables.mjs), [documentation](https://eslint.org/docs/latest/rules))
|
|
283
|
+
|
|
284
|
+
## Additional Documentation
|
|
285
|
+
|
|
286
|
+
- [Changelog.md](Changelog.md)
|
|
287
|
+
|
|
288
|
+
## Credits
|
|
289
|
+
|
|
290
|
+
Authored and maintained by Vilda Lipold ([dovolena.cz](https://dovolena.cz))
|
|
291
|
+
|
|
292
|
+
## License
|
|
293
|
+
|
|
294
|
+
Open source [licensed as MIT](LICENSE).
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
barrels, barrelsFiles, ignores, mapFiles, plugins as vanillaPlugins,
|
|
3
|
+
} from 'eslint-config-vylda-vanilla';
|
|
4
|
+
import jsxA11y from 'eslint-plugin-jsx-a11y';
|
|
5
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
6
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
7
|
+
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
8
|
+
import configs, {
|
|
9
|
+
a11y, hooks, react, reactStylistic, refresh,
|
|
10
|
+
} from './rules/index.mjs';
|
|
11
|
+
|
|
12
|
+
export const files = ['**/*.{cjs,js,jsx,mjs}'];
|
|
13
|
+
export const refreshFiles = ['**/*.jsx'];
|
|
14
|
+
|
|
15
|
+
const jsxA11yPlugin = jsxA11y.flatConfigs.strict.plugins['jsx-a11y'];
|
|
16
|
+
|
|
17
|
+
delete reactPlugin.configs;
|
|
18
|
+
delete reactHooks.configs;
|
|
19
|
+
|
|
20
|
+
export const reactPlugins = {
|
|
21
|
+
'jsx-a11y': jsxA11yPlugin,
|
|
22
|
+
react: reactPlugin,
|
|
23
|
+
'react-hooks': reactHooks,
|
|
24
|
+
'react-refresh': reactRefresh,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const plugins = {
|
|
28
|
+
...vanillaPlugins,
|
|
29
|
+
...reactPlugins,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const configsWithFiles = mapFiles(configs, files);
|
|
33
|
+
|
|
34
|
+
const reactConfigs = [
|
|
35
|
+
...a11y,
|
|
36
|
+
...hooks,
|
|
37
|
+
...react,
|
|
38
|
+
...reactStylistic,
|
|
39
|
+
...refresh,
|
|
40
|
+
];
|
|
41
|
+
const reactConfigWithFiles = mapFiles(reactConfigs, refreshFiles);
|
|
42
|
+
const barrelsConfigWithFiles = mapFiles(barrels, barrelsFiles);
|
|
43
|
+
|
|
44
|
+
const config = [
|
|
45
|
+
{
|
|
46
|
+
name: 'vanilla-react/base',
|
|
47
|
+
plugins,
|
|
48
|
+
},
|
|
49
|
+
...configsWithFiles,
|
|
50
|
+
...reactConfigWithFiles,
|
|
51
|
+
...barrelsConfigWithFiles,
|
|
52
|
+
...ignores,
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
export default config;
|