Skip to main content

JavaScript API: lint() and format()

Alongside the CLI the package exports an ESM-only JavaScript API, with TypeScript declarations. lint runs the same two checks and returns structured results without printing or exiting; format turns a result into the console output the CLI writes.

How do I run the checks from Node?​

import { lint, format } from '@ladamczyk/skillslint';

const result = await lint({ path: './skills', threshold: 70, stats: false });

process.stdout.write(await format(result));
process.exitCode = result.passed ? 0 : 1;

What options does lint() take?​

The same options as the CLI flags: path, threshold, the five per-category floors (overall, structure, clarity, specificity, advanced), fix and ignored. stats is required: the API never prompts, so you state consent yourself. See Usage statistics.

What does lint() return?​

result.passed; // boolean — textlint clean and every skill over its threshold
result.skills; // Array<{ name, scores: { overall, structure, clarity, specificity, advanced }, passed }>
result.textlint; // raw textlint lint/fix results
result.fixed; // whether it ran in fix mode

To list the skills that failed:

for (const skill of result.skills.filter((s) => !s.passed)) {
console.log(skill.name, skill.scores);
}

What else is exported?​

buildThreshold, failsThreshold, runTextlint, hasTextlintErrors, DEFAULT_PATH, DEFAULT_THRESHOLD, and the TypeScript types (ILintOptions, ILintResult, IScores, ISkillScore, IThreshold, TTextlintLintResult, TTextlintFixResult, TTextlintResults).