@isentinel/eslint-config 6.0.0-beta.2 → 6.0.0-beta.21
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/README.md +322 -3
- package/bin/index.js +1 -1
- package/bin/lint.js +3 -0
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +719 -0
- package/dist/formatter-agents.d.mts +22 -0
- package/dist/formatter-agents.mjs +69 -0
- package/dist/index.d.mts +19142 -11553
- package/dist/index.mjs +5394 -2590
- package/dist/lint-cli.d.mts +1 -0
- package/dist/lint-cli.mjs +4827 -0
- package/dist/lint-ignored.d.mts +1 -0
- package/dist/lint-ignored.mjs +280 -0
- package/dist/oxlint.d.mts +32373 -0
- package/dist/oxlint.mjs +4711 -0
- package/package.json +74 -41
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ESLint } from "eslint";
|
|
2
|
+
//#region src/formatter-agents.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* ESLint custom formatter that prints one lint message per line in a stable,
|
|
5
|
+
* agent-friendly shape.
|
|
6
|
+
*
|
|
7
|
+
* Each line reads `path:line:column: severity ruleId: message`, with message
|
|
8
|
+
* whitespace collapsed to single spaces so a diagnostic never wraps across
|
|
9
|
+
* lines. Output is sorted deterministically (file, line, column, severity,
|
|
10
|
+
* ruleId) so identical lint runs produce byte-identical output, and returns an
|
|
11
|
+
* empty string when there are no messages.
|
|
12
|
+
*
|
|
13
|
+
* @param lintResults - The per-file lint results ESLint passes to the
|
|
14
|
+
* formatter.
|
|
15
|
+
* @param lintResultData - Optional run metadata; `cwd` is used to relativize
|
|
16
|
+
* file paths, falling back to `process.cwd()`.
|
|
17
|
+
* @returns The formatted report, terminated by a trailing newline, or an empty
|
|
18
|
+
* string when nothing was reported.
|
|
19
|
+
*/
|
|
20
|
+
declare function eslintFormatterAgents(lintResults: ReadonlyArray<ESLint.LintResult>, lintResultData?: ESLint.LintResultData): string;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { eslintFormatterAgents as default };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
//#region src/formatter-agents.ts
|
|
4
|
+
function getSeverity(message) {
|
|
5
|
+
return message.fatal === true || message.severity === 2 ? "error" : "warning";
|
|
6
|
+
}
|
|
7
|
+
function getRuleId(message) {
|
|
8
|
+
return message.ruleId ?? "eslint";
|
|
9
|
+
}
|
|
10
|
+
function getRelativeFilePath(filePath, lintResultData) {
|
|
11
|
+
const currentWorkingDirectory = lintResultData?.cwd ?? process.cwd();
|
|
12
|
+
const relativeFilePath = path.relative(currentWorkingDirectory, filePath);
|
|
13
|
+
return relativeFilePath.length === 0 ? filePath : relativeFilePath;
|
|
14
|
+
}
|
|
15
|
+
function compareNumbers(first = 0, second = 0) {
|
|
16
|
+
return first - second;
|
|
17
|
+
}
|
|
18
|
+
function compareMessages(first, second) {
|
|
19
|
+
const fileComparison = first.filePath.localeCompare(second.filePath);
|
|
20
|
+
if (fileComparison !== 0) return fileComparison;
|
|
21
|
+
const lineComparison = compareNumbers(first.line, second.line);
|
|
22
|
+
if (lineComparison !== 0) return lineComparison;
|
|
23
|
+
const columnComparison = compareNumbers(first.column, second.column);
|
|
24
|
+
if (columnComparison !== 0) return columnComparison;
|
|
25
|
+
if (first.severity !== second.severity) return first.severity === "error" ? -1 : 1;
|
|
26
|
+
return first.ruleId.localeCompare(second.ruleId);
|
|
27
|
+
}
|
|
28
|
+
const WHITESPACE_REGEXP = /\s+/gu;
|
|
29
|
+
/**
|
|
30
|
+
* ESLint custom formatter that prints one lint message per line in a stable,
|
|
31
|
+
* agent-friendly shape.
|
|
32
|
+
*
|
|
33
|
+
* Each line reads `path:line:column: severity ruleId: message`, with message
|
|
34
|
+
* whitespace collapsed to single spaces so a diagnostic never wraps across
|
|
35
|
+
* lines. Output is sorted deterministically (file, line, column, severity,
|
|
36
|
+
* ruleId) so identical lint runs produce byte-identical output, and returns an
|
|
37
|
+
* empty string when there are no messages.
|
|
38
|
+
*
|
|
39
|
+
* @param lintResults - The per-file lint results ESLint passes to the
|
|
40
|
+
* formatter.
|
|
41
|
+
* @param lintResultData - Optional run metadata; `cwd` is used to relativize
|
|
42
|
+
* file paths, falling back to `process.cwd()`.
|
|
43
|
+
* @returns The formatted report, terminated by a trailing newline, or an empty
|
|
44
|
+
* string when nothing was reported.
|
|
45
|
+
*/
|
|
46
|
+
function eslintFormatterAgents(lintResults, lintResultData) {
|
|
47
|
+
const messages = new Array();
|
|
48
|
+
for (const lintResult of lintResults) {
|
|
49
|
+
const filePath = getRelativeFilePath(lintResult.filePath, lintResultData);
|
|
50
|
+
for (const message of lintResult.messages) messages.push({
|
|
51
|
+
column: message.column,
|
|
52
|
+
filePath,
|
|
53
|
+
line: message.line,
|
|
54
|
+
message: normalizeMessage(message.message),
|
|
55
|
+
ruleId: getRuleId(message),
|
|
56
|
+
severity: getSeverity(message)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (messages.length === 0) return "";
|
|
60
|
+
return `${messages.toSorted(compareMessages).map(formatMessage).join("\n")}\n`;
|
|
61
|
+
}
|
|
62
|
+
function normalizeMessage(message) {
|
|
63
|
+
return message.replaceAll(WHITESPACE_REGEXP, " ").trim();
|
|
64
|
+
}
|
|
65
|
+
function formatMessage({ column, filePath, line, message, ruleId, severity }) {
|
|
66
|
+
return `${line === void 0 ? filePath : `${filePath}:${line}:${column ?? 0}`}: ${severity} ${ruleId}: ${message}`;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { eslintFormatterAgents as default };
|