@scayle/eslint-config-storefront 4.6.0 → 4.7.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 +19 -5
- package/config/flat/importX.mjs +22 -0
- package/config/flat/index.mjs +73 -111
- package/config/flat/promise.mjs +26 -8
- package/config/flat/sonarjs.mjs +9 -10
- package/package.json +2 -3
- package/config/flat/sanitized.mjs +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @aboutyou/eslint-config-sfc
|
|
2
2
|
|
|
3
|
+
## 4.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Re-enabled previously disabled promise rules that are now compatible with ESLint Flat Config, adding comprehensive promise rule coverage with proper error, warning, and off severity levels. Rules now include `promise/no-multiple-resolved`, `promise/no-new-statics`, `promise/no-return-wrap` (error level), and various other promise-related rules (warning level). Additionally, removed `eslint-plugin-no-unsanitized` and its associated rules to simplify the configuration and remove potential conflicts with other security-focused plugins.
|
|
8
|
+
|
|
9
|
+
These changes also improve ESLint runtime performance by reducing the number of plugins loaded and optimizing rule configuration structure through pre-defined constants and simplified configuration trees. The removal of YAML parsing and linting support further reduces plugin overhead and improves linting reliability by eliminating potential parsing conflicts, syntax errors, and stability issues that can occur when processing complex YAML files.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Removed dependency `eslint-plugin-no-unsanitized@^4.1.2`
|
|
14
|
+
|
|
15
|
+
## 4.6.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Added dependency `eslint-plugin-import-x@^4.16.1`
|
|
20
|
+
- Updated dependency `typescript-eslint@8.35.1` to `typescript-eslint@8.36.0`
|
|
21
|
+
|
|
3
22
|
## 4.6.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -16,11 +35,6 @@
|
|
|
16
35
|
- `'import-x/no-self-import': 'error'`
|
|
17
36
|
- `'import-x/no-extraneous-dependencies': 'error'`
|
|
18
37
|
|
|
19
|
-
### Patch Changes
|
|
20
|
-
|
|
21
|
-
- Added dependency `eslint-plugin-import-x@^4.16.1`
|
|
22
|
-
- Updated dependency `typescript-eslint@8.35.1` to `typescript-eslint@8.36.0`
|
|
23
|
-
|
|
24
38
|
## 4.5.14
|
|
25
39
|
|
|
26
40
|
### Patch Changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { importX as pluginImportX } from 'eslint-plugin-import-x'
|
|
2
|
+
|
|
3
|
+
// Pre-defined rule configurations for better performance
|
|
4
|
+
const IMPORT_X_RULES = {
|
|
5
|
+
'import-x/consistent-type-specifier-style': ['error', 'prefer-top-level'],
|
|
6
|
+
'import-x/first': 'error',
|
|
7
|
+
'import-x/no-duplicates': 'error',
|
|
8
|
+
'import-x/no-mutable-exports': 'error',
|
|
9
|
+
'import-x/no-named-default': 'error',
|
|
10
|
+
'import-x/no-self-import': 'error',
|
|
11
|
+
'import-x/no-extraneous-dependencies': 'error',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function importX() {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
name: 'storefront/import-x/rules',
|
|
18
|
+
plugins: { 'import-x': pluginImportX },
|
|
19
|
+
rules: IMPORT_X_RULES,
|
|
20
|
+
},
|
|
21
|
+
]
|
|
22
|
+
}
|
package/config/flat/index.mjs
CHANGED
|
@@ -5,26 +5,18 @@ import {
|
|
|
5
5
|
combine,
|
|
6
6
|
comments,
|
|
7
7
|
ignores,
|
|
8
|
-
imports,
|
|
9
8
|
javascript,
|
|
10
9
|
jsdoc,
|
|
11
10
|
jsonc,
|
|
12
11
|
node,
|
|
13
12
|
test,
|
|
14
13
|
typescript,
|
|
15
|
-
yaml,
|
|
16
14
|
} from '@antfu/eslint-config'
|
|
17
15
|
import gitignore from 'eslint-config-flat-gitignore'
|
|
18
|
-
import { importX } from 'eslint-plugin-import-x'
|
|
19
16
|
import tseslint from 'typescript-eslint'
|
|
20
17
|
import { sonarjs } from './sonarjs.mjs'
|
|
21
18
|
import { promise } from './promise.mjs'
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
/*
|
|
25
|
-
* NOTES - REMOVE BEFORE MERGE!
|
|
26
|
-
* - https://www.npmjs.com/package/eslint-plugin-regexp
|
|
27
|
-
*/
|
|
19
|
+
import { importX } from './importX.mjs'
|
|
28
20
|
|
|
29
21
|
// Partial eslint config by `@antfu/eslint-config`
|
|
30
22
|
// <https://github.com/antfu/eslint-config/blob/main/README.md>
|
|
@@ -34,7 +26,6 @@ import { sanitized } from './sanitized.mjs'
|
|
|
34
26
|
* @param {boolean=} config.isNuxt
|
|
35
27
|
* @param {object=} config.typescript
|
|
36
28
|
* @param {string=} config.typescript.tsconfigPath
|
|
37
|
-
* @param {object=} config.custom
|
|
38
29
|
* @returns {FlatConfigComposer<Linter.FlatConfig<Linter.RulesRecord>, never>} Returns a FlatConfigComposer object to be consumed in projects eslint.config.mjs files
|
|
39
30
|
*/
|
|
40
31
|
export const eslintConfigStorefront = function(config = {
|
|
@@ -42,132 +33,103 @@ export const eslintConfigStorefront = function(config = {
|
|
|
42
33
|
typescript: { tsconfigPath: undefined },
|
|
43
34
|
}) {
|
|
44
35
|
const flatConfigComposer = new FlatConfigComposer()
|
|
36
|
+
const isNuxtProject = config.isNuxt
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
38
|
+
// Pre-defined rule configurations for better performance
|
|
39
|
+
const TYPESCRIPT_JSON_RULES = {
|
|
40
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
41
|
+
'@typescript-eslint/no-array-constructor': 'off',
|
|
42
|
+
'@typescript-eslint/no-duplicate-enum-values': 'off',
|
|
43
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
44
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
45
|
+
'@typescript-eslint/no-extra-non-null-assertion': 'off',
|
|
46
|
+
'@typescript-eslint/no-misused-new': 'off',
|
|
47
|
+
'@typescript-eslint/no-namespace': 'off',
|
|
48
|
+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
|
|
49
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
50
|
+
'@typescript-eslint/no-this-alias': 'off',
|
|
51
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
|
|
52
|
+
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
|
|
53
|
+
'@typescript-eslint/no-unsafe-function-type': 'off',
|
|
54
|
+
'@typescript-eslint/no-unused-expressions': 'off',
|
|
55
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
56
|
+
'@typescript-eslint/no-wrapper-object-types': 'off',
|
|
57
|
+
'@typescript-eslint/prefer-as-const': 'off',
|
|
58
|
+
'@typescript-eslint/prefer-namespace-keyword': 'off',
|
|
59
|
+
'@typescript-eslint/triple-slash-reference': 'off',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const CURLY_RULE = ['error', 'all']
|
|
63
|
+
|
|
64
|
+
const TYPESCRIPT_RULES = {
|
|
65
|
+
'curly': CURLY_RULE,
|
|
66
|
+
'@typescript-eslint/no-explicit-any': ['warn', { ignoreRestArgs: true }],
|
|
67
|
+
'@typescript-eslint/no-empty-object-type': ['error', {
|
|
68
|
+
'allowInterfaces': 'always',
|
|
69
|
+
}],
|
|
70
|
+
'@typescript-eslint/no-unused-vars': [
|
|
71
|
+
'error',
|
|
72
|
+
{
|
|
73
|
+
'args': 'all',
|
|
74
|
+
'argsIgnorePattern': '^_',
|
|
75
|
+
'caughtErrors': 'all',
|
|
76
|
+
'caughtErrorsIgnorePattern': '^_',
|
|
77
|
+
'destructuredArrayIgnorePattern': '^_',
|
|
78
|
+
'varsIgnorePattern': '^_',
|
|
79
|
+
'ignoreRestSiblings': true,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const BASE_CONFIGS = [
|
|
85
|
+
comments(),
|
|
86
|
+
node(),
|
|
87
|
+
jsonc(),
|
|
88
|
+
test(),
|
|
89
|
+
sonarjs(),
|
|
90
|
+
promise(),
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
const GLOBAL_RULES = {
|
|
94
|
+
'curly': CURLY_RULE,
|
|
95
|
+
'node/prefer-global/process': 'off',
|
|
63
96
|
}
|
|
64
97
|
|
|
98
|
+
const TEST_RULES = { 'no-console': 'off' }
|
|
99
|
+
|
|
100
|
+
const IGNORE_PATTERNS = ['**/fixtures/**/*', '**/*.jsonc']
|
|
101
|
+
|
|
65
102
|
// The following rules are already handled by `@nuxt/eslint` and
|
|
66
103
|
// don't need to be extended from `@antfu/eslint-config` if it is used
|
|
67
|
-
const nonNuxtRules = !
|
|
104
|
+
const nonNuxtRules = !isNuxtProject
|
|
68
105
|
? combine(
|
|
69
106
|
gitignore(),
|
|
70
107
|
ignores(),
|
|
71
|
-
|
|
108
|
+
importX(),
|
|
72
109
|
javascript(),
|
|
73
110
|
typescript(config.typescript),
|
|
74
111
|
jsdoc(),
|
|
75
112
|
tseslint.configs.recommended,
|
|
76
|
-
[{
|
|
77
|
-
rules: {
|
|
78
|
-
// https://eslint.org/docs/latest/rules/curly
|
|
79
|
-
'curly': ['error', 'all'],
|
|
80
|
-
// https://typescript-eslint.io/rules/no-explicit-any/
|
|
81
|
-
'@typescript-eslint/no-explicit-any': ['warn', {
|
|
82
|
-
ignoreRestArgs: true,
|
|
83
|
-
}],
|
|
84
|
-
// https://typescript-eslint.io/rules/no-empty-object-type/
|
|
85
|
-
'@typescript-eslint/no-empty-object-type': ['error', {
|
|
86
|
-
'allowInterfaces': 'always',
|
|
87
|
-
}],
|
|
88
|
-
// https://typescript-eslint.io/rules/no-unused-vars/
|
|
89
|
-
'@typescript-eslint/no-unused-vars': [
|
|
90
|
-
'error',
|
|
91
|
-
{
|
|
92
|
-
'args': 'all',
|
|
93
|
-
'argsIgnorePattern': '^_',
|
|
94
|
-
'caughtErrors': 'all',
|
|
95
|
-
'caughtErrorsIgnorePattern': '^_',
|
|
96
|
-
'destructuredArrayIgnorePattern': '^_',
|
|
97
|
-
'varsIgnorePattern': '^_',
|
|
98
|
-
'ignoreRestSiblings': true,
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
}],
|
|
103
|
-
importXConfig,
|
|
113
|
+
[{ rules: TYPESCRIPT_RULES }],
|
|
104
114
|
)
|
|
105
115
|
: {}
|
|
106
116
|
|
|
107
117
|
const configs = [
|
|
108
|
-
combine(
|
|
109
|
-
comments(), // https://github.com/antfu/eslint-config/blob/main/src/configs/comments.ts
|
|
110
|
-
node(), // https://github.com/antfu/eslint-config/blob/main/src/configs/node.ts
|
|
111
|
-
jsonc(), // https://github.com/antfu/eslint-config/blob/main/src/configs/jsonc.ts
|
|
112
|
-
yaml(), // https://github.com/antfu/eslint-config/blob/main/src/configs/yaml.ts
|
|
113
|
-
test(), // https://github.com/antfu/eslint-config/blob/main/src/configs/test.ts
|
|
114
|
-
sonarjs(),
|
|
115
|
-
promise(),
|
|
116
|
-
sanitized(),
|
|
117
|
-
importXConfig,
|
|
118
|
-
),
|
|
118
|
+
combine(...BASE_CONFIGS),
|
|
119
119
|
nonNuxtRules,
|
|
120
120
|
{
|
|
121
|
-
rules:
|
|
122
|
-
|
|
123
|
-
'curly': ['error', 'all'],
|
|
124
|
-
},
|
|
121
|
+
rules: GLOBAL_RULES,
|
|
122
|
+
ignores: [IGNORE_PATTERNS[0]],
|
|
125
123
|
},
|
|
126
|
-
{
|
|
127
|
-
// Disable default rules by imported @antfu/eslint-config
|
|
128
|
-
rules: {
|
|
129
|
-
'node/prefer-global/process': 'off',
|
|
130
|
-
'yaml/plain-scalar': 'off',
|
|
131
|
-
},
|
|
132
|
-
ignores: ['**/fixtures/**/*'],
|
|
133
|
-
},
|
|
134
|
-
// Disable TypeScript ESLint rules for JSON files
|
|
135
124
|
{
|
|
136
125
|
files: ['**/*.json'],
|
|
137
|
-
rules:
|
|
138
|
-
'@typescript-eslint/ban-ts-comment': 'off',
|
|
139
|
-
'@typescript-eslint/no-array-constructor': 'off',
|
|
140
|
-
'@typescript-eslint/no-duplicate-enum-values': 'off',
|
|
141
|
-
'@typescript-eslint/no-empty-object-type': 'off',
|
|
142
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
143
|
-
'@typescript-eslint/no-extra-non-null-assertion': 'off',
|
|
144
|
-
'@typescript-eslint/no-misused-new': 'off',
|
|
145
|
-
'@typescript-eslint/no-namespace': 'off',
|
|
146
|
-
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
|
|
147
|
-
'@typescript-eslint/no-require-imports': 'off',
|
|
148
|
-
'@typescript-eslint/no-this-alias': 'off',
|
|
149
|
-
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
|
|
150
|
-
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
|
|
151
|
-
'@typescript-eslint/no-unsafe-function-type': 'off',
|
|
152
|
-
'@typescript-eslint/no-unused-expressions': 'off',
|
|
153
|
-
'@typescript-eslint/no-unused-vars': 'off',
|
|
154
|
-
'@typescript-eslint/no-wrapper-object-types': 'off',
|
|
155
|
-
'@typescript-eslint/prefer-as-const': 'off',
|
|
156
|
-
'@typescript-eslint/prefer-namespace-keyword': 'off',
|
|
157
|
-
'@typescript-eslint/triple-slash-reference': 'off',
|
|
158
|
-
},
|
|
126
|
+
rules: TYPESCRIPT_JSON_RULES,
|
|
159
127
|
},
|
|
160
|
-
// Specific rules handling for test files
|
|
161
128
|
{
|
|
162
|
-
// See https://github.com/antfu/eslint-config/blob/main/src/globs.ts#L34
|
|
163
129
|
files: GLOB_TESTS,
|
|
164
|
-
rules:
|
|
165
|
-
'no-console': 'off',
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
ignores: ['**/*.jsonc'],
|
|
130
|
+
rules: TEST_RULES,
|
|
170
131
|
},
|
|
132
|
+
{ ignores: [IGNORE_PATTERNS[1]] },
|
|
171
133
|
]
|
|
172
134
|
|
|
173
135
|
return flatConfigComposer.append(
|
package/config/flat/promise.mjs
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
import pluginPromise from 'eslint-plugin-promise'
|
|
2
2
|
|
|
3
|
+
// Pre-defined rule configurations for better performance
|
|
4
|
+
const ERROR_RULES = {
|
|
5
|
+
'promise/no-multiple-resolved': 'error',
|
|
6
|
+
'promise/no-new-statics': 'error',
|
|
7
|
+
'promise/no-return-wrap': 'error',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const WARN_RULES = {
|
|
11
|
+
'promise/always-return': 'warn',
|
|
12
|
+
'promise/avoid-new': 'warn',
|
|
13
|
+
'promise/catch-or-return': 'warn',
|
|
14
|
+
'promise/no-callback-in-promise': 'warn',
|
|
15
|
+
'promise/no-nesting': 'warn',
|
|
16
|
+
'promise/no-promise-in-callback': 'warn',
|
|
17
|
+
'promise/no-return-in-finally': 'warn',
|
|
18
|
+
'promise/param-names': 'warn',
|
|
19
|
+
'promise/valid-params': 'warn',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const OFF_RULES = {
|
|
23
|
+
'promise/no-native': 'off',
|
|
24
|
+
}
|
|
25
|
+
|
|
3
26
|
export function promise() {
|
|
4
27
|
return [
|
|
5
28
|
{
|
|
6
29
|
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
30
|
plugins: { promise: pluginPromise },
|
|
12
31
|
rules: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'promise/no-callback-in-promise': 'off',
|
|
32
|
+
...ERROR_RULES,
|
|
33
|
+
...WARN_RULES,
|
|
34
|
+
...OFF_RULES,
|
|
17
35
|
},
|
|
18
36
|
},
|
|
19
37
|
]
|
package/config/flat/sonarjs.mjs
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import pluginSonarjs from 'eslint-plugin-sonarjs'
|
|
2
2
|
|
|
3
|
+
// Pre-defined rule configurations for better performance
|
|
4
|
+
const SONARJS_RULES = {
|
|
5
|
+
'sonarjs/no-duplicate-string': 'off',
|
|
6
|
+
'sonarjs/todo-tag': 'warn',
|
|
7
|
+
'sonarjs/fixme-tag': 'warn',
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
export function sonarjs() {
|
|
4
11
|
return [
|
|
5
12
|
pluginSonarjs.configs.recommended,
|
|
6
13
|
{
|
|
7
14
|
name: 'storefront/sonarjs/rules',
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'plugins': {
|
|
11
|
-
pluginSonarjs,
|
|
12
|
-
},
|
|
13
|
-
rules: {
|
|
14
|
-
'sonarjs/no-duplicate-string': 'off',
|
|
15
|
-
'sonarjs/todo-tag': 'warn',
|
|
16
|
-
'sonarjs/fixme-tag': 'warn',
|
|
17
|
-
},
|
|
15
|
+
plugins: { pluginSonarjs },
|
|
16
|
+
rules: SONARJS_RULES,
|
|
18
17
|
},
|
|
19
18
|
]
|
|
20
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/eslint-config-storefront",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "SCAYLE Commerce Engine specific eslint configuration",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"./config/flat/index.mjs": "./config/flat/index.mjs",
|
|
21
21
|
"./config/flat/sonarjs": "./config/flat/sonarjs.mjs",
|
|
22
22
|
"./config/flat/promise.mjs": "./config/flat/promise.mjs",
|
|
23
|
-
"./config/flat/
|
|
23
|
+
"./config/flat/importX.mjs": "./config/flat/importX.mjs"
|
|
24
24
|
},
|
|
25
25
|
"main": "./index.mjs",
|
|
26
26
|
"files": [
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"eslint-config-flat-gitignore": "^2.0.0",
|
|
40
40
|
"eslint-flat-config-utils": "^2.0.0",
|
|
41
41
|
"eslint-plugin-import-x": "^4.16.1",
|
|
42
|
-
"eslint-plugin-no-unsanitized": "^4.1.2",
|
|
43
42
|
"eslint-plugin-promise": "^7.2.1",
|
|
44
43
|
"eslint-plugin-sonarjs": "^3.0.1",
|
|
45
44
|
"local-pkg": "^1.0.0",
|