@sushichan044/eslint-config-array-resolver 0.1.2 → 0.1.4

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.
@@ -8,12 +8,6 @@ interface ESLintConfig {
8
8
  dependencies: string[];
9
9
  payload: Payload;
10
10
  }
11
- /**
12
- * Traverse and find the ESLint config file.
13
- *
14
- * @internal
15
- */
16
-
17
11
  interface ReadFlatConfigOptions {
18
12
  suppressOutput?: boolean;
19
13
  }
@@ -1,7 +1,7 @@
1
- import { bundleRequire } from "bundle-require";
2
1
  import { any } from "empathic/find";
3
2
  import { resolve } from "mlly";
4
- import { dirname } from "pathe";
3
+ import { dirname, normalize } from "pathe";
4
+ import { unrun } from "unrun";
5
5
  const runInDirectory = async (directory, function_) => {
6
6
  const cwd = process.cwd();
7
7
  process.chdir(directory);
@@ -56,25 +56,18 @@ const findConfigPath = (root) => {
56
56
  ], { cwd: root });
57
57
  if (!isNonEmptyString(configPath)) throw new Error("No eslint config found");
58
58
  return {
59
- basePath: dirname(configPath),
60
- fullPath: configPath
59
+ basePath: normalize(dirname(configPath)),
60
+ fullPath: normalize(configPath)
61
61
  };
62
62
  };
63
63
  const resolveFlatConfig = async (root, options = {}) => {
64
64
  const { suppressOutput = false } = options;
65
65
  const { basePath, fullPath } = findConfigPath(root);
66
- const moduleImportPromise = runInDirectory(basePath, async () => {
67
- return bundleRequire({
68
- cwd: basePath,
69
- filepath: fullPath,
70
- tsconfig: false
71
- });
72
- });
73
- const importPromise = suppressOutput ? executeWithSilentLogs(async () => moduleImportPromise) : moduleImportPromise;
74
- const { dependencies, mod } = await importPromise;
75
- const configModule = await (mod.default ?? mod);
66
+ const startImportConfig = async () => runInDirectory(basePath, async () => unrun({ path: fullPath }));
67
+ const { dependencies, module: configModule } = await (suppressOutput ? executeWithSilentLogs(startImportConfig) : startImportConfig());
76
68
  const rawConfigs = Array.isArray(configModule) ? configModule : [configModule];
77
69
  rawConfigs.unshift({
70
+ index: 1,
78
71
  languageOptions: {
79
72
  ecmaVersion: "latest",
80
73
  parserOptions: {},
@@ -84,12 +77,15 @@ const resolveFlatConfig = async (root, options = {}) => {
84
77
  name: "eslint/defaults/languages"
85
78
  }, {
86
79
  ignores: ["**/node_modules/", ".git/"],
80
+ index: 2,
87
81
  name: "eslint/defaults/ignores"
88
82
  }, {
89
83
  files: ["**/*.js", "**/*.mjs"],
84
+ index: 3,
90
85
  name: "eslint/defaults/files"
91
86
  }, {
92
87
  files: ["**/*.cjs"],
88
+ index: 4,
93
89
  languageOptions: {
94
90
  ecmaVersion: "latest",
95
91
  sourceType: "commonjs"
@@ -97,8 +93,7 @@ const resolveFlatConfig = async (root, options = {}) => {
97
93
  name: "eslint/defaults/files-cjs"
98
94
  });
99
95
  const rulesMap = /* @__PURE__ */ new Map();
100
- const eslintPath = await resolve("eslint/use-at-your-own-risk", { url: basePath }).catch(() => null) ?? "eslint/use-at-your-own-risk";
101
- const eslintRules = await import(eslintPath).then((r) => r.default.builtinRules);
96
+ const eslintRules = await import(await resolve("eslint/use-at-your-own-risk", { url: basePath }).catch(() => null) ?? "eslint/use-at-your-own-risk").then((r) => r.default.builtinRules);
102
97
  for (const [name, rule] of eslintRules.entries()) rulesMap.set(name, {
103
98
  ...rule.meta,
104
99
  messages: void 0,
@@ -114,32 +109,30 @@ const resolveFlatConfig = async (root, options = {}) => {
114
109
  schema: void 0
115
110
  });
116
111
  const rules = Object.fromEntries(rulesMap.entries());
117
- const configs = rawConfigs.map((c, index) => {
118
- return {
119
- ...c,
120
- index,
121
- languageOptions: c.languageOptions ? {
122
- ...c.languageOptions,
123
- parser: c.languageOptions.parser?.meta?.name
124
- } : void 0,
125
- plugins: c.plugins ? Object.fromEntries(Object.entries(c.plugins ?? {}).map(([prefix]) => [prefix, {}]).filter((index_) => index_[0])) : void 0,
126
- processor: c.processor?.meta?.name
127
- };
128
- });
129
- const payload = {
130
- configs,
131
- files: null,
132
- meta: {
133
- basePath,
134
- configPath: fullPath,
135
- lastUpdate: Date.now()
136
- },
137
- rules
138
- };
139
112
  return {
140
113
  configs: rawConfigs,
141
114
  dependencies,
142
- payload
115
+ payload: {
116
+ configs: rawConfigs.map((c, index) => {
117
+ return {
118
+ ...c,
119
+ index,
120
+ languageOptions: c.languageOptions ? {
121
+ ...c.languageOptions,
122
+ parser: c.languageOptions.parser?.meta?.name
123
+ } : void 0,
124
+ plugins: c.plugins ? Object.fromEntries(Object.entries(c.plugins ?? {}).map(([prefix]) => [prefix, {}]).filter((index_) => index_[0])) : void 0,
125
+ processor: c.processor?.meta?.name
126
+ };
127
+ }),
128
+ files: null,
129
+ meta: {
130
+ basePath,
131
+ configPath: fullPath,
132
+ lastUpdate: Date.now()
133
+ },
134
+ rules
135
+ }
143
136
  };
144
137
  };
145
138
  export { resolveFlatConfig };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sushichan044/eslint-config-array-resolver",
3
3
  "description": "Resolves flat config module. For internal use only.",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "author": {
@@ -18,46 +18,42 @@
18
18
  "registry": "https://registry.npmjs.org/",
19
19
  "provenance": true
20
20
  },
21
- "main": "dist/index.js",
22
- "module": "dist/index.js",
23
- "types": "dist/index.d.ts",
24
21
  "files": [
25
22
  "dist"
26
23
  ],
27
24
  "exports": {
28
25
  ".": {
29
- "types": "./dist/index.d.ts",
30
- "import": "./dist/index.js"
26
+ "types": "./dist/index.d.mts",
27
+ "import": "./dist/index.mjs"
31
28
  }
32
29
  },
33
30
  "devDependencies": {
34
- "@arethetypeswrong/cli": "0.18.2",
35
- "@biomejs/biome": "2.1.2",
36
- "@types/node": "24.1.0",
37
- "@virtual-live-lab/eslint-config": "2.2.24",
38
- "@virtual-live-lab/tsconfig": "2.1.21",
39
- "eslint": "9.31.0",
40
- "fs-fixture": "2.8.1",
41
- "publint": "0.3.12",
42
- "tsdown": "0.13.0",
43
- "typescript": "5.8.3",
44
- "typescript-eslint": "8.38.0",
45
- "unplugin-unused": "0.5.1",
46
- "vitest": "3.2.4"
31
+ "@arethetypeswrong/core": "^0.18.2",
32
+ "@biomejs/biome": "^2.3.4",
33
+ "@types/node": "^24.10.0",
34
+ "@virtual-live-lab/eslint-config": "^2.3.1",
35
+ "@virtual-live-lab/tsconfig": "^2.1.21",
36
+ "eslint": "^9.39.1",
37
+ "fs-fixture": "^2.10.1",
38
+ "publint": "^0.3.15",
39
+ "tsdown": "^0.16.1",
40
+ "typescript": "^5.9.3",
41
+ "typescript-eslint": "^8.46.4",
42
+ "unplugin-unused": "^0.5.6",
43
+ "vitest": "^4.0.8"
47
44
  },
48
45
  "dependencies": {
49
- "@typescript-eslint/utils": "^8.0.0",
50
- "bundle-require": "^5.1.0",
46
+ "@typescript-eslint/utils": "^8.46.4",
51
47
  "empathic": "^2.0.0",
52
- "mlly": "^1.7.4",
53
- "pathe": "^2.0.3"
48
+ "mlly": "^1.8.0",
49
+ "pathe": "^2.0.3",
50
+ "unrun": "^0.2.7"
54
51
  },
55
52
  "scripts": {
56
53
  "lint": "eslint --max-warnings 0 --fix .",
57
54
  "format": "biome format --write .",
58
55
  "typecheck": "tsc --noEmit",
59
56
  "test": "vitest --run",
60
- "build": "tsdown",
61
- "build:check": "pnpm run build && pnpm pack && attw"
57
+ "build": "tsdown"
62
58
  }
63
59
  }