@scayle/eslint-config-storefront 3.2.7 → 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/CHANGELOG.md +35 -0
- package/README.md +101 -191
- package/config/flat/index.mjs +81 -0
- package/config/flat/promise.mjs +20 -0
- package/config/flat/sanitized.mjs +14 -0
- package/config/flat/sonarjs.mjs +26 -0
- package/index.mjs +3 -0
- package/package.json +20 -33
- package/config/eslint-config-json.cjs +0 -112
- package/config/eslint-config-vue-base.cjs +0 -56
- package/config/eslint-config-yml.cjs +0 -29
- package/index.js +0 -240
- package/nuxt/nuxt.cjs +0 -27
- package/nuxt/nuxt2.cjs +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @aboutyou/eslint-config-sfc
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- We migrated to `eslint@9` and [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files), to provide improved organization and composition.
|
|
8
|
+
Additionally we simplified the configuration setup by adapting some configurations provided by [@antfu/eslint-config](https://github.com/antfu/eslint-config).
|
|
9
|
+
|
|
10
|
+
Following example can be checked to see how to use this configuration package in your projects `eslint.config.mjs` configuration file:
|
|
11
|
+
|
|
12
|
+
For "pure" TypeScript / Node projects:
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
// eslint.config.mjs
|
|
16
|
+
import eslintConfigStorefront from "@scayle/eslint-config-storefront";
|
|
17
|
+
|
|
18
|
+
export default eslintConfigStorefront();
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For Nuxt projects using `@nuxt/eslint` module:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import withNuxt from "./.nuxt/eslint.config.mjs";
|
|
25
|
+
import eslintConfigStorefront from "@scayle/eslint-config-storefront";
|
|
26
|
+
|
|
27
|
+
export default withNuxt(eslintConfigStorefront());
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The `@scayle/eslint-config-storefront` package exports a factory function `eslintConfigStorefront()`. The factory function is able to automatically detect if a project is using the `@nuxt/eslint` package and automatically disables certain duplicate rules that are provided by `@nuxt/eslint`. This can also manually be adjusted by passing `{ isNuxt: true }` as parameter to `eslintConfigStorefront()`.
|
|
31
|
+
|
|
32
|
+
More details about the `@nuxt/eslint` module can be found within the [official module documentation](https://eslint.nuxt.com/packages/module).
|
|
33
|
+
|
|
34
|
+
Should you want to upgrade from `eslint@8` to `eslint@9`, you can check the official [Eslint Migration Guide](https://eslint.org/docs/latest/use/configure/migration-guide).
|
|
35
|
+
|
|
36
|
+
Should you require support for `eslint@8`, please use `@scayle/eslint-config-storefront@3`.
|
|
37
|
+
|
|
3
38
|
## 3.2.7
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,233 +1,143 @@
|
|
|
1
|
-
# eslint-config-storefront
|
|
1
|
+
# @scayle/eslint-config-storefront
|
|
2
2
|
|
|
3
|
-
A [shared `eslint` config](https://eslint.org/docs/latest/extend/shareable-configs#creating-a-shareable-config) for SCAYLE Storefront
|
|
3
|
+
A [shared `eslint` config](https://eslint.org/docs/latest/extend/shareable-configs#creating-a-shareable-config) for SCAYLE Storefront projects and packages.
|
|
4
|
+
Provides SCAYLE-specific `eslint` configuration for Frontend and Node.js projects using TypeScript.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## ESLint
|
|
6
|
+
We migrated to `eslint@9` and [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files), to provide improved organization and composition.
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
Should you require support for `eslint@8`, please use `@scayle/eslint-config-storefront@3`.
|
|
10
9
|
|
|
10
|
+
- Partially based on [@antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
11
11
|
- [Official ESLint Documentation](https://eslint.org/docs/latest/)
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
#### Default config / `@scayle/eslint-config-storefront`
|
|
16
|
-
|
|
17
|
-
Provides Scayle-specific `eslint` configuration for Frontend and Node.js projects using TypeScript.
|
|
18
|
-
|
|
19
|
-
#### Nuxt 2 config / `@scayle/eslint-config-storefront/nuxt/nuxt2`
|
|
20
|
-
|
|
21
|
-
Provides a Vue2- and Nuxt2-specific partial configuration for `eslint`.
|
|
22
|
-
Based on `plugin:vue/recommended` and should be used with [`@scayle/eslint-config-storefront`](#default-config)
|
|
23
|
-
|
|
24
|
-
#### Nuxt 3 config / `@scayle/eslint-config-storefront/nuxt/nuxt`
|
|
25
|
-
|
|
26
|
-
Provides a Vue3- and Nuxt2-specific partial configuration for `eslint`.
|
|
27
|
-
Based on `plugin:vue/vue-3recommended` and should be used with [`@scayle/eslint-config-storefront`](#default-config)
|
|
28
|
-
|
|
29
|
-
### Used plugins and configurations
|
|
30
|
-
|
|
31
|
-
#### `@rushstack/eslint-patch`
|
|
32
|
-
|
|
33
|
-
> A patch that improves how ESLint loads plugins when working in a monorepo with a reusable toolchain
|
|
34
|
-
|
|
35
|
-
**Why?**
|
|
36
|
-
This patch allows a shared config to include its own `eslint` plugins instead of having them required as peer dependencies for every package that uses this config, which by itself is not yet supported by `eslint`.
|
|
37
|
-
|
|
38
|
-
- License: [**MIT**](https://github.com/microsoft/rushstack/blob/main/eslint/eslint-patch/LICENSE)
|
|
39
|
-
- [README](https://github.com/microsoft/rushstack/blob/main/eslint/eslint-patch/README.md)
|
|
40
|
-
- [Repository](https://github.com/microsoft/rushstack/tree/main/eslint/eslint-patch)
|
|
41
|
-
|
|
42
|
-
#### `@typescript-eslint/eslint-plugin` & `@typescript-eslint/parser`
|
|
43
|
-
|
|
44
|
-
> The tooling that enables ESLint and Prettier to support TypeScript.
|
|
45
|
-
|
|
46
|
-
**Why?**
|
|
47
|
-
Enables support for parsing and linting TypeScript files.
|
|
48
|
-
|
|
49
|
-
- License: [**Use and redistribution without modification**](https://github.com/typescript-eslint/typescript-eslint/blob/main/LICENSE)
|
|
50
|
-
- [Documentation](https://typescript-eslint.io/)
|
|
51
|
-
- [Repository](https://github.com/typescript-eslint/typescript-eslint)
|
|
52
|
-
|
|
53
|
-
#### `eslint-config-prettier`
|
|
54
|
-
|
|
55
|
-
> Turns off all rules that are unnecessary or might conflict with Prettier.
|
|
56
|
-
|
|
57
|
-
**Why?**
|
|
58
|
-
Disables all relevant `eslint` rules that are covered by `prettier`, thus avoiding conflicts between tools.
|
|
59
|
-
|
|
60
|
-
- [**MIT**](https://github.com/prettier/eslint-config-prettier/blob/main/LICENSE)
|
|
61
|
-
- [Readme](https://github.com/prettier/eslint-config-prettier/blob/main/README.md)
|
|
62
|
-
- [Repository](https://github.com/prettier/eslint-config-prettier)
|
|
63
|
-
|
|
64
|
-
#### `eslint-config-standard`
|
|
65
|
-
|
|
66
|
-
> An ESLint Shareable Config for JavaScript Standard Style
|
|
67
|
-
|
|
68
|
-
**Why?**
|
|
69
|
-
Provides JavaScript Standard code style compliant ruleset.
|
|
70
|
-
|
|
71
|
-
- License: [**MIT**](https://github.com/standard/eslint-config-standard/blob/master/LICENSE)
|
|
72
|
-
- [JavaScript Standard Style Documentation](https://standardjs.com/)
|
|
73
|
-
- [Repository](https://github.com/standard/eslint-config-standard)
|
|
74
|
-
|
|
75
|
-
#### `eslint-plugin-eslint-comments`
|
|
76
|
-
|
|
77
|
-
> Additional ESLint rules for ESLint directive comments (e.g.`//eslint-disable-line`).
|
|
78
|
-
|
|
79
|
-
**Why?**
|
|
80
|
-
Provides linting rule targeted at disabling `eslint` code comments, thus allowing fain-grained control what is allowed to be disabled and what needs to be addressed instead.
|
|
81
|
-
|
|
82
|
-
- License: [**MIT**](https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/LICENSE)
|
|
83
|
-
- [Documentation](https://mysticatea.github.io/eslint-plugin-eslint-comments/)
|
|
84
|
-
- [Repository](https://github.com/mysticatea/eslint-plugin-eslint-comments)
|
|
85
|
-
|
|
86
|
-
#### `eslint-plugin-html`
|
|
87
|
-
|
|
88
|
-
> A ESLint plugin to lint and fix inline scripts contained in HTML files.
|
|
89
|
-
|
|
90
|
-
**Why?**
|
|
91
|
-
Allows to lint code within `<script>` tags in HTML markup.
|
|
92
|
-
|
|
93
|
-
- License: [**Use and redistribution without modification**](https://github.com/BenoitZugmeyer/eslint-plugin-html/blob/main/LICENSE)
|
|
94
|
-
- [README](https://github.com/BenoitZugmeyer/eslint-plugin-html/blob/main/README.md)
|
|
95
|
-
- [Repository](https://github.com/BenoitZugmeyer/eslint-plugin-html)
|
|
96
|
-
|
|
97
|
-
#### `eslint-plugin-import`
|
|
98
|
-
|
|
99
|
-
> This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names.
|
|
100
|
-
|
|
101
|
-
**Why?**
|
|
102
|
-
Extends the linting ruleset to support ES6+ import/export syntax, thus reducing amount of false-positives in default `eslint` setup.
|
|
103
|
-
|
|
104
|
-
- License: [**MIT**](https://github.com/import-js/eslint-plugin-import/blob/main/LICENSE)
|
|
105
|
-
- [README](https://github.com/import-js/eslint-plugin-import/blob/main/README.md)
|
|
106
|
-
- [Repository](https://github.com/import-js/eslint-plugin-import)
|
|
107
|
-
|
|
108
|
-
#### `eslint-plugin-jsonc` & `jsonc-eslint-parser`
|
|
109
|
-
|
|
110
|
-
> This ESLint plugin provides linting rules relate to better ways to help you avoid problems when using JSON, JSONC and JSON5.
|
|
111
|
-
|
|
112
|
-
**Why?**
|
|
113
|
-
Enables support for parsing and extends linting of JSON-based files.
|
|
114
|
-
|
|
115
|
-
- License: [**MIT**](https://github.com/ota-meshi/eslint-plugin-jsonc/blob/master/LICENSE)
|
|
116
|
-
- [eslint-plugin-jsonc Documentation](https://ota-meshi.github.io/eslint-plugin-jsonc/)
|
|
117
|
-
- [eslint-plugin-jsonc Repository](https://github.com/ota-meshi/eslint-plugin-jsonc)
|
|
118
|
-
- [jsonc-eslint-parser Repository](https://github.com/ota-meshi/jsonc-eslint-parser)
|
|
119
|
-
|
|
120
|
-
#### `eslint-plugin-markdown`
|
|
121
|
-
|
|
122
|
-
> Lint JS, JSX, TypeScript, and more inside Markdown.
|
|
123
|
-
|
|
124
|
-
**Why?**
|
|
125
|
-
Allows to lint code blocks within Markdown files.
|
|
126
|
-
|
|
127
|
-
- License: [**MIT**](https://github.com/eslint/eslint-plugin-markdown/blob/main/LICENSE)
|
|
128
|
-
- [README](https://github.com/eslint/eslint-plugin-markdown/blob/main/README.md)
|
|
129
|
-
- [Repository](https://github.com/eslint/eslint-plugin-markdown)
|
|
130
|
-
|
|
131
|
-
#### `eslint-plugin-n`
|
|
132
|
-
|
|
133
|
-
> Additional ESLint's rules for Node.js
|
|
13
|
+
---
|
|
134
14
|
|
|
135
|
-
|
|
136
|
-
Provides support for Node.js specifics code and compatibility checks.
|
|
15
|
+
## Install
|
|
137
16
|
|
|
138
|
-
|
|
139
|
-
- [README](https://github.com/eslint-community/eslint-plugin-n/blob/master/README.md)
|
|
140
|
-
- [Repository](https://github.com/eslint-community/eslint-plugin-n)
|
|
17
|
+
Add the `@scayle/eslint-config-storefront` manually to your project:
|
|
141
18
|
|
|
142
|
-
|
|
19
|
+
`pnpm i -D eslint @scayle/eslint-config-storefront`
|
|
143
20
|
|
|
144
|
-
|
|
21
|
+
`yarn add -D eslint @scayle/eslint-config-storefront`
|
|
145
22
|
|
|
146
|
-
|
|
147
|
-
Will disallow assignments (e.g., to `innerHTML`) as well as calls (e.g., to `insertAdjacentHTML`) without the use of a pre-defined escaping function.
|
|
23
|
+
And create a `eslint.config.mjs` in your project root:
|
|
148
24
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
25
|
+
```js
|
|
26
|
+
// eslint.config.mjs
|
|
27
|
+
import eslintConfigStorefront from '@scayle/eslint-config-storefront'
|
|
152
28
|
|
|
153
|
-
|
|
29
|
+
export default eslintConfigStorefront()
|
|
30
|
+
```
|
|
154
31
|
|
|
155
|
-
|
|
32
|
+
### Add script for package.json
|
|
156
33
|
|
|
157
|
-
|
|
158
|
-
Provides Nuxt.js-specific linting ruleset and configuration.
|
|
34
|
+
For example:
|
|
159
35
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"scripts": {
|
|
39
|
+
"lint": "eslint .",
|
|
40
|
+
"lint:fix": "eslint . --fix"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
163
44
|
|
|
164
|
-
|
|
45
|
+
## VS Code support (auto fix on save)
|
|
165
46
|
|
|
166
|
-
|
|
47
|
+
Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
167
48
|
|
|
168
|
-
|
|
169
|
-
Provides ruleset to enforce best practices for JavaScript promises.
|
|
49
|
+
Add the following settings to your `.vscode/settings.json`:
|
|
170
50
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
51
|
+
```jsonc
|
|
52
|
+
{
|
|
53
|
+
// Enable the ESlint flat config support
|
|
54
|
+
"eslint.experimental.useFlatConfig": true,
|
|
174
55
|
|
|
175
|
-
|
|
56
|
+
// Auto fix
|
|
57
|
+
"editor.codeActionsOnSave": {
|
|
58
|
+
"source.fixAll.eslint": "explicit",
|
|
59
|
+
"source.organizeImports": "never"
|
|
60
|
+
},
|
|
176
61
|
|
|
177
|
-
|
|
62
|
+
// Enable eslint for all supported languages
|
|
63
|
+
"eslint.validate": [
|
|
64
|
+
"javascript",
|
|
65
|
+
"javascriptreact",
|
|
66
|
+
"typescript",
|
|
67
|
+
"typescriptreact",
|
|
68
|
+
"vue",
|
|
69
|
+
"html",
|
|
70
|
+
"markdown",
|
|
71
|
+
"json",
|
|
72
|
+
"jsonc",
|
|
73
|
+
"yaml"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
```
|
|
178
77
|
|
|
179
|
-
|
|
78
|
+
## Customization
|
|
180
79
|
|
|
181
|
-
|
|
182
|
-
Provides ruleset to detect possibler code smells and common sources for bugs.
|
|
80
|
+
### Provides shared configurations
|
|
183
81
|
|
|
184
|
-
|
|
185
|
-
- [README](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/README.md)
|
|
186
|
-
- [Repository](https://github.com/SonarSource/eslint-plugin-sonarjs)
|
|
82
|
+
#### Default config / `@scayle/eslint-config-storefront`
|
|
187
83
|
|
|
188
|
-
|
|
84
|
+
Normally you only need to import the antfu preset:
|
|
189
85
|
|
|
190
|
-
|
|
86
|
+
```js
|
|
87
|
+
// eslint.config.mjs
|
|
88
|
+
import eslintConfigStorefront from '@scayle/eslint-config-storefront'
|
|
191
89
|
|
|
192
|
-
|
|
90
|
+
export default eslintConfigStorefront()
|
|
91
|
+
```
|
|
193
92
|
|
|
194
|
-
|
|
195
|
-
...
|
|
93
|
+
### Extended Configuration
|
|
196
94
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
95
|
+
```js
|
|
96
|
+
// eslint.config.mjs
|
|
97
|
+
import eslintConfigStorefront from '@scayle/eslint-config-storefront'
|
|
200
98
|
|
|
201
|
-
|
|
99
|
+
export default eslintConfigStorefront({
|
|
100
|
+
// If set to `true` removes all rule configurations
|
|
101
|
+
// that are provided by the `@nuxt/eslint` package
|
|
102
|
+
isNuxt: true, // Default via auto-detection of package `@nuxt/eslint`
|
|
202
103
|
|
|
203
|
-
|
|
104
|
+
// If set to `true` adds `eslint-plugin-tailwind`
|
|
105
|
+
isTailwind: true, // Default via auto-detection of package `eslint-plugin-tailwind`
|
|
204
106
|
|
|
205
|
-
|
|
206
|
-
|
|
107
|
+
typescript: {
|
|
108
|
+
// Enables type-aware rules
|
|
109
|
+
// Only works if `isNuxt` is `false`!
|
|
110
|
+
// <https://github.com/antfu/eslint-config?tab=readme-ov-file#type-aware-rules>
|
|
111
|
+
tsconfigPath: 'path/to/tsconfig.ts',
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
```
|
|
207
115
|
|
|
208
|
-
|
|
209
|
-
- [README](https://github.com/sweepline/eslint-plugin-unused-imports/blob/master/README.md)
|
|
210
|
-
- [Repository](https://github.com/sweepline/eslint-plugin-unused-imports)
|
|
116
|
+
### Plugins Renaming
|
|
211
117
|
|
|
212
|
-
|
|
118
|
+
Since flat config requires us to explicitly provide the plugin names (instead of the mandatory convention from npm package name), we renamed some plugins to make the overall scope more consistent and easier to write.
|
|
213
119
|
|
|
214
|
-
|
|
120
|
+
| New Prefix | Original Prefix | Source Plugin |
|
|
121
|
+
| ---------- | ---------------------- | ------------------------------------------------------------------------------------------ |
|
|
122
|
+
| `import/*` | `import-x/*` | [eslint-plugin-import-x](https://github.com/un-es/eslint-plugin-import-x) |
|
|
123
|
+
| `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
|
|
124
|
+
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
|
|
125
|
+
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
|
|
126
|
+
| `test/*` | `vitest/*` | [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) |
|
|
127
|
+
| `test/*` | `no-only-tests/*` | [eslint-plugin-no-only-tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests) |
|
|
215
128
|
|
|
216
|
-
|
|
217
|
-
Provides Vue-specific linting ruleset and configuration. Supports both Vue2 and Vue3.
|
|
129
|
+
When you want to override rules, or disable them inline, you need to update to the new prefix:
|
|
218
130
|
|
|
219
|
-
|
|
220
|
-
-
|
|
221
|
-
-
|
|
131
|
+
```diff
|
|
132
|
+
-// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
133
|
+
+// eslint-disable-next-line ts/consistent-type-definitions
|
|
134
|
+
type foo = { bar: 2 }
|
|
135
|
+
```
|
|
222
136
|
|
|
223
|
-
|
|
137
|
+
## View what rules are enabled
|
|
224
138
|
|
|
225
|
-
|
|
139
|
+
[Anthony Fu](https://github.com/antfu) built a visual tool to help you view what rules are enabled in your project and apply them to what files, [@eslint/config-inspector](https://github.com/eslint/config-inspector).
|
|
226
140
|
|
|
227
|
-
|
|
228
|
-
Enables support for parsing and extends linting of YAML-based files.
|
|
141
|
+
Go into your project root that contains eslint.config.js and run:
|
|
229
142
|
|
|
230
|
-
|
|
231
|
-
- [eslint-plugin-yml Documentation](https://ota-meshi.github.io/eslint-plugin-yml/)
|
|
232
|
-
- [eslint-plugin-yml Repository](https://github.com/ota-meshi/eslint-plugin-yml)
|
|
233
|
-
- [yaml-eslint-parser Repository](https://github.com/ota-meshi/yaml-eslint-parser)
|
|
143
|
+
`npx @eslint/config-inspector`
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { FlatConfigComposer } from 'eslint-flat-config-utils'
|
|
2
|
+
import { isPackageExists } from 'local-pkg'
|
|
3
|
+
import {
|
|
4
|
+
combine,
|
|
5
|
+
comments,
|
|
6
|
+
ignores,
|
|
7
|
+
imports,
|
|
8
|
+
javascript,
|
|
9
|
+
jsdoc,
|
|
10
|
+
jsonc,
|
|
11
|
+
node,
|
|
12
|
+
test,
|
|
13
|
+
typescript,
|
|
14
|
+
yaml,
|
|
15
|
+
} from '@antfu/eslint-config'
|
|
16
|
+
import gitignore from 'eslint-config-flat-gitignore'
|
|
17
|
+
import { sonarjs } from './sonarjs.mjs'
|
|
18
|
+
import { promise } from './promise.mjs'
|
|
19
|
+
import { sanitized } from './sanitized.mjs'
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* NOTES - REMOVE BEFORE MERGE!
|
|
23
|
+
* - https://www.npmjs.com/package/eslint-plugin-regexp
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// Partial eslint config by `@antfu/eslint-config`
|
|
27
|
+
// <https://github.com/antfu/eslint-config/blob/main/README.md>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {object=} config
|
|
31
|
+
* @param {boolean=} config.isNuxt
|
|
32
|
+
* @param {object=} config.typescript
|
|
33
|
+
* @param {string=} config.typescript.tsconfigPath
|
|
34
|
+
* @param {object=} config.custom
|
|
35
|
+
* @returns {FlatConfigComposer<Linter.FlatConfig<Linter.RulesRecord>, never>} Returns a FlatConfigComposer object to be consumed in projects eslint.config.mjs files
|
|
36
|
+
*/
|
|
37
|
+
export const eslintConfigStorefront = function(config = {
|
|
38
|
+
isNuxt: isPackageExists('@nuxt/eslint'),
|
|
39
|
+
typescript: { tsconfigPath: undefined },
|
|
40
|
+
}) {
|
|
41
|
+
const flatConfigComposer = new FlatConfigComposer()
|
|
42
|
+
|
|
43
|
+
// The following rules are already handled by `@nuxt/eslint` and
|
|
44
|
+
// don't need to be extended from `@antfu/eslint-config` if it is used
|
|
45
|
+
const nonNuxtRules = !config.isNuxt
|
|
46
|
+
? combine(
|
|
47
|
+
gitignore(),
|
|
48
|
+
ignores(),
|
|
49
|
+
imports(),
|
|
50
|
+
javascript(),
|
|
51
|
+
typescript(config.typescript),
|
|
52
|
+
jsdoc(),
|
|
53
|
+
)
|
|
54
|
+
: {}
|
|
55
|
+
|
|
56
|
+
const configs = [
|
|
57
|
+
combine(
|
|
58
|
+
comments(), // https://github.com/antfu/eslint-config/blob/main/src/configs/comments.ts
|
|
59
|
+
node(), // https://github.com/antfu/eslint-config/blob/main/src/configs/node.ts
|
|
60
|
+
jsonc(), // https://github.com/antfu/eslint-config/blob/main/src/configs/jsonc.ts
|
|
61
|
+
yaml(), // https://github.com/antfu/eslint-config/blob/main/src/configs/yaml.ts
|
|
62
|
+
test(), // https://github.com/antfu/eslint-config/blob/main/src/configs/test.ts
|
|
63
|
+
sonarjs(),
|
|
64
|
+
promise(),
|
|
65
|
+
sanitized(),
|
|
66
|
+
),
|
|
67
|
+
nonNuxtRules,
|
|
68
|
+
{
|
|
69
|
+
// Disable default rules by imported @antfu/eslint-config
|
|
70
|
+
rules: {
|
|
71
|
+
'node/prefer-global/process': 'off',
|
|
72
|
+
'yaml/plain-scalar': 'warn',
|
|
73
|
+
},
|
|
74
|
+
ignores: ['**/fixtures/**/*'],
|
|
75
|
+
},
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
return flatConfigComposer.append(
|
|
79
|
+
...configs,
|
|
80
|
+
)
|
|
81
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import pluginPromise from 'eslint-plugin-promise'
|
|
2
|
+
|
|
3
|
+
export function promise() {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
name: 'storefront/promise/rules',
|
|
7
|
+
// eslint-plugin-promise
|
|
8
|
+
// Support for FlatConfig: <https://github.com/eslint-community/eslint-plugin-promise/issues/449>
|
|
9
|
+
// Disabling currently incompatible rules per recommendation:
|
|
10
|
+
// <https://github.com/eslint-community/eslint-plugin-promise/issues/449#issuecomment-2051655694>
|
|
11
|
+
plugins: { promise: pluginPromise },
|
|
12
|
+
rules: {
|
|
13
|
+
'promise/no-return-wrap': 'off',
|
|
14
|
+
'promise/no-promise-in-callback': 'off',
|
|
15
|
+
'promise/no-nesting': 'off',
|
|
16
|
+
'promise/no-callback-in-promise': 'off',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import pluginNoUnsanitized from 'eslint-plugin-no-unsanitized'
|
|
2
|
+
|
|
3
|
+
export function sanitized() {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
name: 'storefront/sanitized/rules',
|
|
7
|
+
// Legacy: eslint-plugin-no-unsanitized
|
|
8
|
+
plugins: {
|
|
9
|
+
sanitized: pluginNoUnsanitized,
|
|
10
|
+
},
|
|
11
|
+
rules: {},
|
|
12
|
+
},
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pluginSonarjs from 'eslint-plugin-sonarjs'
|
|
2
|
+
|
|
3
|
+
export function sonarjs() {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
name: 'storefront/sonarjs/rules',
|
|
7
|
+
// Legacy: eslint-plugin-sonarjs
|
|
8
|
+
// Support for FlatConfig: <https://github.com/SonarSource/SonarJS/issues/3968>
|
|
9
|
+
// Disabling currently incompatible rules per recommendation:
|
|
10
|
+
// <https://github.com/SonarSource/eslint-plugin-sonarjs/issues/454#issuecomment-2051659694>
|
|
11
|
+
plugins: {
|
|
12
|
+
sonarjs: pluginSonarjs,
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
'sonarjs/no-gratuitous-expressions': 'off',
|
|
16
|
+
'sonarjs/no-empty-collection': 'off',
|
|
17
|
+
'sonarjs/no-unused-collection': 'off',
|
|
18
|
+
'security/detect-child-process': 'off',
|
|
19
|
+
'sonarjs/no-use-of-empty-return-value': 'off',
|
|
20
|
+
'sonarjs/no-extra-arguments': 'off',
|
|
21
|
+
'sonarjs/no-redundant-jump': 'off',
|
|
22
|
+
'sonarjs/no-one-iteration-loop': 'off',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
]
|
|
26
|
+
}
|
package/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/eslint-config-storefront",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "SCAYLE Commerce Engine specific eslint configuration",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
"access": "public",
|
|
9
9
|
"registry": "https://registry.npmjs.org/"
|
|
10
10
|
},
|
|
11
|
+
"type": "module",
|
|
11
12
|
"exports": {
|
|
12
|
-
".": "./index.
|
|
13
|
-
"./
|
|
14
|
-
"./
|
|
15
|
-
"./config/
|
|
16
|
-
"./config/
|
|
17
|
-
"./config/eslint-config-vue-base.cjs": "./config/eslint-config-vue-base.cjs"
|
|
13
|
+
".": "./index.mjs",
|
|
14
|
+
"./config/flat/index.mjs": "./config/flat/index.mjs",
|
|
15
|
+
"./config/flat/sonarjs": "./config/flat/sonarjs.mjs",
|
|
16
|
+
"./config/flat/promise.mjs": "./config/flat/promise.mjs",
|
|
17
|
+
"./config/flat/sanitized.mjs": "./config/flat/sanitized.mjs"
|
|
18
18
|
},
|
|
19
|
-
"main": "./index.
|
|
19
|
+
"main": "./index.mjs",
|
|
20
20
|
"files": [
|
|
21
21
|
"CHANGELOG.md",
|
|
22
|
-
"
|
|
23
|
-
"./
|
|
24
|
-
"./
|
|
22
|
+
"README.md",
|
|
23
|
+
"./index.mjs",
|
|
24
|
+
"./config/"
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
27
|
"format": "dprint check",
|
|
@@ -31,35 +31,22 @@
|
|
|
31
31
|
"package:lint": "publint"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"eslint": "^
|
|
35
|
-
"typescript": "^5.
|
|
34
|
+
"eslint": "^9.0.0",
|
|
35
|
+
"typescript": "^5.4.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"eslint-config-
|
|
42
|
-
"eslint-config-
|
|
43
|
-
"eslint-plugin-eslint-comments": "3.2.0",
|
|
44
|
-
"eslint-plugin-html": "8.0.0",
|
|
45
|
-
"eslint-plugin-import": "2.29.1",
|
|
46
|
-
"eslint-plugin-n": "17.1.0",
|
|
38
|
+
"local-pkg": "0.5.0",
|
|
39
|
+
"@antfu/eslint-config": "2.14.0",
|
|
40
|
+
"@eslint/eslintrc": "3.0.2",
|
|
41
|
+
"eslint-flat-config-utils": "0.2.3",
|
|
42
|
+
"eslint-config-flat-gitignore": "0.1.5",
|
|
47
43
|
"eslint-plugin-no-unsanitized": "4.0.2",
|
|
48
|
-
"eslint-plugin-nuxt": "4.0.0",
|
|
49
44
|
"eslint-plugin-promise": "6.1.1",
|
|
50
|
-
"eslint-plugin-sonarjs": "0.25.1"
|
|
51
|
-
"eslint-plugin-unicorn": "52.0.0",
|
|
52
|
-
"eslint-plugin-unused-imports": "3.1.0",
|
|
53
|
-
"eslint-plugin-vue": "9.24.1",
|
|
54
|
-
"eslint-plugin-yml": "1.14.0",
|
|
55
|
-
"jsonc-eslint-parser": "2.4.0",
|
|
56
|
-
"yaml-eslint-parser": "1.2.2"
|
|
45
|
+
"eslint-plugin-sonarjs": "0.25.1"
|
|
57
46
|
},
|
|
58
47
|
"devDependencies": {
|
|
59
|
-
"@scayle/prettier-config-storefront": "2.0.2",
|
|
60
|
-
"@types/eslint": "8.56.7",
|
|
61
48
|
"dprint": "0.45.1",
|
|
62
|
-
"eslint": "
|
|
49
|
+
"eslint": "9.0.0",
|
|
63
50
|
"eslint-formatter-gitlab": "5.1.0",
|
|
64
51
|
"publint": "0.2.7"
|
|
65
52
|
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared eslint config for codeblocks within MD / Markdown
|
|
3
|
-
* https://eslint.org/docs/latest/
|
|
4
|
-
*
|
|
5
|
-
* Partially based on
|
|
6
|
-
* - https://github.com/antfu/eslint-config/blob/main/packages/eslint-config-basic
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// A patch that improves how ESLint loads plugins when
|
|
10
|
-
// working in a monorepo with a reusable toolchain.
|
|
11
|
-
// https://github.com/microsoft/rushstack/tree/main/eslint/eslint-patch
|
|
12
|
-
require('@rushstack/eslint-patch/modern-module-resolution')
|
|
13
|
-
|
|
14
|
-
/** @type {import('eslint').ESLint.ConfigData} */
|
|
15
|
-
module.exports = {
|
|
16
|
-
extends: ['plugin:jsonc/recommended-with-jsonc'],
|
|
17
|
-
overrides: [
|
|
18
|
-
{
|
|
19
|
-
// JSON(C) specific rule overrides
|
|
20
|
-
// https://ota-meshi.github.io/eslint-plugin-jsonc/
|
|
21
|
-
// https://github.com/ota-meshi/jsonc-eslint-parser
|
|
22
|
-
files: ['*.json', '*.json5'],
|
|
23
|
-
parser: 'jsonc-eslint-parser',
|
|
24
|
-
rules: {
|
|
25
|
-
'jsonc/array-bracket-spacing': ['error', 'never'],
|
|
26
|
-
'jsonc/comma-dangle': ['error', 'never'],
|
|
27
|
-
'jsonc/comma-style': ['error', 'last'],
|
|
28
|
-
'jsonc/indent': ['error', 2],
|
|
29
|
-
'jsonc/key-spacing': [
|
|
30
|
-
'error',
|
|
31
|
-
{ beforeColon: false, afterColon: true },
|
|
32
|
-
],
|
|
33
|
-
'jsonc/no-octal-escape': 'error',
|
|
34
|
-
'jsonc/object-curly-newline': [
|
|
35
|
-
'error',
|
|
36
|
-
{ multiline: true, consistent: true },
|
|
37
|
-
],
|
|
38
|
-
'jsonc/object-curly-spacing': ['error', 'always'],
|
|
39
|
-
'jsonc/object-property-newline': [
|
|
40
|
-
'error',
|
|
41
|
-
{ allowMultiplePropertiesPerLine: true },
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
// package.json specific rule overrides
|
|
47
|
-
// https://ota-meshi.github.io/eslint-plugin-jsonc/rules/sort-keys.html
|
|
48
|
-
files: ['package.json'],
|
|
49
|
-
parser: 'jsonc-eslint-parser',
|
|
50
|
-
rules: {
|
|
51
|
-
'jsonc/sort-keys': [
|
|
52
|
-
'error',
|
|
53
|
-
{
|
|
54
|
-
pathPattern: '^$',
|
|
55
|
-
order: [
|
|
56
|
-
'publisher',
|
|
57
|
-
'name',
|
|
58
|
-
'displayName',
|
|
59
|
-
'type',
|
|
60
|
-
'version',
|
|
61
|
-
'private',
|
|
62
|
-
'packageManager',
|
|
63
|
-
'description',
|
|
64
|
-
'author',
|
|
65
|
-
'license',
|
|
66
|
-
'funding',
|
|
67
|
-
'homepage',
|
|
68
|
-
'repository',
|
|
69
|
-
'bugs',
|
|
70
|
-
'keywords',
|
|
71
|
-
'categories',
|
|
72
|
-
'sideEffects',
|
|
73
|
-
'exports',
|
|
74
|
-
'main',
|
|
75
|
-
'module',
|
|
76
|
-
'unpkg',
|
|
77
|
-
'types',
|
|
78
|
-
'typesVersions',
|
|
79
|
-
'bin',
|
|
80
|
-
'icon',
|
|
81
|
-
'files',
|
|
82
|
-
'engines',
|
|
83
|
-
'activationEvents',
|
|
84
|
-
'contributes',
|
|
85
|
-
'scripts',
|
|
86
|
-
'peerDependencies',
|
|
87
|
-
'peerDependenciesMeta',
|
|
88
|
-
'dependencies',
|
|
89
|
-
'optionalDependencies',
|
|
90
|
-
'devDependencies',
|
|
91
|
-
'pnpm',
|
|
92
|
-
'overrides',
|
|
93
|
-
'resolutions',
|
|
94
|
-
'husky',
|
|
95
|
-
'simple-git-hooks',
|
|
96
|
-
'lint-staged',
|
|
97
|
-
'eslintConfig',
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
pathPattern: '^(?:dev|peer|optional|bundled)?[Dd]ependencies$',
|
|
102
|
-
order: { type: 'asc' },
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
pathPattern: '^exports.*$',
|
|
106
|
-
order: ['types', 'require', 'import'],
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared eslint config for Vue
|
|
3
|
-
* https://eslint.org/docs/latest/
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/** @type {import('eslint').ESLint.ConfigData} */
|
|
7
|
-
module.exports = {
|
|
8
|
-
overrides: [
|
|
9
|
-
{
|
|
10
|
-
files: ['*.vue'],
|
|
11
|
-
parser: 'vue-eslint-parser',
|
|
12
|
-
parserOptions: {
|
|
13
|
-
parser: '@typescript-eslint/parser',
|
|
14
|
-
},
|
|
15
|
-
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
|
|
16
|
-
rules: {
|
|
17
|
-
'no-unused-vars': 'off',
|
|
18
|
-
'constructor-super': 'off', // ts(2335) & ts(2377)
|
|
19
|
-
'getter-return': 'off', // ts(2378)
|
|
20
|
-
'no-const-assign': 'off', // ts(2588)
|
|
21
|
-
'no-dupe-args': 'off', // ts(2300)
|
|
22
|
-
'no-dupe-class-members': 'off', // ts(2393) & ts(2300)
|
|
23
|
-
'no-dupe-keys': 'off', // ts(1117)
|
|
24
|
-
'no-func-assign': 'off', // ts(2539)
|
|
25
|
-
'no-import-assign': 'off', // ts(2539) & ts(2540)
|
|
26
|
-
'no-new-symbol': 'off', // ts(7009)
|
|
27
|
-
'no-obj-calls': 'off', // ts(2349)
|
|
28
|
-
'no-redeclare': 'off', // ts(2451)
|
|
29
|
-
'no-setter-return': 'off', // ts(2408)
|
|
30
|
-
'no-this-before-super': 'off', // ts(2376)
|
|
31
|
-
'no-undef': 'off', // ts(2304)
|
|
32
|
-
'no-unreachable': 'off', // ts(7027)
|
|
33
|
-
'no-unsafe-negation': 'off', // ts(2365) & ts(2360) & ts(2358)
|
|
34
|
-
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
|
|
35
|
-
'prefer-const': 'error', // ts provides better types with const
|
|
36
|
-
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
|
|
37
|
-
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
|
|
38
|
-
'valid-typeof': 'off', // ts(2367)
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
files: [
|
|
44
|
-
// These pages are not used directly by users so they can have one-word names.
|
|
45
|
-
// https://github.com/nuxt/eslint-config/blob/main/packages/eslint-config/index.js#L66
|
|
46
|
-
'**/pages/**/*.{js,ts,jsx,tsx,vue}',
|
|
47
|
-
'**/layouts/**/*.{js,ts,jsx,tsx,vue}',
|
|
48
|
-
'**/app.{js,ts,jsx,tsx,vue}',
|
|
49
|
-
'**/error.{js,ts,jsx,tsx,vue}',
|
|
50
|
-
// These files should have multiple words in their names as they are within subdirectories.
|
|
51
|
-
'**/components/*/**/*.{js,ts,jsx,tsx,vue}',
|
|
52
|
-
],
|
|
53
|
-
rules: { 'vue/multi-word-component-names': 'off' },
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared eslint config for codeblocks within MD / Markdown
|
|
3
|
-
* https://eslint.org/docs/latest/
|
|
4
|
-
*
|
|
5
|
-
* Partially based on
|
|
6
|
-
* - https://github.com/antfu/eslint-config/blob/main/packages/eslint-config-basic
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// A patch that improves how ESLint loads plugins when
|
|
10
|
-
// working in a monorepo with a reusable toolchain.
|
|
11
|
-
// https://github.com/microsoft/rushstack/tree/main/eslint/eslint-patch
|
|
12
|
-
require('@rushstack/eslint-patch/modern-module-resolution')
|
|
13
|
-
|
|
14
|
-
/** @type {import('eslint').ESLint.ConfigData} */
|
|
15
|
-
module.exports = {
|
|
16
|
-
extends: ['plugin:yml/standard', 'plugin:yml/prettier'],
|
|
17
|
-
overrides: [
|
|
18
|
-
{
|
|
19
|
-
// YAML specific rule overrides
|
|
20
|
-
// https://ota-meshi.github.io/eslint-plugin-yml/
|
|
21
|
-
// https://github.com/ota-meshi/yaml-eslint-parser
|
|
22
|
-
files: ['*.yaml', '*.yml'],
|
|
23
|
-
parser: 'yaml-eslint-parser',
|
|
24
|
-
rules: {
|
|
25
|
-
'spaced-comment': 'off',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
}
|
package/index.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared eslint config
|
|
3
|
-
* https://eslint.org/docs/latest/
|
|
4
|
-
*
|
|
5
|
-
* Partially based on
|
|
6
|
-
* - https://github.com/antfu/eslint-config/blob/main/packages/eslint-config-basic
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// A patch that improves how ESLint loads plugins when
|
|
10
|
-
// working in a monorepo with a reusable toolchain.
|
|
11
|
-
// https://github.com/microsoft/rushstack/tree/main/eslint/eslint-patch
|
|
12
|
-
require('@rushstack/eslint-patch/modern-module-resolution')
|
|
13
|
-
|
|
14
|
-
/** @type {import('eslint').ESLint.ConfigData} */
|
|
15
|
-
module.exports = {
|
|
16
|
-
parserOptions: {
|
|
17
|
-
ecmaVersion: '2018',
|
|
18
|
-
parser: {
|
|
19
|
-
js: 'espree',
|
|
20
|
-
jsx: 'espree',
|
|
21
|
-
// eslint-disable-next-line sonarjs/no-duplicate-string
|
|
22
|
-
ts: '@typescript-eslint/parser',
|
|
23
|
-
tsx: '@typescript-eslint/parser',
|
|
24
|
-
},
|
|
25
|
-
extraFileExtensions: ['.vue'],
|
|
26
|
-
ecmaFeatures: {
|
|
27
|
-
jsx: true,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
env: {
|
|
31
|
-
es6: true,
|
|
32
|
-
browser: true,
|
|
33
|
-
node: true,
|
|
34
|
-
},
|
|
35
|
-
// Reports errors for unused `eslint-disable directives`
|
|
36
|
-
// when no problems would be reported in the disabled area
|
|
37
|
-
// https://eslint.org/docs/latest/integrate/nodejs-api#linterverify
|
|
38
|
-
reportUnusedDisableDirectives: true,
|
|
39
|
-
ignorePatterns: [
|
|
40
|
-
'__snapshots__',
|
|
41
|
-
'.nuxt',
|
|
42
|
-
'.output',
|
|
43
|
-
'*.d.ts',
|
|
44
|
-
'*.min.*',
|
|
45
|
-
'build',
|
|
46
|
-
'CHANGELOG.md',
|
|
47
|
-
'coverage',
|
|
48
|
-
'dist',
|
|
49
|
-
'LICENSE*',
|
|
50
|
-
'node_modules',
|
|
51
|
-
'out',
|
|
52
|
-
'output',
|
|
53
|
-
'package-lock.json',
|
|
54
|
-
'pnpm-lock.yaml',
|
|
55
|
-
'public',
|
|
56
|
-
'temp',
|
|
57
|
-
'yarn.lock',
|
|
58
|
-
// ignore for in lint-staged
|
|
59
|
-
'*.css',
|
|
60
|
-
'*.png',
|
|
61
|
-
'*.ico',
|
|
62
|
-
'*.toml',
|
|
63
|
-
'*.patch',
|
|
64
|
-
'*.txt',
|
|
65
|
-
'*.crt',
|
|
66
|
-
'*.csr',
|
|
67
|
-
'*.key',
|
|
68
|
-
'Dockerfile',
|
|
69
|
-
'!.vscode',
|
|
70
|
-
],
|
|
71
|
-
extends: [
|
|
72
|
-
'plugin:@typescript-eslint/eslint-recommended',
|
|
73
|
-
'standard',
|
|
74
|
-
// 'plugin:n/recommended', // Disabled to to config collision with 'standard'
|
|
75
|
-
'plugin:import/recommended',
|
|
76
|
-
'plugin:import/typescript',
|
|
77
|
-
'plugin:eslint-comments/recommended',
|
|
78
|
-
'plugin:sonarjs/recommended',
|
|
79
|
-
'plugin:no-unsanitized/DOM',
|
|
80
|
-
// 'plugin:unicorn/recommended',
|
|
81
|
-
'./config/eslint-config-yml.cjs',
|
|
82
|
-
'prettier',
|
|
83
|
-
],
|
|
84
|
-
plugins: [
|
|
85
|
-
'@typescript-eslint',
|
|
86
|
-
'html',
|
|
87
|
-
'promise',
|
|
88
|
-
'unused-imports',
|
|
89
|
-
'sonarjs',
|
|
90
|
-
],
|
|
91
|
-
// Shared configuration for rules
|
|
92
|
-
settings: {
|
|
93
|
-
'import/resolver': {
|
|
94
|
-
node: {
|
|
95
|
-
extensions: ['.js', '.jsx', '.mjs', 'cjs', '.ts', '.tsx', '.d.ts'],
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
rules: {
|
|
100
|
-
/** General Code Rules **/
|
|
101
|
-
// Handled by unused-imports/no-unused-imports
|
|
102
|
-
'@typescript-eslint/no-unused-vars': 'off',
|
|
103
|
-
'no-redeclare': 'off',
|
|
104
|
-
'@typescript-eslint/no-redeclare': [
|
|
105
|
-
'error',
|
|
106
|
-
{ ignoreDeclarationMerge: true },
|
|
107
|
-
],
|
|
108
|
-
// 'n/no-missing-import': 0,
|
|
109
|
-
// 'n/no-missing-require': 0,
|
|
110
|
-
// Enforce import order
|
|
111
|
-
'import/order': 'error',
|
|
112
|
-
// Imports should come first
|
|
113
|
-
'import/first': 'error',
|
|
114
|
-
// Exporting mutable variables
|
|
115
|
-
'import/no-mutable-exports': 'error',
|
|
116
|
-
// Allow unresolved imports
|
|
117
|
-
'import/no-unresolved': 'off',
|
|
118
|
-
// Allow debugger during development
|
|
119
|
-
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
|
|
120
|
-
// 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
|
|
121
|
-
// Prefer const over let
|
|
122
|
-
'prefer-const': [
|
|
123
|
-
'error',
|
|
124
|
-
{
|
|
125
|
-
destructuring: 'any',
|
|
126
|
-
ignoreReadBeforeAssign: false,
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
// No single if in an "else" block
|
|
130
|
-
'no-lonely-if': 'error',
|
|
131
|
-
// Force curly braces for control flow, including if blocks with a single statement
|
|
132
|
-
curly: ['error', 'all'],
|
|
133
|
-
// No async function without await
|
|
134
|
-
'require-await': 'error',
|
|
135
|
-
// Force dot notation when possible
|
|
136
|
-
'dot-notation': 1,
|
|
137
|
-
// Warn for void usage
|
|
138
|
-
'no-void': 1,
|
|
139
|
-
'no-var': 'error',
|
|
140
|
-
// Force object shorthand where possible
|
|
141
|
-
'object-shorthand': 'error',
|
|
142
|
-
// No useless destructuring/importing/exporting renames
|
|
143
|
-
'no-useless-rename': 'error',
|
|
144
|
-
// Per the docs, the root no-unused-vars should be disabled:
|
|
145
|
-
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
|
|
146
|
-
// '@typescript-eslint/no-unused-vars': ['error', { args: 'all', argsIgnorePattern: '^_' }],
|
|
147
|
-
'no-unused-vars': 'off',
|
|
148
|
-
// https://github.com/typescript-eslint/typescript-eslint/blob/1cf9243/docs/getting-started/linting/FAQ.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
|
149
|
-
'no-undef': 'off',
|
|
150
|
-
|
|
151
|
-
/** Formatting (not handled by Prettier) **/
|
|
152
|
-
// Deprecated
|
|
153
|
-
'newline-before-return': 'off',
|
|
154
|
-
// Deprecated
|
|
155
|
-
'newline-after-var': 'off',
|
|
156
|
-
// https://eslint.org/docs/latest/rules/padding-line-between-statements
|
|
157
|
-
'padding-line-between-statements': [
|
|
158
|
-
'error',
|
|
159
|
-
{ blankLine: 'always', prev: 'var', next: 'return' },
|
|
160
|
-
{ blankLine: 'always', prev: 'var', next: 'block' },
|
|
161
|
-
{ blankLine: 'always', prev: 'block', next: 'return' },
|
|
162
|
-
],
|
|
163
|
-
|
|
164
|
-
/** Performance Tweaks for ESLint ***/
|
|
165
|
-
// https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/TROUBLESHOOTING.md#eslint-plugin-import
|
|
166
|
-
indent: 0,
|
|
167
|
-
'@typescript-eslint/indent': 0,
|
|
168
|
-
// Disable to increase eslint performance as TypeScript covers its usecase
|
|
169
|
-
'import/no-named-as-default-member': 0,
|
|
170
|
-
// Disable to increase eslint performance as TypeScript covers its usecase
|
|
171
|
-
'import/default': 0,
|
|
172
|
-
// Allow unverifiable namespaces of imports
|
|
173
|
-
// Disable to increase eslint performance as TypeScript covers its usecase
|
|
174
|
-
'import/namespace': 0,
|
|
175
|
-
// Name imports result sometimes in errors, as type definitions are incomplete
|
|
176
|
-
// Disable to increase eslint performance as TypeScript covers its usecase
|
|
177
|
-
'import/named': 0,
|
|
178
|
-
'import/no-named-as-default': 0,
|
|
179
|
-
|
|
180
|
-
/** Additional Rule Tweaks **/
|
|
181
|
-
'eslint-comments/no-unlimited-disable': 1,
|
|
182
|
-
// Use node internals and types to check for extraneous imports of dependencies
|
|
183
|
-
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md
|
|
184
|
-
'import/no-extraneous-dependencies': [
|
|
185
|
-
'error',
|
|
186
|
-
{ includeInternal: true, includeTypes: true },
|
|
187
|
-
],
|
|
188
|
-
|
|
189
|
-
/** Prettier Compatibility **/
|
|
190
|
-
'space-before-function-paren': 0,
|
|
191
|
-
|
|
192
|
-
/** Disallowed Imports **/
|
|
193
|
-
'no-restricted-imports': [
|
|
194
|
-
'error',
|
|
195
|
-
// Forbid importing "Lodash" package since it's replaced with "Radash"
|
|
196
|
-
{
|
|
197
|
-
paths: [
|
|
198
|
-
{
|
|
199
|
-
name: 'lodash',
|
|
200
|
-
message: 'Usage radash instead of lodash ',
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
patterns: [
|
|
204
|
-
{
|
|
205
|
-
group: ['lodash/*', 'lodash-es/*'],
|
|
206
|
-
message: 'Usage radash instead of lodash',
|
|
207
|
-
},
|
|
208
|
-
],
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
},
|
|
212
|
-
overrides: [
|
|
213
|
-
{
|
|
214
|
-
files: ['*.ts', '*.tsx'],
|
|
215
|
-
parser: '@typescript-eslint/parser',
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
files: ['*.ts', '*.tsx', '*.mts', '*.cts', '*.vue'],
|
|
219
|
-
rules: {
|
|
220
|
-
// The rule `no-unused-vars` of `eslint:recommended`
|
|
221
|
-
// does not work with TypeScripts type definitions.
|
|
222
|
-
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
|
|
223
|
-
'no-unused-vars': 'off',
|
|
224
|
-
// https://github.com/typescript-eslint/typescript-eslint/blob/1cf9243/docs/getting-started/linting/FAQ.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
|
225
|
-
'no-undef': 'off',
|
|
226
|
-
'@typescript-eslint/no-unused-vars': [
|
|
227
|
-
'error',
|
|
228
|
-
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
|
|
229
|
-
],
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
// TypeScript Definitions specific overrides
|
|
234
|
-
files: ['*.d.ts'],
|
|
235
|
-
rules: {
|
|
236
|
-
'import/no-duplicates': 'off',
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
],
|
|
240
|
-
}
|
package/nuxt/nuxt.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared eslint config for Vue3
|
|
3
|
-
* https://eslint.org/docs/latest/
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** @type {import('eslint').ESLint.ConfigData} */
|
|
8
|
-
module.exports = {
|
|
9
|
-
extends: [
|
|
10
|
-
'../config/eslint-config-vue-base.cjs',
|
|
11
|
-
'plugin:vue/vue3-recommended',
|
|
12
|
-
],
|
|
13
|
-
rules: {
|
|
14
|
-
'vue/no-reserved-component-names': 'error',
|
|
15
|
-
},
|
|
16
|
-
overrides: [
|
|
17
|
-
{
|
|
18
|
-
// Pages and layouts are required to have a single root element if transitions are enabled.
|
|
19
|
-
// https://github.com/nuxt/eslint-config/blob/main/packages/eslint-config/index.js#L77
|
|
20
|
-
files: [
|
|
21
|
-
'**/pages/**/*.{js,ts,jsx,tsx,vue}',
|
|
22
|
-
'**/layouts/**/*.{js,ts,jsx,tsx,vue}',
|
|
23
|
-
],
|
|
24
|
-
rules: { 'vue/no-multiple-template-root': 'error' },
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
}
|
package/nuxt/nuxt2.cjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared eslint config for Vue2
|
|
3
|
-
* https://eslint.org/docs/latest/
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** @type {import('eslint').ESLint.ConfigData} */
|
|
8
|
-
module.exports = {
|
|
9
|
-
extends: ['../config/eslint-config-vue-base.cjs', 'plugin:vue/recommended'],
|
|
10
|
-
rules: {
|
|
11
|
-
'vue/no-reserved-component-names': 'error',
|
|
12
|
-
},
|
|
13
|
-
overrides: [
|
|
14
|
-
{
|
|
15
|
-
// Pages and layouts are required to have a single root element if transitions are enabled.
|
|
16
|
-
// https://github.com/nuxt/eslint-config/blob/main/packages/eslint-config/index.js#L77
|
|
17
|
-
files: [
|
|
18
|
-
'**/pages/**/*.{js,ts,jsx,tsx,vue}',
|
|
19
|
-
'**/layouts/**/*.{js,ts,jsx,tsx,vue}',
|
|
20
|
-
],
|
|
21
|
-
rules: { 'vue/no-multiple-template-root': 'error' },
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
}
|