@nice-move/eslint-config-base 0.8.9 → 0.8.12

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/lib/import.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { join } = require('path');
3
+ const { join } = require('node:path');
4
4
  const { pkgHas, configHas } = require('./utils.cjs');
5
5
 
6
6
  const Vscode = pkgHas(
@@ -44,9 +44,19 @@ module.exports = {
44
44
  },
45
45
  settings: {
46
46
  ...Vscode,
47
- 'import/extensions': ['.tsx', '.ts', '.vue', '.jsx', '.js', '.mjs', '.cjs'],
47
+ 'import/extensions': [
48
+ '.tsx',
49
+ '.ts',
50
+ '.cts',
51
+ '.mts',
52
+ '.vue',
53
+ '.jsx',
54
+ '.js',
55
+ '.mjs',
56
+ '.cjs',
57
+ ],
48
58
  'import/parsers': {
49
- '@typescript-eslint/parser': ['.ts', '.tsx'],
59
+ '@typescript-eslint/parser': ['.ts', '.cts', '.mts', '.tsx'],
50
60
  'vue-eslint-parser': ['.vue'],
51
61
  [require.resolve('./jsx-parser.cjs')]: ['.jsx'],
52
62
  },
@@ -55,6 +65,10 @@ module.exports = {
55
65
  ({ 'internal-regex': internalRegex }) => internalRegex,
56
66
  (internalRegex) => ({ 'import/internal-regex': internalRegex }),
57
67
  ),
68
+ 'import/resolver': {
69
+ node: false,
70
+ [require.resolve('./node-next-resolver.cjs')]: {},
71
+ },
58
72
  },
59
73
  overrides: [
60
74
  pkgHas(
@@ -71,7 +85,7 @@ module.exports = {
71
85
  ),
72
86
  {
73
87
  files: '**/*.*',
74
- excludedFiles: '*.{m,c}js',
88
+ excludedFiles: '*.{m,c}{j,t}s',
75
89
  rules: {
76
90
  'import/no-nodejs-modules': 'error',
77
91
  },
package/lib/mini.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { relative } = require('path');
3
+ const { relative } = require('node:path');
4
4
  const { reaching } = require('settingz');
5
5
 
6
6
  const cwd = process.cwd();
@@ -122,6 +122,35 @@ function generate({ miniprogramRoot, pluginRoot, cloudfunctionRoot }) {
122
122
  'unicorn/prefer-module': 0,
123
123
  },
124
124
  },
125
+ {
126
+ files: '*.js',
127
+ rules: {
128
+ 'n/file-extension-in-import': [
129
+ 'error',
130
+ 'always',
131
+ {
132
+ '.ts': 'never',
133
+ },
134
+ ],
135
+ 'import/extensions': [
136
+ 'error',
137
+ 'always',
138
+ {
139
+ ignorePackages: true,
140
+ pattern: {
141
+ ts: 'never',
142
+ },
143
+ },
144
+ ],
145
+ },
146
+ settings: {
147
+ 'import/resolver': {
148
+ node: {
149
+ extensions: ['.ts'],
150
+ },
151
+ },
152
+ },
153
+ },
125
154
  ].filter(Boolean);
126
155
  }
127
156
 
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ const path = require('node:path');
4
+ const { resolve: resolveExports } = require('resolve.exports');
5
+ const { builtinModules } = require('node:module');
6
+
7
+ const withNodeLabel = builtinModules.map((item) => `node:${item}`);
8
+
9
+ const builtins = new Set([...builtinModules, ...withNodeLabel]);
10
+
11
+ module.exports = {
12
+ interfaceVersion: 2,
13
+ resolve: (source, file) => {
14
+ if (/\.[cm][jt]s$/.test(file) && builtins.has(source)) {
15
+ return { found: true, path: null };
16
+ }
17
+
18
+ try {
19
+ const moduleId = require.resolve(source, { paths: [path.dirname(file)] });
20
+
21
+ if (builtins.has(moduleId)) {
22
+ return { found: false };
23
+ }
24
+
25
+ return { found: true, path: moduleId };
26
+ } catch (error) {
27
+ if (
28
+ error.code === 'MODULE_NOT_FOUND' &&
29
+ error.path?.endsWith('/package.json')
30
+ ) {
31
+ const { name, module, main, exports } = require(error.path);
32
+
33
+ const resolved = resolveExports(
34
+ { name, module, main, exports },
35
+ source,
36
+ );
37
+ const moduleId = path.join(path.dirname(error.path), resolved);
38
+
39
+ return { found: true, path: moduleId };
40
+ }
41
+
42
+ return { found: false };
43
+ }
44
+ },
45
+ };
@@ -39,6 +39,26 @@ module.exports = {
39
39
  varsIgnorePattern: '^_+$',
40
40
  },
41
41
  ],
42
+ 'import/extensions': [
43
+ 'error',
44
+ 'always',
45
+ {
46
+ ignorePackages: true,
47
+ pattern: {
48
+ ts: 'never',
49
+ mts: 'never',
50
+ cts: 'never',
51
+ tsx: 'never',
52
+ },
53
+ },
54
+ ],
55
+ },
56
+ settings: {
57
+ 'import/resolver': {
58
+ node: {
59
+ extensions: ['.ts', '.cts', '.mts', '.tsx'],
60
+ },
61
+ },
42
62
  },
43
63
  },
44
64
  ],
package/lib/unicorn.cjs CHANGED
@@ -15,7 +15,6 @@ module.exports = {
15
15
  { onlyIfContainsSeparator: true },
16
16
  ],
17
17
  'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: true }],
18
- 'unicorn/prefer-node-protocol': 'off',
19
18
  'unicorn/prefer-prototype-methods': 'off',
20
19
  'unicorn/prefer-set-has': 'off',
21
20
  'unicorn/prefer-top-level-await': 'off',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-move/eslint-config-base",
3
- "version": "0.8.9",
3
+ "version": "0.8.12",
4
4
  "description": "A `eslint` config for best practice",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -47,10 +47,11 @@
47
47
  "eslint-plugin-sonarjs": "^0.15.0",
48
48
  "eslint-plugin-unicorn": "^43.0.2",
49
49
  "espree": "^9.4.0",
50
+ "resolve.exports": "^1.1.0",
50
51
  "settingz": "^0.2.0"
51
52
  },
52
53
  "peerDependencies": {
53
- "eslint": "^8.16.0"
54
+ "eslint": "^8.20.0"
54
55
  },
55
56
  "engines": {
56
57
  "node": "^16.13.0 || >=18.0.0"