@nekoyasuii/config 0.1.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.
Files changed (37) hide show
  1. package/README.md +1 -0
  2. package/dist/chunk-41590bpf.js +70 -0
  3. package/dist/chunk-5wgwscd0.js +4 -0
  4. package/dist/chunk-8m4by0h8.js +138 -0
  5. package/dist/chunk-c8jq73qx.js +38 -0
  6. package/dist/chunk-xmts0xe5.js +565 -0
  7. package/dist/chunk-y56m56wh.js +430 -0
  8. package/dist/tools/oxfmt/index.d.ts +36 -0
  9. package/dist/tools/oxfmt/index.js +56 -0
  10. package/dist/tools/oxlint/config/anti-slop/index.d.ts +27 -0
  11. package/dist/tools/oxlint/config/anti-slop/index.js +7 -0
  12. package/dist/tools/oxlint/config/anti-slop/plugin.d.ts +2 -0
  13. package/dist/tools/oxlint/config/anti-slop/plugin.js +1944 -0
  14. package/dist/tools/oxlint/config/core/index.d.ts +558 -0
  15. package/dist/tools/oxlint/config/core/index.js +8 -0
  16. package/dist/tools/oxlint/config/index.d.ts +774 -0
  17. package/dist/tools/oxlint/config/index.js +57 -0
  18. package/dist/tools/oxlint/config/js-plugins/index.d.ts +446 -0
  19. package/dist/tools/oxlint/config/js-plugins/index.js +11 -0
  20. package/dist/tools/oxlint/config/react/index.d.ts +131 -0
  21. package/dist/tools/oxlint/config/react/index.js +7 -0
  22. package/dist/tools/oxlint/config/remix/index.d.ts +11 -0
  23. package/dist/tools/oxlint/config/remix/index.js +19 -0
  24. package/dist/tools/oxlint/config/tanstack/index.d.ts +17 -0
  25. package/dist/tools/oxlint/config/tanstack/index.js +25 -0
  26. package/dist/tools/oxlint/config/tanstack/js-plugins/index.d.ts +30 -0
  27. package/dist/tools/oxlint/config/tanstack/js-plugins/index.js +33 -0
  28. package/dist/tools/oxlint/rules/index.d.ts +2 -0
  29. package/dist/tools/oxlint/rules/index.js +482 -0
  30. package/dist/tools/shared/ignores.d.ts +1 -0
  31. package/dist/tools/shared/ignores.js +7 -0
  32. package/dist/tools/shared/tsconfig-aliases.d.ts +11 -0
  33. package/dist/tools/shared/types.d.ts +1 -0
  34. package/package.json +114 -0
  35. package/tsconfig.json +12 -0
  36. package/tsconfig.node.json +30 -0
  37. package/tsconfig.react.json +30 -0
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ overrides: {
3
+ files: string[];
4
+ rules: {
5
+ "unicorn/filename-case": "off";
6
+ "unicorn/no-abusive-eslint-disable": "off";
7
+ };
8
+ }[];
9
+ rules: {};
10
+ };
11
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import"../../../../chunk-5wgwscd0.js";
2
+
3
+ // tools/oxlint/config/remix/index.ts
4
+ import { defineConfig } from "oxlint";
5
+ var remix_default = defineConfig({
6
+ overrides: [
7
+ {
8
+ files: ["**/routeTree.gen.ts"],
9
+ rules: {
10
+ "unicorn/filename-case": "off",
11
+ "unicorn/no-abusive-eslint-disable": "off"
12
+ }
13
+ }
14
+ ],
15
+ rules: {}
16
+ });
17
+ export {
18
+ remix_default as default
19
+ };
@@ -0,0 +1,17 @@
1
+ export declare const tanstackConfig: {
2
+ overrides: ({
3
+ files: string[];
4
+ rules: {
5
+ "sort-keys": "off";
6
+ "unicorn/filename-case": "off";
7
+ "unicorn/no-abusive-eslint-disable"?: undefined;
8
+ };
9
+ } | {
10
+ files: string[];
11
+ rules: {
12
+ "sort-keys"?: undefined;
13
+ "unicorn/filename-case": "off";
14
+ "unicorn/no-abusive-eslint-disable": "off";
15
+ };
16
+ })[];
17
+ };
@@ -0,0 +1,25 @@
1
+ import"../../../../chunk-5wgwscd0.js";
2
+
3
+ // tools/oxlint/config/tanstack/index.ts
4
+ import { defineConfig } from "oxlint";
5
+ var tanstackConfig = defineConfig({
6
+ overrides: [
7
+ {
8
+ files: ["**/routes/**/*.{tsx,ts}", "**/app/routes/**/*.{tsx,ts}"],
9
+ rules: {
10
+ "sort-keys": "off",
11
+ "unicorn/filename-case": "off"
12
+ }
13
+ },
14
+ {
15
+ files: ["**/routeTree.gen.ts"],
16
+ rules: {
17
+ "unicorn/filename-case": "off",
18
+ "unicorn/no-abusive-eslint-disable": "off"
19
+ }
20
+ }
21
+ ]
22
+ });
23
+ export {
24
+ tanstackConfig
25
+ };
@@ -0,0 +1,30 @@
1
+ declare const _default: {
2
+ jsPlugins: {
3
+ name: string;
4
+ specifier: string;
5
+ }[];
6
+ rules: {
7
+ "react-doctor/query-destructure-result": "error";
8
+ "react-doctor/query-mutation-missing-invalidation": "error";
9
+ "react-doctor/query-no-query-in-effect": "error";
10
+ "react-doctor/query-no-rest-destructuring": "error";
11
+ "react-doctor/query-no-usequery-for-mutation": "error";
12
+ "react-doctor/query-no-void-query-fn": "error";
13
+ "react-doctor/query-stable-query-client": "error";
14
+ "react-doctor/tanstack-start-get-mutation": "error";
15
+ "react-doctor/tanstack-start-loader-parallel-fetch": "error";
16
+ "react-doctor/tanstack-start-missing-head-content": "error";
17
+ "react-doctor/tanstack-start-no-anchor-element": "error";
18
+ "react-doctor/tanstack-start-no-direct-fetch-in-loader": "error";
19
+ "react-doctor/tanstack-start-no-dynamic-server-fn-import": "error";
20
+ "react-doctor/tanstack-start-no-navigate-in-render": "error";
21
+ "react-doctor/tanstack-start-no-secrets-in-loader": "error";
22
+ "react-doctor/tanstack-start-no-use-server-in-handler": "error";
23
+ "react-doctor/tanstack-start-no-useeffect-fetch": "error";
24
+ "react-doctor/tanstack-start-redirect-in-try-catch": "error";
25
+ "react-doctor/tanstack-start-route-property-order": "error";
26
+ "react-doctor/tanstack-start-server-fn-method-order": "error";
27
+ "react-doctor/tanstack-start-server-fn-validate-input": "error";
28
+ };
29
+ };
30
+ export default _default;
@@ -0,0 +1,33 @@
1
+ import"../../../../../chunk-5wgwscd0.js";
2
+
3
+ // tools/oxlint/config/tanstack/js-plugins/index.ts
4
+ import { defineConfig } from "oxlint";
5
+ var js_plugins_default = defineConfig({
6
+ jsPlugins: [{ name: "react-doctor", specifier: "oxlint-plugin-react-doctor" }],
7
+ rules: {
8
+ "react-doctor/query-destructure-result": "error",
9
+ "react-doctor/query-mutation-missing-invalidation": "error",
10
+ "react-doctor/query-no-query-in-effect": "error",
11
+ "react-doctor/query-no-rest-destructuring": "error",
12
+ "react-doctor/query-no-usequery-for-mutation": "error",
13
+ "react-doctor/query-no-void-query-fn": "error",
14
+ "react-doctor/query-stable-query-client": "error",
15
+ "react-doctor/tanstack-start-get-mutation": "error",
16
+ "react-doctor/tanstack-start-loader-parallel-fetch": "error",
17
+ "react-doctor/tanstack-start-missing-head-content": "error",
18
+ "react-doctor/tanstack-start-no-anchor-element": "error",
19
+ "react-doctor/tanstack-start-no-direct-fetch-in-loader": "error",
20
+ "react-doctor/tanstack-start-no-dynamic-server-fn-import": "error",
21
+ "react-doctor/tanstack-start-no-navigate-in-render": "error",
22
+ "react-doctor/tanstack-start-no-secrets-in-loader": "error",
23
+ "react-doctor/tanstack-start-no-use-server-in-handler": "error",
24
+ "react-doctor/tanstack-start-no-useeffect-fetch": "error",
25
+ "react-doctor/tanstack-start-redirect-in-try-catch": "error",
26
+ "react-doctor/tanstack-start-route-property-order": "error",
27
+ "react-doctor/tanstack-start-server-fn-method-order": "error",
28
+ "react-doctor/tanstack-start-server-fn-validate-input": "error"
29
+ }
30
+ });
31
+ export {
32
+ js_plugins_default as default
33
+ };
@@ -0,0 +1,2 @@
1
+ declare const plugin: import("@oxlint/plugins").Plugin;
2
+ export default plugin;
@@ -0,0 +1,482 @@
1
+ import"../../../chunk-5wgwscd0.js";
2
+
3
+ // node_modules/@oxlint/plugins/index.js
4
+ function definePlugin(plugin) {
5
+ return plugin;
6
+ }
7
+ function defineRule(rule) {
8
+ return rule;
9
+ }
10
+ var FILE_CONTEXT = Object.freeze({
11
+ get filename() {
12
+ throw Error("Cannot access `context.filename` in `createOnce`");
13
+ },
14
+ getFilename() {
15
+ throw Error("Cannot call `context.getFilename` in `createOnce`");
16
+ },
17
+ get physicalFilename() {
18
+ throw Error("Cannot access `context.physicalFilename` in `createOnce`");
19
+ },
20
+ getPhysicalFilename() {
21
+ throw Error("Cannot call `context.getPhysicalFilename` in `createOnce`");
22
+ },
23
+ get cwd() {
24
+ throw Error("Cannot access `context.cwd` in `createOnce`");
25
+ },
26
+ getCwd() {
27
+ throw Error("Cannot call `context.getCwd` in `createOnce`");
28
+ },
29
+ get sourceCode() {
30
+ throw Error("Cannot access `context.sourceCode` in `createOnce`");
31
+ },
32
+ getSourceCode() {
33
+ throw Error("Cannot call `context.getSourceCode` in `createOnce`");
34
+ },
35
+ get languageOptions() {
36
+ throw Error("Cannot access `context.languageOptions` in `createOnce`");
37
+ },
38
+ get settings() {
39
+ throw Error("Cannot access `context.settings` in `createOnce`");
40
+ },
41
+ extend(extension) {
42
+ return Object.freeze(Object.assign(Object.create(this), extension));
43
+ },
44
+ get parserOptions() {
45
+ throw Error("Cannot access `context.parserOptions` in `createOnce`");
46
+ },
47
+ get parserPath() {
48
+ throw Error("Cannot access `context.parserPath` in `createOnce`");
49
+ }
50
+ });
51
+
52
+ // tools/oxlint/rules/prefer-alias/rule.ts
53
+ import fs2 from "node:fs";
54
+ import path2 from "node:path";
55
+
56
+ // tools/shared/tsconfig-aliases.ts
57
+ import fs from "node:fs";
58
+ import path from "node:path";
59
+ var emptyConfig = { aliasPatterns: {}, basePath: "" };
60
+ function readStringLiteral(source, start) {
61
+ let index = start + 1;
62
+ while (index < source.length) {
63
+ const char = source[index];
64
+ if (char === "\\") {
65
+ index += 2;
66
+ continue;
67
+ }
68
+ index += 1;
69
+ if (char === `"`)
70
+ break;
71
+ }
72
+ return index;
73
+ }
74
+ function skipComment(source, index) {
75
+ const char = source[index];
76
+ const next = source[index + 1];
77
+ if (char !== "/" || next !== "/" && next !== "*")
78
+ return index;
79
+ if (next === "/") {
80
+ let end2 = index + 2;
81
+ while (end2 < source.length && source[end2] !== `
82
+ `)
83
+ end2 += 1;
84
+ return end2;
85
+ }
86
+ let end = index + 2;
87
+ while (end < source.length && !(source[end] === "*" && source[end + 1] === "/"))
88
+ end += 1;
89
+ return end + 2;
90
+ }
91
+ function skipWhitespace(source, index) {
92
+ let end = index;
93
+ while (end < source.length && /\s/u.test(source[end]))
94
+ end += 1;
95
+ return end;
96
+ }
97
+ function closesCollection(source, index) {
98
+ const next = source[skipWhitespace(source, index)];
99
+ return next === "}" || next === "]";
100
+ }
101
+ function stripJsonComments(source) {
102
+ const { length } = source;
103
+ const parts = [];
104
+ let chunkStart = 0;
105
+ let index = 0;
106
+ while (index < length) {
107
+ const char = source[index];
108
+ if (char === `"`) {
109
+ index = readStringLiteral(source, index);
110
+ continue;
111
+ }
112
+ const commentEnd = skipComment(source, index);
113
+ if (commentEnd !== index) {
114
+ parts.push(source.slice(chunkStart, index));
115
+ index = commentEnd;
116
+ chunkStart = index;
117
+ continue;
118
+ }
119
+ if (char === "," && closesCollection(source, index + 1)) {
120
+ parts.push(source.slice(chunkStart, index));
121
+ index += 1;
122
+ chunkStart = index;
123
+ continue;
124
+ }
125
+ index += 1;
126
+ }
127
+ parts.push(source.slice(chunkStart));
128
+ return parts.join("");
129
+ }
130
+ function resolveExtendsPath(fromFile, parent) {
131
+ if (!parent.startsWith(".") && !path.isAbsolute(parent)) {
132
+ return null;
133
+ }
134
+ const resolved = path.resolve(path.dirname(fromFile), parent);
135
+ if (fs.existsSync(resolved))
136
+ return resolved;
137
+ const withExtension = `${resolved.replace(/\.json$/u, "")}.json`;
138
+ return fs.existsSync(withExtension) ? withExtension : null;
139
+ }
140
+ function parseTsConfigFile(filePath, seen) {
141
+ if (seen.has(filePath))
142
+ return {};
143
+ seen.add(filePath);
144
+ const parsed = JSON.parse(stripJsonComments(fs.readFileSync(filePath, "utf-8")));
145
+ const parents = typeof parsed.extends === "string" ? [parsed.extends] : parsed.extends ?? [];
146
+ let merged = {};
147
+ for (const parent of parents) {
148
+ const parentPath = resolveExtendsPath(filePath, parent);
149
+ if (!parentPath)
150
+ continue;
151
+ merged = parseTsConfigFile(parentPath, seen);
152
+ }
153
+ return {
154
+ ...merged,
155
+ ...parsed,
156
+ compilerOptions: { ...merged.compilerOptions, ...parsed.compilerOptions }
157
+ };
158
+ }
159
+ var configCache = new Map;
160
+ function loadTsConfigAliases(cwd) {
161
+ const tsconfigPath = path.resolve(cwd, "tsconfig.json");
162
+ if (!fs.existsSync(tsconfigPath))
163
+ return emptyConfig;
164
+ try {
165
+ const mtime = fs.statSync(tsconfigPath).mtimeMs;
166
+ const cached = configCache.get(tsconfigPath);
167
+ if (cached && cached.mtime === mtime)
168
+ return cached.config;
169
+ const tsconfig = parseTsConfigFile(tsconfigPath, new Set);
170
+ const config = {
171
+ aliasPatterns: tsconfig.compilerOptions?.paths ?? {},
172
+ basePath: path.resolve(path.dirname(tsconfigPath), tsconfig.compilerOptions?.baseUrl ?? ".")
173
+ };
174
+ configCache.set(tsconfigPath, { mtime, config });
175
+ return config;
176
+ } catch (error) {
177
+ console.error(`prefer-alias: could not read ${tsconfigPath}: ${String(error)}`);
178
+ return emptyConfig;
179
+ }
180
+ }
181
+
182
+ // tools/oxlint/rules/prefer-alias/rule.ts
183
+ var moduleExtensions = [
184
+ ".ts",
185
+ ".tsx",
186
+ ".mts",
187
+ ".cts",
188
+ ".js",
189
+ ".jsx",
190
+ ".mjs",
191
+ ".cjs",
192
+ ".json"
193
+ ];
194
+ var fileCheckCache = new Map;
195
+ function isFile(absolutePath) {
196
+ const cached = fileCheckCache.get(absolutePath);
197
+ if (cached !== undefined)
198
+ return cached;
199
+ let exists;
200
+ try {
201
+ exists = fs2.statSync(absolutePath).isFile();
202
+ } catch {
203
+ exists = false;
204
+ }
205
+ fileCheckCache.set(absolutePath, exists);
206
+ return exists;
207
+ }
208
+ var resolutionCache = new Map;
209
+ function resolveModulePath(absolutePath) {
210
+ const cached = resolutionCache.get(absolutePath);
211
+ if (cached !== undefined)
212
+ return cached;
213
+ let resolved = null;
214
+ if (isFile(absolutePath))
215
+ resolved = absolutePath;
216
+ else {
217
+ for (const extension of moduleExtensions) {
218
+ if (isFile(`${absolutePath}${extension}`)) {
219
+ resolved = `${absolutePath}${extension}`;
220
+ break;
221
+ }
222
+ }
223
+ }
224
+ if (!resolved) {
225
+ for (const extension of moduleExtensions) {
226
+ const candidate = path2.join(absolutePath, `index${extension}`);
227
+ if (isFile(candidate)) {
228
+ resolved = candidate;
229
+ break;
230
+ }
231
+ }
232
+ }
233
+ resolutionCache.set(absolutePath, resolved);
234
+ return resolved;
235
+ }
236
+ function capturePathRemainder(absolutePath, basePath, pathPattern) {
237
+ const wildcardIndex = pathPattern.indexOf("*");
238
+ if (wildcardIndex === -1)
239
+ return absolutePath === path2.resolve(basePath, pathPattern) ? "" : null;
240
+ const head = pathPattern.slice(0, wildcardIndex);
241
+ const tail = pathPattern.slice(wildcardIndex + 1);
242
+ const resolvedHead = path2.normalize(path2.resolve(basePath, head));
243
+ const prefix = resolvedHead.endsWith(path2.sep) ? resolvedHead : `${resolvedHead}${path2.sep}`;
244
+ if (!absolutePath.startsWith(prefix))
245
+ return null;
246
+ let remainder = absolutePath.slice(prefix.length);
247
+ if (tail) {
248
+ if (!remainder.endsWith(tail) || remainder.length === tail.length)
249
+ return null;
250
+ remainder = remainder.slice(0, remainder.length - tail.length);
251
+ }
252
+ return remainder.replaceAll(path2.sep, "/");
253
+ }
254
+ function collectAliasCandidates(absolutePath, basePath, aliasPatterns) {
255
+ const candidates = [];
256
+ for (const [aliasPattern, pathPatterns] of Object.entries(aliasPatterns)) {
257
+ const aliasWildcard = aliasPattern.indexOf("*");
258
+ for (const pathPattern of pathPatterns) {
259
+ const remainder = capturePathRemainder(absolutePath, basePath, pathPattern);
260
+ if (remainder === null)
261
+ continue;
262
+ if (aliasWildcard === -1) {
263
+ if (remainder === "")
264
+ candidates.push(aliasPattern);
265
+ continue;
266
+ }
267
+ candidates.push(aliasPattern.slice(0, aliasWildcard) + remainder);
268
+ }
269
+ }
270
+ return candidates;
271
+ }
272
+ function findBestAliasMatch(absolutePath, basePath, aliasPatterns) {
273
+ const candidates = collectAliasCandidates(absolutePath, basePath, aliasPatterns);
274
+ let shortest = null;
275
+ for (const candidate of candidates)
276
+ if (shortest === null || candidate.length < shortest.length)
277
+ shortest = candidate;
278
+ return shortest;
279
+ }
280
+ function findAliasTarget(importPath, basePath, aliasPatterns) {
281
+ const candidates = [];
282
+ for (const [aliasPattern, pathPatterns] of Object.entries(aliasPatterns)) {
283
+ const aliasWildcard = aliasPattern.indexOf("*");
284
+ if (aliasWildcard === -1) {
285
+ if (importPath === aliasPattern) {
286
+ const [pathPattern] = pathPatterns;
287
+ if (pathPattern)
288
+ candidates.push(path2.resolve(basePath, pathPattern));
289
+ }
290
+ continue;
291
+ }
292
+ const aliasBase = aliasPattern.slice(0, aliasWildcard);
293
+ if (!importPath.startsWith(aliasBase))
294
+ continue;
295
+ const remainder = importPath.slice(aliasBase.length);
296
+ for (const pathPattern of pathPatterns) {
297
+ const pathWildcardIndex = pathPattern.indexOf("*");
298
+ if (pathWildcardIndex === -1)
299
+ continue;
300
+ candidates.push(path2.resolve(basePath, `${pathPattern.slice(0, pathWildcardIndex)}${remainder}${pathPattern.slice(pathWildcardIndex + 1)}`));
301
+ }
302
+ }
303
+ if (candidates.length === 0)
304
+ return null;
305
+ return candidates.find((candidate) => resolveModulePath(candidate)) ?? candidates[0];
306
+ }
307
+ function matchesAliasPattern(importPath, aliasPatterns) {
308
+ for (const aliasPattern of Object.keys(aliasPatterns)) {
309
+ const wildcardIndex = aliasPattern.indexOf("*");
310
+ if (wildcardIndex === -1) {
311
+ if (importPath === aliasPattern)
312
+ return true;
313
+ continue;
314
+ }
315
+ const head = aliasPattern.slice(0, wildcardIndex);
316
+ const tail = aliasPattern.slice(wildcardIndex + 1);
317
+ if (tail) {
318
+ if (importPath.endsWith(tail) && importPath.length >= head.length + tail.length)
319
+ return true;
320
+ continue;
321
+ }
322
+ if (importPath.startsWith(head) && importPath.length > head.length)
323
+ return true;
324
+ }
325
+ return false;
326
+ }
327
+ var packageNameCache = new Map;
328
+ function pathExists(absolutePath) {
329
+ try {
330
+ fs2.statSync(absolutePath);
331
+ return true;
332
+ } catch {
333
+ return false;
334
+ }
335
+ }
336
+ function isInstalledPackage(importPath, cwd, exists = pathExists) {
337
+ const segments = importPath.split("/");
338
+ const packageName = importPath.startsWith("@") ? segments.slice(0, 2).join("/") : segments[0];
339
+ if (!packageName)
340
+ return false;
341
+ const cacheKey = `${cwd}
342
+ ${packageName}`;
343
+ const cached = packageNameCache.get(cacheKey);
344
+ if (cached !== undefined)
345
+ return cached;
346
+ const installed = exists(path2.join(cwd, "node_modules", packageName));
347
+ packageNameCache.set(cacheKey, installed);
348
+ return installed;
349
+ }
350
+ function isSameDirectory(absolutePath, directory) {
351
+ return path2.dirname(absolutePath) === directory;
352
+ }
353
+ function toRelativeImport(importerDirectory, absolutePath) {
354
+ const relativePath = path2.relative(importerDirectory, absolutePath).replaceAll(path2.sep, "/");
355
+ return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
356
+ }
357
+ function isRelativeImport(importPath) {
358
+ return ["./", "../"].some((prefix) => importPath.startsWith(prefix)) || importPath === "." || importPath === "..";
359
+ }
360
+ function preserveExtensionOmission(original, suggested) {
361
+ const extension = path2.extname(suggested);
362
+ return extension !== "" && path2.extname(original) === "" ? suggested.slice(0, -extension.length) : suggested;
363
+ }
364
+ function parseOptionsAlias(option) {
365
+ if (typeof option !== "object" || option === null || Array.isArray(option))
366
+ return null;
367
+ const { alias } = option;
368
+ if (typeof alias !== "object" || alias === null || Array.isArray(alias))
369
+ return null;
370
+ const parsed = {};
371
+ for (const [key, value] of Object.entries(alias)) {
372
+ if (typeof value === "string") {
373
+ parsed[key] = [value];
374
+ continue;
375
+ }
376
+ if (Array.isArray(value) && value.every((item) => typeof item === "string"))
377
+ parsed[key] = value;
378
+ }
379
+ return parsed;
380
+ }
381
+ function loadAliasConfig(cwd, options) {
382
+ const loaded = loadTsConfigAliases(cwd);
383
+ const aliasPatterns = { ...loaded.aliasPatterns };
384
+ const configured = parseOptionsAlias(options[0]);
385
+ if (configured)
386
+ Object.assign(aliasPatterns, configured);
387
+ return { aliasPatterns, basePath: loaded.basePath || cwd };
388
+ }
389
+ function findShorterAlias(absolutePath, basePath, aliasPatterns, currentSpelling) {
390
+ const match = findBestAliasMatch(absolutePath, basePath, aliasPatterns);
391
+ if (!match || match === currentSpelling)
392
+ return null;
393
+ return preserveExtensionOmission(currentSpelling, match).length < currentSpelling.length ? match : null;
394
+ }
395
+ function hasStaticModuleSpecifier(node) {
396
+ return node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration";
397
+ }
398
+ var preferAlias = defineRule({
399
+ createOnce: (context) => {
400
+ let config;
401
+ const checkModuleSpecifier = (node) => {
402
+ if (!hasStaticModuleSpecifier(node))
403
+ return;
404
+ const { source } = node;
405
+ if (!source)
406
+ return;
407
+ config ??= loadAliasConfig(context.cwd, context.options);
408
+ const { aliasPatterns, basePath } = config;
409
+ if (Object.keys(aliasPatterns).length === 0)
410
+ return;
411
+ const importPath = source.value;
412
+ const importerDirectory = path2.dirname(context.filename);
413
+ const relativeImport = isRelativeImport(importPath);
414
+ const absoluteImport = relativeImport ? resolveModulePath(path2.resolve(importerDirectory, importPath)) ?? path2.resolve(importerDirectory, importPath) : findAliasTarget(importPath, basePath, aliasPatterns);
415
+ if (!absoluteImport)
416
+ return;
417
+ const report = (candidate, messageId) => {
418
+ const newPath = preserveExtensionOmission(importPath, candidate);
419
+ context.report({
420
+ data: { newPath, path: importPath },
421
+ fix: (fixer) => fixer.replaceTextRange([source.range[0] + 1, source.range[1] - 1], newPath),
422
+ messageId,
423
+ node
424
+ });
425
+ };
426
+ if (!relativeImport) {
427
+ if (isInstalledPackage(importPath, context.cwd) || !matchesAliasPattern(importPath, aliasPatterns))
428
+ return;
429
+ if (isSameDirectory(absoluteImport, importerDirectory)) {
430
+ report(toRelativeImport(importerDirectory, absoluteImport), "import");
431
+ return;
432
+ }
433
+ const match2 = findShorterAlias(absoluteImport, basePath, aliasPatterns, importPath);
434
+ if (match2)
435
+ report(match2, "shortAlias");
436
+ return;
437
+ }
438
+ if (isSameDirectory(absoluteImport, importerDirectory))
439
+ return;
440
+ const match = findShorterAlias(absoluteImport, basePath, aliasPatterns, importPath);
441
+ if (match)
442
+ report(match, "import");
443
+ };
444
+ return {
445
+ ImportDeclaration: checkModuleSpecifier,
446
+ ExportAllDeclaration: checkModuleSpecifier,
447
+ ExportNamedDeclaration: checkModuleSpecifier
448
+ };
449
+ },
450
+ meta: {
451
+ defaultOptions: [{}],
452
+ fixable: "code",
453
+ messages: {
454
+ import: "Unexpected import {{path}}. Use {{newPath}} instead",
455
+ shortAlias: "Prefer importing {{newPath}} over {{path}}"
456
+ },
457
+ schema: [
458
+ {
459
+ additionalProperties: false,
460
+ properties: {
461
+ alias: {
462
+ description: "Optional map of additional aliases (overrides tsconfig.json if provided). Can be string or array of strings.",
463
+ type: "object"
464
+ }
465
+ },
466
+ type: "object"
467
+ }
468
+ ],
469
+ hasSuggestions: true,
470
+ type: "suggestion"
471
+ }
472
+ });
473
+
474
+ // tools/oxlint/rules/index.ts
475
+ var plugin = definePlugin({
476
+ meta: { name: "lazuee" },
477
+ rules: { "prefer-alias": preferAlias }
478
+ });
479
+ var rules_default = plugin;
480
+ export {
481
+ rules_default as default
482
+ };
@@ -0,0 +1 @@
1
+ export declare const ignorePatterns: string[];
@@ -0,0 +1,7 @@
1
+ import {
2
+ ignorePatterns
3
+ } from "../../chunk-41590bpf.js";
4
+ import"../../chunk-5wgwscd0.js";
5
+ export {
6
+ ignorePatterns
7
+ };
@@ -0,0 +1,11 @@
1
+ export interface AliasConfig {
2
+ aliasPatterns: Record<string, string[]>;
3
+ /** Directory that `paths` entries are resolved against. */
4
+ basePath: string;
5
+ }
6
+ /**
7
+ * Removes `//` and block comments plus trailing commas, skipping the contents
8
+ * of string literals so values like "http://localhost" survive.
9
+ */
10
+ export declare function stripJsonComments(source: string): string;
11
+ export declare function loadTsConfigAliases(cwd: string): AliasConfig;
@@ -0,0 +1 @@
1
+ export type RuleSeverity = "off" | "warn" | "error" | [RuleSeverity, ...unknown[]];