@nice-move/eslint-config-base 0.13.27 → 0.14.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/index.mjs +17 -1
- package/lib/import.mjs +19 -27
- package/lib/markdown.mjs +2 -2
- package/lib/mini.mjs +2 -2
- package/lib/node.mjs +1 -1
- package/package.json +2 -3
- package/lib/node-next-resolver.mjs +0 -63
package/index.mjs
CHANGED
|
@@ -39,9 +39,25 @@ const old = compat.config(airbnb).map((item) => {
|
|
|
39
39
|
|
|
40
40
|
item.files = allExts;
|
|
41
41
|
|
|
42
|
+
item.settings &&= Object.fromEntries(
|
|
43
|
+
Object.entries(item.settings).map(([key, value]) => [
|
|
44
|
+
key.replace(/^import\//, 'import-x/'),
|
|
45
|
+
value,
|
|
46
|
+
]),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
item.rules &&= Object.fromEntries(
|
|
50
|
+
Object.entries(item.rules).map(([key, value]) => [
|
|
51
|
+
key.replace(/^import\//, 'import-x/'),
|
|
52
|
+
value,
|
|
53
|
+
]),
|
|
54
|
+
);
|
|
55
|
+
|
|
42
56
|
return item;
|
|
43
57
|
});
|
|
44
58
|
|
|
59
|
+
console.log(old);
|
|
60
|
+
|
|
45
61
|
export const create = (...addings) => [
|
|
46
62
|
{
|
|
47
63
|
files: allExts,
|
|
@@ -59,7 +75,7 @@ export const create = (...addings) => [
|
|
|
59
75
|
{
|
|
60
76
|
files: ['src/**/*.{mjs,mts,cjs,cts}'],
|
|
61
77
|
settings: {
|
|
62
|
-
'import/core-modules': ['electron'],
|
|
78
|
+
'import-x/core-modules': ['electron'],
|
|
63
79
|
},
|
|
64
80
|
},
|
|
65
81
|
],
|
package/lib/import.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { flatConfigs } from 'eslint-plugin-import-x';
|
|
4
4
|
|
|
5
5
|
import { configHas, pkgHas } from './utils.mjs';
|
|
6
6
|
|
|
7
7
|
const Vscode = pkgHas(
|
|
8
8
|
({ engines: { vscode } = {} }) => vscode,
|
|
9
|
-
() => ({ 'import/core-modules': ['vscode'] }),
|
|
9
|
+
() => ({ 'import-x/core-modules': ['vscode'] }),
|
|
10
10
|
);
|
|
11
11
|
|
|
12
12
|
export default [
|
|
13
|
-
|
|
13
|
+
flatConfigs.recommended,
|
|
14
14
|
{
|
|
15
15
|
files: ['**/*.{js,jsx,ts,tsx,cjs,mjs,cts,mts}'],
|
|
16
16
|
ignores: [
|
|
@@ -21,20 +21,20 @@ export default [
|
|
|
21
21
|
'**/*.md/*',
|
|
22
22
|
],
|
|
23
23
|
rules: {
|
|
24
|
-
'import/no-default-export': 'warn',
|
|
24
|
+
'import-x/no-default-export': 'warn',
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
files: ['**/*.{js,jsx,ts,tsx,cjs,mjs,cts,mts,qs,wxs,vue}'],
|
|
29
29
|
rules: {
|
|
30
|
-
'import/extensions': [
|
|
30
|
+
'import-x/extensions': [
|
|
31
31
|
'error',
|
|
32
32
|
'always',
|
|
33
33
|
{
|
|
34
34
|
ignorePackages: true,
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
|
-
'import/no-extraneous-dependencies': [
|
|
37
|
+
'import-x/no-extraneous-dependencies': [
|
|
38
38
|
'error',
|
|
39
39
|
{
|
|
40
40
|
devDependencies: [
|
|
@@ -54,18 +54,18 @@ export default [
|
|
|
54
54
|
],
|
|
55
55
|
},
|
|
56
56
|
],
|
|
57
|
-
'import/newline-after-import': 0,
|
|
58
|
-
'import/no-dynamic-require': 0,
|
|
59
|
-
'import/no-empty-named-blocks': 'error',
|
|
60
|
-
'import/no-relative-packages': 0,
|
|
61
|
-
'import/order': 0,
|
|
62
|
-
'import/prefer-default-export': 0,
|
|
63
|
-
'import/no-cycle': 0,
|
|
64
|
-
'import/no-duplicates': ['warn', { considerQueryString: true }],
|
|
57
|
+
'import-x/newline-after-import': 0,
|
|
58
|
+
'import-x/no-dynamic-require': 0,
|
|
59
|
+
'import-x/no-empty-named-blocks': 'error',
|
|
60
|
+
'import-x/no-relative-packages': 0,
|
|
61
|
+
'import-x/order': 0,
|
|
62
|
+
'import-x/prefer-default-export': 0,
|
|
63
|
+
'import-x/no-cycle': 0,
|
|
64
|
+
'import-x/no-duplicates': ['warn', { considerQueryString: true }],
|
|
65
65
|
},
|
|
66
66
|
settings: {
|
|
67
67
|
...Vscode,
|
|
68
|
-
'import/extensions': [
|
|
68
|
+
'import-x/extensions': [
|
|
69
69
|
'.tsx',
|
|
70
70
|
'.ts',
|
|
71
71
|
'.cts',
|
|
@@ -76,30 +76,22 @@ export default [
|
|
|
76
76
|
'.mjs',
|
|
77
77
|
'.cjs',
|
|
78
78
|
],
|
|
79
|
-
'import/parsers': {
|
|
79
|
+
'import-x/parsers': {
|
|
80
80
|
'@typescript-eslint/parser': ['.ts', '.cts', '.mts', '.tsx'],
|
|
81
81
|
'vue-eslint-parser': ['.vue'],
|
|
82
82
|
[fileURLToPath(import.meta.resolve('./jsx-parser.cjs'))]: ['.jsx'],
|
|
83
83
|
},
|
|
84
|
-
'import/ignore': false,
|
|
84
|
+
'import-x/ignore': false,
|
|
85
85
|
...configHas(
|
|
86
86
|
({ 'internal-regex': internalRegex }) => internalRegex,
|
|
87
|
-
(internalRegex) => ({ 'import/internal-regex': internalRegex }),
|
|
87
|
+
(internalRegex) => ({ 'import-x/internal-regex': internalRegex }),
|
|
88
88
|
),
|
|
89
|
-
'import/resolver': {
|
|
90
|
-
node: false,
|
|
91
|
-
[fileURLToPath(import.meta.resolve('./node-next-resolver.mjs'))]:
|
|
92
|
-
configHas(
|
|
93
|
-
({ 'import-http': importHttp }) => importHttp,
|
|
94
|
-
(importHttp) => ({ importHttp }),
|
|
95
|
-
) || {},
|
|
96
|
-
},
|
|
97
89
|
},
|
|
98
90
|
},
|
|
99
91
|
{
|
|
100
92
|
files: ['**/*.{js,jsx,ts,tsx,vue,qs,wxs}'],
|
|
101
93
|
rules: {
|
|
102
|
-
'import/no-nodejs-modules': 'error',
|
|
94
|
+
'import-x/no-nodejs-modules': 'error',
|
|
103
95
|
},
|
|
104
96
|
},
|
|
105
97
|
];
|
package/lib/markdown.mjs
CHANGED
|
@@ -23,8 +23,8 @@ export default [
|
|
|
23
23
|
'@typescript-eslint/no-extraneous-class': 'off',
|
|
24
24
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
25
25
|
'eol-last': 'off',
|
|
26
|
-
'import/no-extraneous-dependencies': 'off',
|
|
27
|
-
'import/no-unresolved': 'off',
|
|
26
|
+
'import-x/no-extraneous-dependencies': 'off',
|
|
27
|
+
'import-x/no-unresolved': 'off',
|
|
28
28
|
'n/no-missing-require': 'off',
|
|
29
29
|
'no-undef': 'off',
|
|
30
30
|
'no-unused-expressions': 'off',
|
package/lib/mini.mjs
CHANGED
|
@@ -104,7 +104,7 @@ function generate({
|
|
|
104
104
|
},
|
|
105
105
|
},
|
|
106
106
|
rules: {
|
|
107
|
-
'import/no-commonjs': 'off',
|
|
107
|
+
'import-x/no-commonjs': 'off',
|
|
108
108
|
'unicorn/prefer-module': 'off',
|
|
109
109
|
},
|
|
110
110
|
}
|
|
@@ -147,7 +147,7 @@ function generate({
|
|
|
147
147
|
},
|
|
148
148
|
},
|
|
149
149
|
rules: {
|
|
150
|
-
'import/no-commonjs': 0,
|
|
150
|
+
'import-x/no-commonjs': 0,
|
|
151
151
|
'no-var': 0,
|
|
152
152
|
'object-shorthand': ['error', 'never'],
|
|
153
153
|
'prefer-arrow-callback': 0,
|
package/lib/node.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice-move/eslint-config-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "A `eslint` config for best practice",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -41,14 +41,13 @@
|
|
|
41
41
|
"@nice-move/eslint-plugin-html": "^0.1.1",
|
|
42
42
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
43
43
|
"eslint-config-prettier": "^10.1.8",
|
|
44
|
-
"eslint-plugin-import": "^
|
|
44
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
45
45
|
"eslint-plugin-n": "^17.24.0",
|
|
46
46
|
"eslint-plugin-promise": "^7.2.1",
|
|
47
47
|
"eslint-plugin-regexp": "^3.1.0",
|
|
48
48
|
"eslint-plugin-unicorn": "^63.0.0",
|
|
49
49
|
"espree": "^10.4.0",
|
|
50
50
|
"globals": "^17.4.0",
|
|
51
|
-
"resolve.exports": "^2.0.3",
|
|
52
51
|
"settingz": "^0.2.0",
|
|
53
52
|
"typescript-eslint": "^8.57.0"
|
|
54
53
|
},
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url';
|
|
2
|
-
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { resolve as resolveExports } from 'resolve.exports';
|
|
5
|
-
import { builtinModules } from 'node:module';
|
|
6
|
-
import { readFileSync } from 'node:fs';
|
|
7
|
-
|
|
8
|
-
const withNodeLabel = builtinModules.map((item) => `node:${item}`);
|
|
9
|
-
|
|
10
|
-
const builtins = new Set([...builtinModules, ...withNodeLabel]);
|
|
11
|
-
|
|
12
|
-
function isValidUrl(string) {
|
|
13
|
-
try {
|
|
14
|
-
const io = new URL(string);
|
|
15
|
-
|
|
16
|
-
return ['http:', 'https:'].includes(io.protocol);
|
|
17
|
-
} catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const interfaceVersion = 2;
|
|
23
|
-
|
|
24
|
-
export const resolve = (source, file, config) => {
|
|
25
|
-
if (config.importHttp && isValidUrl(source)) {
|
|
26
|
-
return { found: true, path: null };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (/\.[cm][jt]s$/.test(file) && builtins.has(source)) {
|
|
30
|
-
return { found: true, path: null };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
const moduleId = fileURLToPath(
|
|
35
|
-
import.meta.resolve(source, { paths: [path.dirname(file)] }),
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
if (builtins.has(moduleId)) {
|
|
39
|
-
return { found: false };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return { found: true, path: moduleId };
|
|
43
|
-
} catch (error) {
|
|
44
|
-
if (
|
|
45
|
-
error.code === 'MODULE_NOT_FOUND' &&
|
|
46
|
-
error.path?.endsWith('/package.json')
|
|
47
|
-
) {
|
|
48
|
-
const { name, module, main, exports, imports } = JSON.parse(
|
|
49
|
-
readFileSync(error.path),
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
const [resolved] = resolveExports(
|
|
53
|
-
{ name, module, main, exports, imports },
|
|
54
|
-
source,
|
|
55
|
-
);
|
|
56
|
-
const moduleId = path.join(path.dirname(error.path), resolved);
|
|
57
|
-
|
|
58
|
-
return { found: true, path: moduleId };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return { found: false };
|
|
62
|
-
}
|
|
63
|
-
};
|