@nice-move/eslint-config-base 0.13.26 → 0.13.27

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.mjs CHANGED
@@ -88,7 +88,7 @@ export default [
88
88
  ),
89
89
  'import/resolver': {
90
90
  node: false,
91
- [fileURLToPath(import.meta.resolve('./node-next-resolver.cjs'))]:
91
+ [fileURLToPath(import.meta.resolve('./node-next-resolver.mjs'))]:
92
92
  configHas(
93
93
  ({ 'import-http': importHttp }) => importHttp,
94
94
  (importHttp) => ({ importHttp }),
@@ -0,0 +1,63 @@
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-move/eslint-config-base",
3
- "version": "0.13.26",
3
+ "version": "0.13.27",
4
4
  "description": "A `eslint` config for best practice",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -35,8 +35,8 @@
35
35
  "type": "module",
36
36
  "dependencies": {
37
37
  "@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
38
- "@eslint/eslintrc": "^3.3.4",
39
- "@eslint/js": "^9.39.3",
38
+ "@eslint/eslintrc": "^3.3.5",
39
+ "@eslint/js": "^9.39.4",
40
40
  "@eslint/markdown": "^7.5.1",
41
41
  "@nice-move/eslint-plugin-html": "^0.1.1",
42
42
  "eslint-config-airbnb-base": "^15.0.0",
@@ -44,16 +44,16 @@
44
44
  "eslint-plugin-import": "^2.32.0",
45
45
  "eslint-plugin-n": "^17.24.0",
46
46
  "eslint-plugin-promise": "^7.2.1",
47
- "eslint-plugin-regexp": "^3.0.0",
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
51
  "resolve.exports": "^2.0.3",
52
52
  "settingz": "^0.2.0",
53
- "typescript-eslint": "^8.56.1"
53
+ "typescript-eslint": "^8.57.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "eslint": "^9.39.3"
56
+ "eslint": "^9.39.4"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=24.0.0 || ^22.18.0"
@@ -1,59 +0,0 @@
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
- function isValidUrl(string) {
12
- try {
13
- const io = new URL(string);
14
-
15
- return ['http:', 'https:'].includes(io.protocol);
16
- } catch {
17
- return false;
18
- }
19
- }
20
-
21
- module.exports = {
22
- interfaceVersion: 2,
23
- resolve: (source, file, config) => {
24
- if (config.importHttp && isValidUrl(source)) {
25
- return { found: true, path: null };
26
- }
27
-
28
- if (/\.[cm][jt]s$/.test(file) && builtins.has(source)) {
29
- return { found: true, path: null };
30
- }
31
-
32
- try {
33
- const moduleId = require.resolve(source, { paths: [path.dirname(file)] });
34
-
35
- if (builtins.has(moduleId)) {
36
- return { found: false };
37
- }
38
-
39
- return { found: true, path: moduleId };
40
- } catch (error) {
41
- if (
42
- error.code === 'MODULE_NOT_FOUND' &&
43
- error.path?.endsWith('/package.json')
44
- ) {
45
- const { name, module, main, exports, imports } = require(error.path);
46
-
47
- const [resolved] = resolveExports(
48
- { name, module, main, exports, imports },
49
- source,
50
- );
51
- const moduleId = path.join(path.dirname(error.path), resolved);
52
-
53
- return { found: true, path: moduleId };
54
- }
55
-
56
- return { found: false };
57
- }
58
- },
59
- };