@dword-design/eslint-config 5.0.32 → 6.0.1
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/dist/create/index.js +124 -64
- package/package.json +29 -29
- package/dist/cjs-fallback.cjs +0 -4
package/dist/create/index.js
CHANGED
|
@@ -1,74 +1,98 @@
|
|
|
1
|
+
import pathLib from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import babelParser from '@babel/eslint-parser';
|
|
1
4
|
import defu from '@dword-design/defu';
|
|
2
|
-
import {
|
|
5
|
+
import { includeIgnoreFile } from '@eslint/compat';
|
|
6
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
7
|
+
import js from '@eslint/js';
|
|
3
8
|
import confusingBrowserGlobals from 'confusing-browser-globals';
|
|
4
9
|
import packageName from 'depcheck-package-name';
|
|
10
|
+
import { defineConfig } from 'eslint/config';
|
|
11
|
+
import importPlugin from 'eslint-plugin-import';
|
|
12
|
+
import eslintPluginJsonc from 'eslint-plugin-jsonc';
|
|
13
|
+
import pluginPlaywright from 'eslint-plugin-playwright';
|
|
14
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
15
|
+
import pluginPromise from 'eslint-plugin-promise';
|
|
16
|
+
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
|
17
|
+
import pluginVue from 'eslint-plugin-vue';
|
|
5
18
|
import fs from 'fs-extra';
|
|
19
|
+
import globals from 'globals';
|
|
6
20
|
import loadPkg from 'load-pkg';
|
|
7
|
-
import { without } from 'lodash-es';
|
|
21
|
+
import { compact, omit, without } from 'lodash-es';
|
|
22
|
+
import { sortOrder as packageJsonSortOrder } from 'sort-package-json';
|
|
8
23
|
import restrictedImports from "./restricted-imports.js";
|
|
9
24
|
export default () => {
|
|
10
|
-
var _ref, _restrictedImports;
|
|
11
25
|
const packageConfig = loadPkg.sync() || {};
|
|
12
26
|
const baseConfig = defu(fs.existsSync('.baserc.json') ? fs.readJsonSync('.baserc.json') : {}, {
|
|
13
27
|
testRunner: 'mocha'
|
|
14
28
|
});
|
|
15
|
-
const eslintRestrictedImports =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
globals: {
|
|
33
|
-
expect: 'readonly'
|
|
29
|
+
const eslintRestrictedImports = restrictedImports.filter(importDef => importDef.alternative === undefined || importDef.alternative !== packageConfig.name).map(importDef => ({
|
|
30
|
+
...omit(importDef, ['alternative']),
|
|
31
|
+
message: compact([importDef.message, importDef.alternative ? `Use '${importDef.alternative}' instead` : '']).join(' ')
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
// mimic CommonJS variables -- not needed if using CommonJS
|
|
35
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
36
|
+
const __dirname = pathLib.dirname(__filename);
|
|
37
|
+
const compat = new FlatCompat({
|
|
38
|
+
baseDirectory: __dirname
|
|
39
|
+
});
|
|
40
|
+
return defineConfig([...(fs.existsSync('.gitignore') ? [includeIgnoreFile(pathLib.resolve('.gitignore'))] : []), {
|
|
41
|
+
languageOptions: {
|
|
42
|
+
parser: babelParser,
|
|
43
|
+
parserOptions: {
|
|
44
|
+
babelOptions: {
|
|
45
|
+
rootMode: 'upward-optional'
|
|
34
46
|
}
|
|
35
|
-
}),
|
|
36
|
-
rules: {
|
|
37
|
-
'no-restricted-imports': ['error', {
|
|
38
|
-
paths: [...eslintRestrictedImports, {
|
|
39
|
-
message: "Use the global 'expect' variable instead",
|
|
40
|
-
name: 'expect'
|
|
41
|
-
}]
|
|
42
|
-
}]
|
|
43
47
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
}
|
|
49
|
+
}, js.configs.recommended, importPlugin.flatConfigs.recommended, pluginPromise.configs['flat/recommended'], ...pluginVue.configs['flat/recommended'].map(plugin => ({
|
|
50
|
+
files: ['**/*.js', '**/*.vue'],
|
|
51
|
+
...plugin
|
|
52
|
+
})), ...compat.extends(`plugin:${packageName`@dword-design/eslint-plugin-import-alias`}/recommended`), {
|
|
53
|
+
files: ['**/*.js', '**/*.vue'],
|
|
54
|
+
...eslintPluginPrettierRecommended
|
|
55
|
+
}, ...(baseConfig.testRunner === 'playwright' ? [pluginPlaywright.configs['flat/recommended']] : []), ...compat.plugins(packageName`eslint-plugin-prefer-arrow`), ...compat.plugins(packageName`eslint-plugin-simple-import-sort`), ...compat.plugins(packageName`eslint-plugin-sort-keys-fix`), {
|
|
56
|
+
files: ['**/*.js', '**/*.vue'],
|
|
57
|
+
...eslintPluginUnicorn.configs.recommended
|
|
58
|
+
}, ...eslintPluginJsonc.configs['flat/recommended-with-jsonc'], {
|
|
59
|
+
files: ['**/*.vue'],
|
|
60
|
+
languageOptions: {
|
|
61
|
+
parserOptions: {
|
|
62
|
+
babelOptions: {
|
|
63
|
+
rootMode: 'upward-optional'
|
|
64
|
+
},
|
|
65
|
+
parser: packageName`@babel/eslint-parser`
|
|
50
66
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
files: ['**/*.json'],
|
|
70
|
+
rules: {
|
|
71
|
+
'jsonc/indent': ['error', 2],
|
|
72
|
+
'jsonc/sort-keys': 'error'
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
files: ['**/package.json'],
|
|
76
|
+
rules: {
|
|
77
|
+
'jsonc/sort-keys': ['error', {
|
|
78
|
+
order: packageJsonSortOrder,
|
|
79
|
+
pathPattern: '^$'
|
|
80
|
+
}]
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
files: ['**/*.js', '**/*.vue'],
|
|
84
|
+
languageOptions: {
|
|
85
|
+
globals: {
|
|
86
|
+
...globals.node,
|
|
87
|
+
...globals.browser
|
|
55
88
|
}
|
|
56
|
-
}],
|
|
57
|
-
parser: packageName`vue-eslint-parser`,
|
|
58
|
-
parserOptions: {
|
|
59
|
-
babelOptions: {
|
|
60
|
-
rootMode: 'upward-optional'
|
|
61
|
-
},
|
|
62
|
-
parser: packageName`@babel/eslint-parser`
|
|
63
89
|
},
|
|
64
|
-
plugins: [packageName`eslint-plugin-prefer-arrow`, packageName`eslint-plugin-simple-import-sort`, packageName`eslint-plugin-json-format`, packageName`eslint-plugin-sort-keys-fix`, packageName`eslint-plugin-github`, packageName`eslint-plugin-unicorn`],
|
|
65
90
|
rules: {
|
|
66
91
|
...(baseConfig.testRunner === 'playwright' && {
|
|
67
92
|
'playwright/expect-expect': 'off'
|
|
68
93
|
}),
|
|
69
94
|
'arrow-body-style': ['error', 'as-needed'],
|
|
70
95
|
'func-names': ['error', 'never'],
|
|
71
|
-
'github/array-foreach': 'error',
|
|
72
96
|
'global-require': 'off',
|
|
73
97
|
'import/extensions': ['error', 'ignorePackages'],
|
|
74
98
|
'import/no-commonjs': 'error',
|
|
@@ -76,6 +100,7 @@ export default () => {
|
|
|
76
100
|
'import/no-extraneous-dependencies': ['error', {
|
|
77
101
|
devDependencies: ['**/*.spec.js', ...(baseConfig.testRunner === 'playwright' ? ['fixtures/**', 'global-setup.js', 'global-teardown.js', 'playwright.config.js'] : ['global-test-hooks.js'])]
|
|
78
102
|
}],
|
|
103
|
+
'import/no-named-as-default': 'off',
|
|
79
104
|
'import/order': 'off',
|
|
80
105
|
'import/prefer-default-export': 'off',
|
|
81
106
|
'linebreak-style': ['error', 'unix'],
|
|
@@ -107,10 +132,16 @@ export default () => {
|
|
|
107
132
|
'no-restricted-imports': ['error', {
|
|
108
133
|
paths: eslintRestrictedImports
|
|
109
134
|
}],
|
|
110
|
-
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
|
|
111
135
|
'no-return-assign': 'off',
|
|
112
136
|
'no-template-curly-in-string': 'off',
|
|
113
137
|
'no-underscore-dangle': 'off',
|
|
138
|
+
'no-var': 'error',
|
|
139
|
+
[`${packageName`prettier`}/prettier`]: ['error', {
|
|
140
|
+
arrowParens: 'avoid',
|
|
141
|
+
objectWrap: 'collapse',
|
|
142
|
+
singleQuote: true,
|
|
143
|
+
trailingComma: 'all'
|
|
144
|
+
}],
|
|
114
145
|
'object-shorthand': ['error', 'always'],
|
|
115
146
|
'padding-line-between-statements': ['error', {
|
|
116
147
|
blankLine: 'never',
|
|
@@ -142,18 +173,17 @@ export default () => {
|
|
|
142
173
|
next: 'export',
|
|
143
174
|
prev: '*'
|
|
144
175
|
}],
|
|
145
|
-
[`${packageName`prettier`}/prettier`]: ['error', {
|
|
146
|
-
arrowParens: 'avoid',
|
|
147
|
-
plugins: [packageName`prettier-plugin-compactify`],
|
|
148
|
-
singleQuote: true,
|
|
149
|
-
trailingComma: 'all'
|
|
150
|
-
}],
|
|
151
176
|
'prefer-arrow/prefer-arrow-functions': ['error'],
|
|
152
|
-
// Everything from airbnb except ForOfStatement
|
|
153
177
|
'prefer-destructuring': 'off',
|
|
154
178
|
'require-await': 'error',
|
|
155
179
|
'simple-import-sort/imports': 'error',
|
|
156
180
|
'sort-keys-fix/sort-keys-fix': 'error',
|
|
181
|
+
'unicorn/catch-error-name': 'off',
|
|
182
|
+
'unicorn/no-anonymous-default-export': 'off',
|
|
183
|
+
'unicorn/no-negated-condition': 'off',
|
|
184
|
+
'unicorn/no-nested-ternary': 'off',
|
|
185
|
+
'unicorn/no-null': 'off',
|
|
186
|
+
'unicorn/prevent-abbreviations': 'off',
|
|
157
187
|
'unicorn/template-indent': ['error', {
|
|
158
188
|
tags: Object.keys({
|
|
159
189
|
css: true,
|
|
@@ -165,11 +195,6 @@ export default () => {
|
|
|
165
195
|
xml: true
|
|
166
196
|
})
|
|
167
197
|
}],
|
|
168
|
-
...(baseConfig.testRunner === 'playwright' && {
|
|
169
|
-
'playwright/valid-title': ['error', {
|
|
170
|
-
ignoreTypeOfTestName: true
|
|
171
|
-
}]
|
|
172
|
-
}),
|
|
173
198
|
'vue/attributes-order': ['error', {
|
|
174
199
|
alphabetical: true
|
|
175
200
|
}],
|
|
@@ -177,7 +202,13 @@ export default () => {
|
|
|
177
202
|
'vue/order-in-components': 'off',
|
|
178
203
|
'vue/prefer-true-attribute-shorthand': 'error',
|
|
179
204
|
'vue/require-default-prop': 'off',
|
|
180
|
-
'vue/require-prop-types': 'off'
|
|
205
|
+
'vue/require-prop-types': 'off',
|
|
206
|
+
// Complains about title not being a string if variable is passed
|
|
207
|
+
...(baseConfig.testRunner === 'playwright' && {
|
|
208
|
+
'playwright/valid-title': ['error', {
|
|
209
|
+
ignoreTypeOfTestName: true
|
|
210
|
+
}]
|
|
211
|
+
})
|
|
181
212
|
},
|
|
182
213
|
settings: {
|
|
183
214
|
'import/resolver': {
|
|
@@ -187,5 +218,34 @@ export default () => {
|
|
|
187
218
|
[packageName`eslint-import-resolver-exports`]: {}
|
|
188
219
|
}
|
|
189
220
|
}
|
|
190
|
-
}
|
|
221
|
+
}, {
|
|
222
|
+
files: ['**/*.spec.js'],
|
|
223
|
+
...(baseConfig.testRunner === 'mocha' && {
|
|
224
|
+
languageOptions: {
|
|
225
|
+
globals: {
|
|
226
|
+
expect: 'readonly'
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}),
|
|
230
|
+
rules: {
|
|
231
|
+
'no-restricted-imports': ['error', {
|
|
232
|
+
paths: [...eslintRestrictedImports, {
|
|
233
|
+
message: "Use the global 'expect' variable instead",
|
|
234
|
+
name: 'expect'
|
|
235
|
+
}]
|
|
236
|
+
}]
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
files: [...(baseConfig.testRunner === 'playwright' ? ['fixtures/**'] : []), '**/*.spec.js'],
|
|
240
|
+
rules: {
|
|
241
|
+
...(baseConfig.testRunner === 'playwright' && {
|
|
242
|
+
'no-empty-pattern': 'off'
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
}, {
|
|
246
|
+
files: ['**/*.vue'],
|
|
247
|
+
rules: {
|
|
248
|
+
'vue/multi-word-component-names': 'off'
|
|
249
|
+
}
|
|
250
|
+
}]);
|
|
191
251
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dword-design/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"repository": "dword-design/eslint-config",
|
|
5
5
|
"funding": "https://github.com/sponsors/dword-design",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Sebastian Landwehr <info@sebastianlandwehr.com>",
|
|
8
8
|
"type": "module",
|
|
9
|
-
"
|
|
9
|
+
"exports": "./dist/index.js",
|
|
10
|
+
"main": "dist/index.js",
|
|
10
11
|
"files": [
|
|
11
12
|
"dist"
|
|
12
13
|
],
|
|
@@ -21,44 +22,43 @@
|
|
|
21
22
|
"test": "base test"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@babel/eslint-parser": "
|
|
25
|
+
"@babel/eslint-parser": "7.27.1",
|
|
25
26
|
"@dword-design/defu": "^1.0.0",
|
|
26
|
-
"@dword-design/eslint-plugin-import-alias": "^5.
|
|
27
|
-
"@
|
|
27
|
+
"@dword-design/eslint-plugin-import-alias": "^5.1.2",
|
|
28
|
+
"@eslint/compat": "^1.2.9",
|
|
29
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
30
|
+
"@eslint/js": "^9.27.0",
|
|
28
31
|
"confusing-browser-globals": "^1.0.11",
|
|
29
|
-
"depcheck-package-name": "^3.0.
|
|
30
|
-
"eslint
|
|
31
|
-
"eslint-config-prettier": "^10.
|
|
32
|
-
"eslint-import-resolver-babel-module": "^5.3.
|
|
33
|
-
"eslint-import-resolver-exports": "
|
|
34
|
-
"eslint-plugin-github": "^5.0.0",
|
|
32
|
+
"depcheck-package-name": "^3.0.1",
|
|
33
|
+
"eslint": "^9.27.0",
|
|
34
|
+
"eslint-config-prettier": "^10.1.5",
|
|
35
|
+
"eslint-import-resolver-babel-module": "^5.3.2",
|
|
36
|
+
"eslint-import-resolver-exports": "1.0.0-beta.5",
|
|
35
37
|
"eslint-plugin-import": "npm:@dword-design/eslint-plugin-import@^0.1.0",
|
|
36
|
-
"eslint-plugin-
|
|
38
|
+
"eslint-plugin-jsonc": "^2.20.1",
|
|
37
39
|
"eslint-plugin-playwright": "^2.2.0",
|
|
38
|
-
"eslint-plugin-prefer-arrow": "^1.
|
|
39
|
-
"eslint-plugin-prettier": "^5.
|
|
40
|
-
"eslint-plugin-promise": "^7.
|
|
41
|
-
"eslint-plugin-simple-import-sort": "^12.1.
|
|
42
|
-
"eslint-plugin-sort-keys-fix": "^1.1.
|
|
43
|
-
"eslint-plugin-unicorn": "
|
|
44
|
-
"eslint-plugin-vue": "^10.
|
|
40
|
+
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
41
|
+
"eslint-plugin-prettier": "^5.4.0",
|
|
42
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
43
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
44
|
+
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
45
|
+
"eslint-plugin-unicorn": "npm:@dword-design/eslint-plugin-unicorn@^0.0.1",
|
|
46
|
+
"eslint-plugin-vue": "^10.1.0",
|
|
45
47
|
"fs-extra": "^11.3.0",
|
|
46
|
-
"
|
|
48
|
+
"globals": "^16.1.0",
|
|
47
49
|
"load-pkg": "^4.0.0",
|
|
48
50
|
"lodash-es": "^4.17.21",
|
|
49
|
-
"prettier": "^3.
|
|
50
|
-
"
|
|
51
|
-
"vue-eslint-parser": "^9.1.1"
|
|
51
|
+
"prettier": "^3.5.3",
|
|
52
|
+
"sort-package-json": "^3.2.1"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@dword-design/base": "^11.
|
|
55
|
+
"@dword-design/base": "^11.3.14",
|
|
56
|
+
"@dword-design/functions": "^6.0.2",
|
|
55
57
|
"@playwright/test": "^1.52.0",
|
|
56
|
-
"
|
|
57
|
-
"execa": "^9.3.0",
|
|
58
|
+
"execa": "^9.5.3",
|
|
58
59
|
"in-folder": "^1.0.3",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"with-local-tmp-dir": "^5.0.0"
|
|
60
|
+
"output-files": "^2.0.32",
|
|
61
|
+
"with-local-tmp-dir": "^5.1.1"
|
|
62
62
|
},
|
|
63
63
|
"packageManager": "pnpm@10.4.0+sha512.6b849d0787d97f8f4e1f03a9b8ff8f038e79e153d6f11ae539ae7c435ff9e796df6a862c991502695c7f9e8fac8aeafc1ac5a8dab47e36148d183832d886dd52",
|
|
64
64
|
"engines": {
|
package/dist/cjs-fallback.cjs
DELETED