mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-17 14:28:25 +00:00
ci(lint): split lint jobs and annotate Prettier and JSON schema errors in PRs (#4982)
* ci: split lint-code into ESLint, Prettier and JSON Schema jobs with PR annotations - ESLint: annotations via setup-node's built-in eslint-stylish problem matcher. - Prettier: new scripts/lintFormat.mts formats unformatted files in memory, diffs them and emits line-level `::error` annotations with the expected code. - JSON Schema: replace ajv-cli with a local ESLint rule (Ajv draft 2020-12) that validates icons/categories JSON against their `$schema` and reports at the offending property. eslint-plugin-json-schema-validator was not used because it runs Ajv in draft-07 mode and ignores `dependentRequired`. All annotations use workflow commands, so they work on fork PRs with a read-only token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVxEtqNswEDq1N23taZYh8 * Improve root value check and property error handling Enhance error reporting for JSON schema validation. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * style(lint): format jsonSchemaPlugin with Prettier Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVxEtqNswEDq1N23taZYh8 * test commit * fix(lint): annotate syntax errors from Prettier and ESLint in PRs - ESLint/JSON Schema jobs use a small GitHub formatter that prints `::error` workflow commands. setup-node's eslint-stylish matcher skipped parsing errors because they have no rule id. - lintFormat.mts annotates Prettier syntax errors (exit code 2) at their line and column instead of only printing stderr, and still checks the other files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVxEtqNswEDq1N23taZYh8 * ci(lint): spell check icon and category metadata with cspell annotations - New "Spelling" job runs scripts/lintSpelling.mts, which turns cspell findings into `::error` annotations (with cspell's suggested fix when it has one). - cspell accepts both US and British English, ignores contributor usernames and deprecated `alias.typo` aliases. - Add existing search tags and domain terms to .cspell/custom-words.txt so the current metadata passes. - Add `lint:spelling` to `pnpm lint` and lint-staged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVxEtqNswEDq1N23taZYh8 * fix(lint): pin JSON schemas per file set and drop typo tags - json-schema/no-invalid now takes the schema from config (icon.schema.json for icons, category.schema.json for categories) and reports a `$schema` that points elsewhere, so metadata can't opt out of validation. - Remove the misspelled `frigerator` and `sterisk` tags and their allowlist entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVxEtqNswEDq1N23taZYh8 * fix(icons): split joined-word tags into separate words Tags like `groupchat` and `timemachine` become `group chat` and `time machine` so they read naturally and pass the spell check without allowlisting. Where the spaced tag already existed (`smart home`) the joined one is dropped. cspell now skips all alias names, since they are icon names that can't change (e.g. the deprecated `palmtree` alias). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVxEtqNswEDq1N23taZYh8 * Revert * Try another error * Revert error --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
Copilot Autofix powered by AI
parent
62c584a5f2
commit
55b9969b82
@@ -0,0 +1,61 @@
|
||||
import path from 'node:path';
|
||||
|
||||
/**
|
||||
* ESLint formatter for GitHub Actions. Prints each problem as a readable line plus a workflow
|
||||
* command (`::error file=…`), so it shows up as an inline annotation in the PR diff.
|
||||
*
|
||||
* Unlike setup-node's `eslint-stylish` problem matcher, this also annotates parsing errors, which
|
||||
* have no rule id.
|
||||
*
|
||||
* Usage: eslint --format ./scripts/eslint/githubFormatter.mjs
|
||||
*/
|
||||
|
||||
/** Escape data for a workflow command, see https://github.com/actions/toolkit/blob/main/packages/core/src/command.ts */
|
||||
const escapeData = (/** @type {string} */ value) =>
|
||||
value.replaceAll('%', '%25').replaceAll('\r', '%0D').replaceAll('\n', '%0A');
|
||||
const escapeProperty = (/** @type {string} */ value) =>
|
||||
escapeData(value).replaceAll(':', '%3A').replaceAll(',', '%2C');
|
||||
|
||||
/** @type {import('eslint').ESLint.FormatterFunction} */
|
||||
const formatter = (results) => {
|
||||
const lines = [];
|
||||
let errors = 0;
|
||||
let warnings = 0;
|
||||
|
||||
for (const result of results) {
|
||||
const file = path.relative(process.cwd(), result.filePath);
|
||||
|
||||
for (const message of result.messages) {
|
||||
const severity = message.severity === 2 ? 'error' : 'warning';
|
||||
if (severity === 'error') errors++;
|
||||
else warnings++;
|
||||
|
||||
const rule = message.ruleId ?? 'parse';
|
||||
const line = message.line ?? 1;
|
||||
const column = message.column ?? 1;
|
||||
lines.push(`${file}:${line}:${column} ${severity} ${message.message} (${rule})`);
|
||||
|
||||
const properties = [
|
||||
`file=${escapeProperty(file)}`,
|
||||
`line=${line}`,
|
||||
`col=${column}`,
|
||||
message.endLine ? `endLine=${message.endLine}` : '',
|
||||
message.endColumn ? `endColumn=${message.endColumn}` : '',
|
||||
`title=${escapeProperty(`ESLint (${rule})`)}`,
|
||||
].filter(Boolean);
|
||||
lines.push(`::${severity} ${properties.join(',')}::${escapeData(message.message)}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (errors + warnings > 0) {
|
||||
const plural = (/** @type {number} */ count, /** @type {string} */ word) =>
|
||||
`${count} ${word}${count === 1 ? '' : 's'}`;
|
||||
lines.push(
|
||||
'',
|
||||
`✖ ${plural(errors + warnings, 'problem')} (${plural(errors, 'error')}, ${plural(warnings, 'warning')})`,
|
||||
);
|
||||
}
|
||||
return lines.join('\n');
|
||||
};
|
||||
|
||||
export default formatter;
|
||||
Reference in New Issue
Block a user