@oxlint-config-inspector/core 1.1.2 → 1.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.
- package/dist/index.d.mts +5 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +28 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -169,8 +169,12 @@ type InspectConfigResult = {
|
|
|
169
169
|
declare function inspectConfig(options?: GetConfigOptions): Promise<InspectConfigResult | null>;
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/rules.d.ts
|
|
172
|
+
/**
|
|
173
|
+
* Options for locating and invoking the project's linter.
|
|
174
|
+
*/
|
|
172
175
|
type GetOxlintRulesOptions = {
|
|
173
|
-
/**
|
|
176
|
+
/** The project directory used to resolve and run Vite+. Defaults to `process.cwd()`. */cwd?: string; /** Selects Vite+ instead of Oxlint. When omitted, detects Vite+ in the project. */
|
|
177
|
+
useVitePlus?: boolean;
|
|
174
178
|
};
|
|
175
179
|
/**
|
|
176
180
|
* Fetches the list of builtin lint rules by invoking the linter binary.
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/plugins.ts","../src/types.ts","../src/inspect.ts","../src/rules.ts"],"mappings":";KAmBY,gBAAA;EAAgB,+EAE1B,KAAA,YAF0B;EAI1B,UAAA;EAEA,GAAA;AAAA;;cAoBW,YAAA;;;;ACMF;;KAHC,eAAA;EACV,OAAA;EACA,IAAA;EACA,SAAA;AAAA;;;KCnDU,QAAA;EACV,KAAA;EACA,KAAA;EACA,QAAA;EACA,UAAA;EACA,GAAA;EACA,OAAA;EACA,QAAA;AAAA;;;;;;KCYU,qBAAA;;;AHMP;KGDO,eAAA;EHqB2F,8CGnBrG,SAAA,UHmBqG;EGjBrG,IAAA;EAEA,SAAA;EAEA,MAAA,EAAQ,qBAAqB;AAA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8BR,YAAA,aA1BA;EA4BA,KAAA,YA1BA;EA4BA,KAAA,UA5BI;EA8BJ,SAAA,aAxBoC;EA0BpC,OAAA,aAhB2B;EAkB3B,KAAA,EAAO,0BAA0B;AAAA;;;;KAMvB,mBAAA;EAxBF,2DA0BR,WAAA,YA1B2B;EA4B3B,cAAA,UAtBgC;EAwBhC,WAAA,UAZiC;EAcjC,cAAA,EAAgB,sBAAA,IAtBhB;EAwBA,YAAA,EAAc,wBAAA,IApBd;EAsBA,OAAA,EAAS,eAAA,IAlBT;EAoBA,iBAAA,YApBiC;EAsBjC,KAAA,EAAO,aAAA,IAhBG;EAkBV,KAAA,EAAO,kBAAA;EAEP,YAAA,EAAc,aAAA,IAVA;EAYd,OAAA;AAAA;;;;;;;iBAeoB,aAAA,CAAc,OAAA,GAAS,gBAAA,GAAwB,OAAA,CAAQ,mBAAA;;;AH7N7E;;;AAAA,KINY,qBAAA;EJQV,wFINA,GAAA,WJUA;EIRA,WAAW;AAAA;AJ4Bb;;;;AAAuG;;AAAvG,iBInBsB,cAAA,CAAe,OAAA,GAAU,qBAAA,GAAwB,OAAA,CAAQ,QAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { access } from "node:fs/promises";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { cosmiconfig, defaultLoaders } from "cosmiconfig";
|
|
4
5
|
import { createJiti } from "jiti";
|
|
5
6
|
import { parse, printParseErrorCode } from "jsonc-parser";
|
|
6
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
+
import process$1 from "node:process";
|
|
7
9
|
import { x } from "tinyexec";
|
|
8
10
|
//#region src/config.ts
|
|
9
11
|
/** Known Oxlint / Vite+ config file names, searched in order by cosmiconfig. */
|
|
@@ -242,7 +244,7 @@ function mergeArrays(base, override) {
|
|
|
242
244
|
}
|
|
243
245
|
//#endregion
|
|
244
246
|
//#region package.json
|
|
245
|
-
var version = "1.1.
|
|
247
|
+
var version = "1.1.4";
|
|
246
248
|
//#endregion
|
|
247
249
|
//#region src/generated/builtin-rule-docs.ts
|
|
248
250
|
const builtinRuleDocs = {
|
|
@@ -2356,8 +2358,8 @@ const builtinRuleDocs = {
|
|
|
2356
2358
|
},
|
|
2357
2359
|
number: {
|
|
2358
2360
|
fractionGroupLength: "Infinity",
|
|
2359
|
-
groupLength:
|
|
2360
|
-
minimumDigits:
|
|
2361
|
+
groupLength: 3,
|
|
2362
|
+
minimumDigits: 5
|
|
2361
2363
|
},
|
|
2362
2364
|
octal: {
|
|
2363
2365
|
groupLength: 4,
|
|
@@ -2370,7 +2372,7 @@ const builtinRuleDocs = {
|
|
|
2370
2372
|
"unicorn/prefer-add-event-listener": { description: "Enforces the use of .addEventListener() and .removeEventListener() over their on-function counterparts." },
|
|
2371
2373
|
"unicorn/prefer-array-find": { description: "Encourages using Array.prototype.find and Array.prototype.findLast instead of taking the first or last matching element from filter(...)." },
|
|
2372
2374
|
"unicorn/prefer-array-flat": { description: "Prefers Array#flat() over legacy techniques to flatten arrays." },
|
|
2373
|
-
"unicorn/prefer-array-flat-map": { description: "Prefers
|
|
2375
|
+
"unicorn/prefer-array-flat-map": { description: "Prefers a single .flatMap() over .map().flat() or .filter().flatMap()." },
|
|
2374
2376
|
"unicorn/prefer-array-index-of": { description: "Enforces using indexOf or lastIndexOf instead of findIndex or findLastIndex when the callback is a simple strict equality comparison." },
|
|
2375
2377
|
"unicorn/prefer-array-some": { description: "Prefers using Array#some() over Array#find(), Array#findLast() with comparing to undefined, or Array#findIndex(), Array#findLastIndex() and a non-zero length check on the result of Array#filter()" },
|
|
2376
2378
|
"unicorn/prefer-at": {
|
|
@@ -2562,9 +2564,9 @@ const builtinRuleDocs = {
|
|
|
2562
2564
|
"vitest/prefer-strict-boolean-matchers": { description: "Enforce using toBe(true) and toBe(false) over matchers that coerce types to boolean." },
|
|
2563
2565
|
"vitest/prefer-strict-equal": { description: "This rule triggers a warning if toEqual() is used to assert equality." },
|
|
2564
2566
|
"vitest/prefer-to-be": { description: "Recommends using toBe matcher for primitive literals and specific matchers for null, undefined, and NaN." },
|
|
2565
|
-
"vitest/prefer-to-be-falsy": { description: "This rule warns when toBe(false) is used with expect or expectTypeOf. With --fix, it will be replaced with toBeFalsy()." },
|
|
2567
|
+
"vitest/prefer-to-be-falsy": { description: "This rule warns when toBe(false) is used with expect or expectTypeOf. With --fix-suggestions, it will be replaced with toBeFalsy()." },
|
|
2566
2568
|
"vitest/prefer-to-be-object": { description: "This rule enforces using toBeObject() to check if a value is of type Object." },
|
|
2567
|
-
"vitest/prefer-to-be-truthy": { description: "This rule warns when toBe(true) is used with expect or expectTypeOf. With --fix, it will be replaced with toBeTruthy()." },
|
|
2569
|
+
"vitest/prefer-to-be-truthy": { description: "This rule warns when toBe(true) is used with expect or expectTypeOf. With --fix-suggestions, it will be replaced with toBeTruthy()." },
|
|
2568
2570
|
"vitest/prefer-to-contain": { description: "In order to have a better failure message, toContain() should be used upon asserting expectations on an array containing an object." },
|
|
2569
2571
|
"vitest/prefer-to-have-been-called-times": { description: "In order to have a better failure message, [toHaveBeenCalledTimes should be used instead of directly checking the length of mock.calls](https://github.com/jest-community/eslint-plugin-jest/blob/v29.5.0/docs/rules/prefer-to-have-been-called-times.md)." },
|
|
2570
2572
|
"vitest/prefer-to-have-length": { description: "In order to have a better failure message, toHaveLength() should be used upon asserting expectations on objects length property." },
|
|
@@ -2891,7 +2893,9 @@ let oxlintBinaryAvailability;
|
|
|
2891
2893
|
* @returns The parsed rules, or an empty array if the binary is unavailable or the invocation fails.
|
|
2892
2894
|
*/
|
|
2893
2895
|
async function getOxlintRules(options) {
|
|
2894
|
-
|
|
2896
|
+
const cwd = path.resolve(options?.cwd ?? process$1.cwd());
|
|
2897
|
+
const entry = resolveVitePlusEntry(cwd);
|
|
2898
|
+
if (options?.useVitePlus ?? Boolean(entry)) return getVitePlusRules(cwd, entry);
|
|
2895
2899
|
if (!await isOxlintBinaryAvailable()) {
|
|
2896
2900
|
console.error("Unable to inspect builtin Oxlint rules because the `oxlint` binary is not available on PATH.");
|
|
2897
2901
|
return [];
|
|
@@ -2904,13 +2908,23 @@ async function getOxlintRules(options) {
|
|
|
2904
2908
|
return [];
|
|
2905
2909
|
}
|
|
2906
2910
|
}
|
|
2907
|
-
|
|
2911
|
+
function resolveVitePlusEntry(cwd) {
|
|
2912
|
+
const require = createRequire(path.join(cwd, "package.json"));
|
|
2913
|
+
for (let directory = cwd;; directory = path.dirname(directory)) try {
|
|
2914
|
+
const packagePath = require.resolve(path.join(directory, "node_modules/vite-plus/package.json"));
|
|
2915
|
+
return path.join(path.dirname(packagePath), "bin/vp");
|
|
2916
|
+
} catch {
|
|
2917
|
+
if (path.dirname(directory) === directory) return;
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
async function getVitePlusRules(cwd, entry) {
|
|
2908
2921
|
try {
|
|
2909
|
-
const
|
|
2922
|
+
const args = [
|
|
2910
2923
|
"lint",
|
|
2911
2924
|
"--rules",
|
|
2912
2925
|
"--format=json"
|
|
2913
|
-
]
|
|
2926
|
+
];
|
|
2927
|
+
const rules = await x(entry ? process$1.execPath : "vp", entry ? [entry, ...args] : args, { nodeOptions: { cwd } });
|
|
2914
2928
|
return JSON.parse(rules.stdout);
|
|
2915
2929
|
} catch (error) {
|
|
2916
2930
|
console.error("Error fetching Vite+ rules:", error);
|
|
@@ -3023,7 +3037,10 @@ async function inspectConfig(options = {}) {
|
|
|
3023
3037
|
const config = await getConfig(options);
|
|
3024
3038
|
if (!config) return null;
|
|
3025
3039
|
const isVitePlus = config.filepath.endsWith("vite.config.ts");
|
|
3026
|
-
const [builtinRules, loadedPlugins] = await Promise.all([getOxlintRules({
|
|
3040
|
+
const [builtinRules, loadedPlugins] = await Promise.all([getOxlintRules({
|
|
3041
|
+
useVitePlus: isVitePlus ? true : void 0,
|
|
3042
|
+
cwd: options.cwd
|
|
3043
|
+
}), getPlugins(config)]);
|
|
3027
3044
|
return inspectLoadedConfig(config, builtinRules, loadedPlugins.plugins, loadedPlugins.errors);
|
|
3028
3045
|
}
|
|
3029
3046
|
/**
|