lintmax 0.1.92 → 0.1.94
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/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { S as OXLINT_CLI_ALLOW, b as DEFAULT_SHARED_IGNORE_PATTERNS, i as joinPath, l as isRecord, n as fromFileUrl, t as dirnamePath, w as PARSE_DIALECTS, x as ESLINT_TEST_FILE_PATTERNS } from "./path-
|
|
3
|
-
import { _ as resolveBin, a as PRETTIER_MD_ARGS, b as usage, c as cwd, d as envValue, f as lintmaxRoot, g as readVersion, h as readRequiredJson, i as CliExitError, l as decodeText, m as readJson, o as bunEnv, p as pathExists, r as sync, s as cacheDir, u as ensureDirectory, v as run, y as runCapture } from "./src-
|
|
2
|
+
import { S as OXLINT_CLI_ALLOW, b as DEFAULT_SHARED_IGNORE_PATTERNS, i as joinPath, l as isRecord, n as fromFileUrl, t as dirnamePath, w as PARSE_DIALECTS, x as ESLINT_TEST_FILE_PATTERNS } from "./path-CVd5J9sx.mjs";
|
|
3
|
+
import { _ as resolveBin, a as PRETTIER_MD_ARGS, b as usage, c as cwd, d as envValue, f as lintmaxRoot, g as readVersion, h as readRequiredJson, i as CliExitError, l as decodeText, m as readJson, o as bunEnv, p as pathExists, r as sync, s as cacheDir, u as ensureDirectory, v as run, y as runCapture } from "./src-apGJLN8u.mjs";
|
|
4
4
|
import { $, Glob, env, file, write } from "bun";
|
|
5
5
|
import { lstat, unlink } from "node:fs/promises";
|
|
6
6
|
import { join } from "node:path";
|
|
@@ -128,7 +128,7 @@ const normalizePath = (filePath) => {
|
|
|
128
128
|
const parseBiomeDiagnostics = ({ stdout }) => {
|
|
129
129
|
let parsed;
|
|
130
130
|
try {
|
|
131
|
-
parsed =
|
|
131
|
+
parsed = readRequiredJson(stdout);
|
|
132
132
|
} catch {
|
|
133
133
|
return [];
|
|
134
134
|
}
|
|
@@ -152,7 +152,7 @@ const parseBiomeDiagnostics = ({ stdout }) => {
|
|
|
152
152
|
const parseOxlintDiagnostics = ({ stdout }) => {
|
|
153
153
|
let parsed;
|
|
154
154
|
try {
|
|
155
|
-
parsed =
|
|
155
|
+
parsed = readRequiredJson(stdout);
|
|
156
156
|
} catch {
|
|
157
157
|
return [];
|
|
158
158
|
}
|
|
@@ -192,7 +192,7 @@ const eslintDiagnosticsForFile = (fileEntry) => {
|
|
|
192
192
|
const parseEslintDiagnostics = ({ stdout }) => {
|
|
193
193
|
let parsed;
|
|
194
194
|
try {
|
|
195
|
-
parsed =
|
|
195
|
+
parsed = readRequiredJson(stdout);
|
|
196
196
|
} catch {
|
|
197
197
|
return [];
|
|
198
198
|
}
|
|
@@ -316,7 +316,11 @@ const BANNED_CALLEE_NAMES = /* @__PURE__ */ new Set([
|
|
|
316
316
|
"cx",
|
|
317
317
|
"twMerge"
|
|
318
318
|
]);
|
|
319
|
-
const asNode = (v) =>
|
|
319
|
+
const asNode = (v) => {
|
|
320
|
+
if (!v || typeof v !== "object" || !("type" in v) || typeof v.type !== "string") return null;
|
|
321
|
+
/** biome-ignore lint/nursery/noUnsafeTypeAssertion: external parser AST node is narrowed only at this boundary */
|
|
322
|
+
return v;
|
|
323
|
+
};
|
|
320
324
|
const strName = (n) => typeof n?.name === "string" ? n.name : "";
|
|
321
325
|
const lineAt$1 = (sourceText, offset) => {
|
|
322
326
|
let line = 1;
|
|
@@ -372,7 +376,7 @@ const findClassNameViolations = ({ sourceText }) => {
|
|
|
372
376
|
}
|
|
373
377
|
const node = asNode(raw);
|
|
374
378
|
if (!node) {
|
|
375
|
-
if (raw && typeof raw === "object") for (const
|
|
379
|
+
if (raw && typeof raw === "object") for (const child of Object.values(raw)) visit(child, parent, grand);
|
|
376
380
|
return;
|
|
377
381
|
}
|
|
378
382
|
collectClassNameAttrViolation(node, sourceText, violations);
|
|
@@ -422,7 +426,7 @@ const checkClassName = async ({ root }) => {
|
|
|
422
426
|
//#region src/rules.ts
|
|
423
427
|
const extractBiomeRules = async () => {
|
|
424
428
|
const pkgPath = fromFileUrl(import.meta.resolve("@biomejs/biome/configuration_schema.json"));
|
|
425
|
-
const defs =
|
|
429
|
+
const defs = readRequiredJson(await file(pkgPath).text()).$defs ?? {};
|
|
426
430
|
const categories = [
|
|
427
431
|
"a11y",
|
|
428
432
|
"complexity",
|
|
@@ -480,7 +484,7 @@ const extractEslintRules = async () => {
|
|
|
480
484
|
if (result.exitCode !== 0) throw new Error(`eslint --print-config failed, so its rule set is unknown: ${result.stderr.toString().trim()}`);
|
|
481
485
|
let parsed;
|
|
482
486
|
try {
|
|
483
|
-
parsed =
|
|
487
|
+
parsed = readRequiredJson(result.stdout.toString());
|
|
484
488
|
} catch (error) {
|
|
485
489
|
throw new Error(`eslint --print-config returned unreadable JSON: ${error instanceof Error ? error.message : ""}`, { cause: error });
|
|
486
490
|
}
|
|
@@ -621,7 +625,12 @@ const normalizeRule = (rule) => {
|
|
|
621
625
|
};
|
|
622
626
|
const loadOxlintOffRules = async () => {
|
|
623
627
|
const configPath = joinPath(process.cwd(), cacheDir, ".oxlintrc.json");
|
|
624
|
-
|
|
628
|
+
let config;
|
|
629
|
+
try {
|
|
630
|
+
config = readRequiredJson(await file(configPath).text());
|
|
631
|
+
} catch {
|
|
632
|
+
config = null;
|
|
633
|
+
}
|
|
625
634
|
if (!config) return /* @__PURE__ */ new Set();
|
|
626
635
|
const off = /* @__PURE__ */ new Set();
|
|
627
636
|
for (const [rule, val] of Object.entries(config.rules ?? {})) if ((Array.isArray(val) ? String(val[0]) : val) === "off") {
|
|
@@ -1327,12 +1336,11 @@ const containsJsxNode = (program) => {
|
|
|
1327
1336
|
for (const child of node) visit(child);
|
|
1328
1337
|
return;
|
|
1329
1338
|
}
|
|
1330
|
-
|
|
1331
|
-
if (typed.type === "JSXElement" || typed.type === "JSXFragment") {
|
|
1339
|
+
if ("type" in node && (node.type === "JSXElement" || node.type === "JSXFragment")) {
|
|
1332
1340
|
found = true;
|
|
1333
1341
|
return;
|
|
1334
1342
|
}
|
|
1335
|
-
for (const key of Object.
|
|
1343
|
+
for (const [key, child] of Object.entries(node)) if (key !== "type") visit(child);
|
|
1336
1344
|
};
|
|
1337
1345
|
visit(program);
|
|
1338
1346
|
return found;
|
|
@@ -2136,7 +2144,7 @@ const throwAgentResults = ({ diagnostics, failures }) => {
|
|
|
2136
2144
|
const readOxlintIgnorePatterns = async ({ dir }) => {
|
|
2137
2145
|
const generated = file(joinPath(dir, ".oxlintrc.json"));
|
|
2138
2146
|
if (!await generated.exists()) return [...DEFAULT_SHARED_IGNORE_PATTERNS];
|
|
2139
|
-
const patterns = (await generated.
|
|
2147
|
+
const patterns = readRequiredJson(await generated.text()).ignorePatterns;
|
|
2140
2148
|
if (!Array.isArray(patterns)) return [...DEFAULT_SHARED_IGNORE_PATTERNS];
|
|
2141
2149
|
return patterns.filter((x) => typeof x === "string");
|
|
2142
2150
|
};
|
|
@@ -2314,7 +2322,7 @@ const runLint = async ({ command, human = false }) => {
|
|
|
2314
2322
|
configPath,
|
|
2315
2323
|
env
|
|
2316
2324
|
});
|
|
2317
|
-
const runtime = await
|
|
2325
|
+
const runtime = readRequiredJson(await file(runtimePath).text());
|
|
2318
2326
|
const failures = [];
|
|
2319
2327
|
const { clearFailures, runCompactContinue, runSteps, runStepsSilent, throwIfFailures } = createStepExecutor({
|
|
2320
2328
|
env,
|
package/dist/eslint.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as TAILWIND_ENTRY_CANDIDATES, T as SHARED_OVERRIDE_SYMBOL_KEY, b as DEFAULT_SHARED_IGNORE_PATTERNS, c as findUnknownRules, d as normalizeObjectListInput, f as normalizePathListInput, g as warnToError, i as joinPath, l as isRecord, m as normalizeTailwindOption, p as normalizeRulesOffInput, r as isAbsolutePath, x as ESLINT_TEST_FILE_PATTERNS } from "./path-
|
|
1
|
+
import { E as TAILWIND_ENTRY_CANDIDATES, T as SHARED_OVERRIDE_SYMBOL_KEY, b as DEFAULT_SHARED_IGNORE_PATTERNS, c as findUnknownRules, d as normalizeObjectListInput, f as normalizePathListInput, g as warnToError, i as joinPath, l as isRecord, m as normalizeTailwindOption, p as normalizeRulesOffInput, r as isAbsolutePath, x as ESLINT_TEST_FILE_PATTERNS } from "./path-CVd5J9sx.mjs";
|
|
2
2
|
import { file } from "bun";
|
|
3
3
|
import eslintReact from "@eslint-react/eslint-plugin";
|
|
4
4
|
import { includeIgnoreFile } from "@eslint/compat";
|
|
@@ -87,7 +87,9 @@ const collectKnownEslintRuleNames = ({ appendConfigs, baseConfigs }) => {
|
|
|
87
87
|
return knownRuleNames;
|
|
88
88
|
};
|
|
89
89
|
const getSharedAppendConfig = ({ config }) => {
|
|
90
|
-
|
|
90
|
+
if (Reflect.get(config, sharedOverrideMarker) !== true) return null;
|
|
91
|
+
/** biome-ignore lint/nursery/noUnsafeTypeAssertion: internal marker identifies this external config as the shared append shape */
|
|
92
|
+
return config;
|
|
91
93
|
};
|
|
92
94
|
const resolveTailwindEntry = async ({ root, tailwind }) => {
|
|
93
95
|
const tailwindSetting = tailwind ?? true;
|
|
@@ -115,6 +117,7 @@ const SOURCE_FILE_PATTERNS = [
|
|
|
115
117
|
const tailwindRules = (entryPoint) => entryPoint ? eslintPluginBetterTailwindcss.configs["recommended-error"].rules : {};
|
|
116
118
|
/** regexp's `flat/recommended` is the curated set: it keeps every correctness rule (no-super-linear-backtracking — the real ReDoS — plus no-misleading-capturing-group, no-dupe-disjunctions, no-unused-capturing-group) and drops the pure-style ones `flat/all` adds (prefer-named-capture-group, require-unicode-sets-regexp, sort-character-class-elements) and the author-excluded advisory no-super-linear-move. Its rules ship at warn, and a warn enforces nothing because the gate's `warnToError` covers consumer overrides, not a config reached through `extends`, so they are lifted to error here. */
|
|
117
119
|
const regexpRecommendedAtError = () => {
|
|
120
|
+
/** biome-ignore lint/nursery/noUnsafeTypeAssertion: external regexp plugin config is structurally compatible with ESLint's config boundary */
|
|
118
121
|
const rec = configs$2["flat/recommended"];
|
|
119
122
|
return {
|
|
120
123
|
...rec,
|
|
@@ -123,7 +126,9 @@ const regexpRecommendedAtError = () => {
|
|
|
123
126
|
};
|
|
124
127
|
/** package.json is a file type the gate would otherwise never lint. The plugin ships its own `files` glob and JSON parser, so it stands alone rather than riding the TypeScript block. Its `recommended` + `stylistic` are the curated set; the `require-*` family stays out because those demand OPT-IN metadata (`bin`, `browser`, `cpu`, `gypfile`, `libc`, `man`, `os`) that no ordinary package declares. `require-type` is disabled with cause: its autofix stamps `"type": "commonjs"` onto any manifest missing `type`, which silently BREAKS an ESM package (a Next/MDX app relying on extension-based resolution) — a rule that guesses a load-bearing field and defaults it wrong is harm, not strictness. */
|
|
125
128
|
const packageJsonConfig = () => {
|
|
129
|
+
/** biome-ignore lint/nursery/noUnsafeTypeAssertion: external package-json plugin config is structurally compatible with ESLint's config boundary */
|
|
126
130
|
const recommended = configs.recommended;
|
|
131
|
+
/** biome-ignore lint/nursery/noUnsafeTypeAssertion: external package-json plugin config is structurally compatible with ESLint's config boundary */
|
|
127
132
|
const stylistic = configs.stylistic;
|
|
128
133
|
return {
|
|
129
134
|
...recommended,
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as eslintImport, r as sync, t as defineConfig } from "./src-
|
|
1
|
+
import { n as eslintImport, r as sync, t as defineConfig } from "./src-apGJLN8u.mjs";
|
|
2
2
|
export { defineConfig, eslintImport, sync };
|
|
@@ -173,7 +173,10 @@ const OXLINT_CLI_ALLOW = [
|
|
|
173
173
|
"react/jsx-no-literals",
|
|
174
174
|
"unicorn/prefer-export-from",
|
|
175
175
|
"react/react-compiler",
|
|
176
|
+
"react/todo",
|
|
176
177
|
"react/function-component-definition",
|
|
178
|
+
"react/memo-dependencies",
|
|
179
|
+
"react/preserve-manual-memoization",
|
|
177
180
|
"node/no-top-level-await",
|
|
178
181
|
"eslint/one-var"
|
|
179
182
|
];
|
|
@@ -199,6 +202,7 @@ const normalizePathListInput = ({ allowUndefined = false, label, value }) => {
|
|
|
199
202
|
return out;
|
|
200
203
|
};
|
|
201
204
|
const hasPlainObjectPrototype = ({ value }) => {
|
|
205
|
+
/** biome-ignore lint/nursery/noUnsafeTypeAssertion: Object.getPrototypeOf returns an untyped external object boundary */
|
|
202
206
|
const prototype = Object.getPrototypeOf(value);
|
|
203
207
|
return prototype === null || prototype === Object.prototype;
|
|
204
208
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as OXLINT_PATTERN_RULE_OVERRIDES, T as SHARED_OVERRIDE_SYMBOL_KEY, _ as BIOME_IGNORE_PATTERNS, a as assertJsonSerializable, b as DEFAULT_SHARED_IGNORE_PATTERNS, c as findUnknownRules, d as normalizeObjectListInput, f as normalizePathListInput, h as stripPluginNamespace, i as joinPath, l as isRecord, m as normalizeTailwindOption, n as fromFileUrl, o as assertObject, p as normalizeRulesOffInput, s as assertOptionalString, t as dirnamePath, u as normalizeIgnorePattern, v as BIOME_PATTERN_RULE_OVERRIDES, y as BIOME_RULES_OFF } from "./path-
|
|
1
|
+
import { C as OXLINT_PATTERN_RULE_OVERRIDES, T as SHARED_OVERRIDE_SYMBOL_KEY, _ as BIOME_IGNORE_PATTERNS, a as assertJsonSerializable, b as DEFAULT_SHARED_IGNORE_PATTERNS, c as findUnknownRules, d as normalizeObjectListInput, f as normalizePathListInput, h as stripPluginNamespace, i as joinPath, l as isRecord, m as normalizeTailwindOption, n as fromFileUrl, o as assertObject, p as normalizeRulesOffInput, s as assertOptionalString, t as dirnamePath, u as normalizeIgnorePattern, v as BIOME_PATTERN_RULE_OVERRIDES, y as BIOME_RULES_OFF } from "./path-CVd5J9sx.mjs";
|
|
2
2
|
import { $, env as bunEnv, file, write } from "bun";
|
|
3
3
|
import { lstat } from "node:fs/promises";
|
|
4
4
|
import { join, relative } from "node:path";
|
|
@@ -44,10 +44,7 @@ const readJson = async ({ path }) => {
|
|
|
44
44
|
return {};
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
const readRequiredJson =
|
|
48
|
-
const text = await file(path).text();
|
|
49
|
-
return JSON.parse(text);
|
|
50
|
-
};
|
|
47
|
+
const readRequiredJson = (text) => JSON.parse(text);
|
|
51
48
|
const ensureDirectory = async ({ directory }) => {
|
|
52
49
|
const result = await $`mkdir -p ${directory}`.quiet().nothrow();
|
|
53
50
|
if (result.exitCode === 0) return;
|
|
@@ -72,7 +69,7 @@ const resolveBin = async ({ bin, pkg }) => {
|
|
|
72
69
|
code: 1,
|
|
73
70
|
message: `Cannot find ${pkg} — run: bun add -d ${pkg}`
|
|
74
71
|
});
|
|
75
|
-
const pkgJson = await
|
|
72
|
+
const pkgJson = readRequiredJson(await file(packageJsonPath).text());
|
|
76
73
|
const pkgDir = dirnamePath(packageJsonPath);
|
|
77
74
|
const binPath = typeof pkgJson.bin === "string" ? pkgJson.bin : pkgJson.bin?.[bin] ?? "";
|
|
78
75
|
return joinPath(pkgDir, binPath);
|
|
@@ -100,7 +97,7 @@ const runCapture = async ({ args, command, env }) => {
|
|
|
100
97
|
};
|
|
101
98
|
const envValue = (name) => bunEnv[name] ?? "";
|
|
102
99
|
const readVersion = async () => {
|
|
103
|
-
return (await
|
|
100
|
+
return readRequiredJson(await file(joinPath(lintmaxRoot, "package.json")).text()).version;
|
|
104
101
|
};
|
|
105
102
|
const usage = ({ version }) => {
|
|
106
103
|
process.stdout.write(`lintmax v${version}\n\n`);
|
|
@@ -138,7 +135,7 @@ const resolveSchemaPath = async ({ cwd }) => {
|
|
|
138
135
|
};
|
|
139
136
|
const resolveBiomeSchema = async ({ cwd }) => {
|
|
140
137
|
const schemaPath = await resolveSchemaPath({ cwd });
|
|
141
|
-
const schema = await
|
|
138
|
+
const schema = readRequiredJson(await file(schemaPath).text());
|
|
142
139
|
const rulesProps = schema.$defs.Rules?.properties ?? {};
|
|
143
140
|
const categories = Object.keys(rulesProps).filter((k) => {
|
|
144
141
|
return schema.$defs[k.charAt(0).toUpperCase() + k.slice(1)]?.properties !== void 0;
|
|
@@ -225,7 +222,7 @@ const normalizeSharedOverrides = ({ label, value }) => {
|
|
|
225
222
|
label: `${label}.${pattern}`,
|
|
226
223
|
value: rawOverride
|
|
227
224
|
});
|
|
228
|
-
for (const key of Object.keys(override)) if (!SHARED_OVERRIDE_KEYS.
|
|
225
|
+
for (const key of Object.keys(override)) if (!SHARED_OVERRIDE_KEYS.some((k) => k === key)) throw new Error(`${label}.${pattern}.${key} is not supported. Use biome, eslint, or oxlint.`);
|
|
229
226
|
entries.push({
|
|
230
227
|
...override,
|
|
231
228
|
files: [pattern]
|
|
@@ -663,7 +660,7 @@ const createBiomeConfig = async ({ cwd, options, sharedIgnorePatterns }) => {
|
|
|
663
660
|
};
|
|
664
661
|
};
|
|
665
662
|
const createOxlintConfig = async ({ options, sharedIgnorePatterns }) => {
|
|
666
|
-
const base = await
|
|
663
|
+
const base = readRequiredJson(await file(joinPath(pkgRoot, "oxlintrc.json")).text());
|
|
667
664
|
const knownRules = /* @__PURE__ */ new Set([
|
|
668
665
|
...Object.keys(base.rules),
|
|
669
666
|
...(base.overrides ?? []).flatMap((override) => Object.keys(override.rules)),
|