@actioneer/ads-lint 1.0.66 → 1.0.67
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 +5 -3
- package/bin/ads-lint.mjs +2 -63
- package/package.json +1 -1
- package/src/cli.mjs +72 -0
- package/src/rules/recipes.mjs +28 -0
package/README.md
CHANGED
|
@@ -10,8 +10,10 @@ isn't — so it works in a fresh repo before `npm i`.
|
|
|
10
10
|
|
|
11
11
|
## Install it at the same version as `@actioneer/ads`
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
and
|
|
13
|
+
From 1.0.67 the linter ships **inside** `@actioneer/ads`: run `npx ads lint`
|
|
14
|
+
(same flags as below) and there is nothing else to install. This package keeps
|
|
15
|
+
publishing the same code at the same version for projects that already use
|
|
16
|
+
`ads-lint`; install it at your `@actioneer/ads` version:
|
|
15
17
|
|
|
16
18
|
```bash
|
|
17
19
|
npm install -D @actioneer/ads-lint@<your @actioneer/ads version>
|
|
@@ -35,7 +37,7 @@ error (`versionCheck: false` in the config turns this off for a deliberate pin).
|
|
|
35
37
|
| Motion: `unbounded-transition`, `sluggish-easing`, `zero-scale-entrance`, `undersized-zoom-entrance`, `legacy-motion-token`, `raw-spring-config`, `layout-property-transition`, `layout-keyframe-disclosure` | error | P3 motion |
|
|
36
38
|
| Tables: `table-column-icon` (any `icon=` but `{null}`/`{undefined}`, or a glyph child), `table-cell-stacked` (`<br>`, a `flex-col`/`grid`/`space-y-*` stack of two, two children one of them block-level, an `<Avatar>`), `table-pagination` ("Page N of", "Rows per page", Previous + Next, "Next page" after a `Table`), plus the actions-column and record-name rules | error | tables |
|
|
37
39
|
| Collections: `collection-toolbar-missing` (a search/filter row or a header Search button with no `CollectionToolbar`), `search-full-width` (a full-width field typed search, led by the Search glyph, or labelled "Search…"), `page-content-top-padding` (class or `style` top spacing on the content or its first wrapper; a toolbar with no gap under an `mb-0` header) | error | P11, collection screens |
|
|
38
|
-
| Recipes: `call-panel-hand-rolled` (a Drawer with a Transcript or AudioWaveform — use `CallPanel`), `filter-menu-hand-rolled` (a Popover of Checkboxes — use the column filter or `Filters`), `filter-chip-clear-button` (a Chip with its own clear button — use `Chip onClose`), `script-opening-line-hand-rolled` (use `ScriptOpeningLine`), `script-character-limit` ("893 / 2,000,000 chars") | error | screen recipes |
|
|
40
|
+
| Recipes: `call-panel-hand-rolled` (a Drawer with a Transcript or AudioWaveform — use `CallPanel`), `filter-menu-hand-rolled` (a Popover of Checkboxes — use the column filter or `Filters`), `filter-chip-clear-button` (a Chip with its own clear button — use `Chip onClose`), `script-opening-line-hand-rolled` (use `ScriptOpeningLine`), `script-character-limit` ("893 / 2,000,000 chars"), `script-ai-review-hand-rolled` (a hand-drawn `<del>`/`<ins>` review — use `ScriptEditor mode="review"` + `ScriptReviewBar`), `script-ask-hand-rolled` (use `ScriptAskBar`) | error | screen recipes |
|
|
39
41
|
| `ads-lint-stale` — this linter is older than the installed `@actioneer/ads` | error | release lockstep |
|
|
40
42
|
| `collection-toolbar-icon-action` — an icon-only `Button` / `TooltipIconButton` in `CollectionToolbar actions` that is not `SearchDisclosure`, `Filters` or `TableColumnsMenu` (a setting such as Caller numbers is a labelled header button) | error | collection screens, workspace setting modals |
|
|
41
43
|
| `modal-footer-done` — a `ModalFooter` whose only action is a `Button` (or `ModalClose`) labelled Done, Close, OK or Got it | error | workspace setting modals |
|
package/bin/ads-lint.mjs
CHANGED
|
@@ -12,67 +12,6 @@
|
|
|
12
12
|
// Config: ads-lint.config.mjs at the repo root (deep-merged over defaults).
|
|
13
13
|
|
|
14
14
|
import process from "node:process";
|
|
15
|
-
import {
|
|
16
|
-
import { resolveFiles, lintFiles, formatFindings } from "../src/runner.mjs";
|
|
17
|
-
import { staleLinterFinding } from "../src/version-check.mjs";
|
|
15
|
+
import { runLint } from "../src/cli.mjs";
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
const opts = { files: [], staged: false, diff: null, all: false, strict: false, quiet: false };
|
|
21
|
-
for (let i = 0; i < argv.length; i++) {
|
|
22
|
-
const a = argv[i];
|
|
23
|
-
if (a === "--staged") opts.staged = true;
|
|
24
|
-
else if (a === "--all") opts.all = true;
|
|
25
|
-
else if (a === "--strict") opts.strict = true;
|
|
26
|
-
else if (a === "--quiet") opts.quiet = true;
|
|
27
|
-
else if (a === "--diff") opts.diff = argv[++i];
|
|
28
|
-
else if (a === "-h" || a === "--help") opts.help = true;
|
|
29
|
-
else if (a.startsWith("-")) {
|
|
30
|
-
console.error(`ads-lint: unknown flag ${a}`);
|
|
31
|
-
process.exit(2);
|
|
32
|
-
} else opts.files.push(a);
|
|
33
|
-
}
|
|
34
|
-
return opts;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const HELP = `ads-lint — Actioneer Design System linter
|
|
38
|
-
|
|
39
|
-
ads-lint [files...] Lint the given files
|
|
40
|
-
ads-lint --staged Lint files staged for commit
|
|
41
|
-
ads-lint --diff <ref> Lint files changed vs <ref> (e.g. origin/main)
|
|
42
|
-
ads-lint --all Lint everything under the configured root
|
|
43
|
-
ads-lint --strict Fail on warnings too (default: errors only)
|
|
44
|
-
ads-lint --quiet Print only the summary line`;
|
|
45
|
-
|
|
46
|
-
async function main() {
|
|
47
|
-
const opts = parseArgs(process.argv.slice(2));
|
|
48
|
-
if (opts.help) {
|
|
49
|
-
console.log(HELP);
|
|
50
|
-
return 0;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const cwd = process.cwd();
|
|
54
|
-
const cfg = await loadConfig(cwd);
|
|
55
|
-
const files = resolveFiles(opts, cfg, cwd);
|
|
56
|
-
const { findings, fileCount } = lintFiles(files, cfg, cwd);
|
|
57
|
-
// An older linter than the installed ADS skips every newer rule: say so first.
|
|
58
|
-
const stale = staleLinterFinding(cwd, cfg);
|
|
59
|
-
if (stale) findings.unshift(stale);
|
|
60
|
-
|
|
61
|
-
const errors = findings.filter((f) => f.severity === "error");
|
|
62
|
-
const warns = findings.filter((f) => f.severity === "warn");
|
|
63
|
-
|
|
64
|
-
if (findings.length && !opts.quiet) {
|
|
65
|
-
console.error(formatFindings(findings));
|
|
66
|
-
console.error("");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const summary = `ads-lint: ${fileCount} file(s) · ${errors.length} error(s) · ${warns.length} warning(s)`;
|
|
70
|
-
if (errors.length || (opts.strict && warns.length)) {
|
|
71
|
-
console.error(summary);
|
|
72
|
-
return 1;
|
|
73
|
-
}
|
|
74
|
-
console.log(summary);
|
|
75
|
-
return 0;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
main().then((code) => process.exit(code));
|
|
17
|
+
runLint(process.argv.slice(2)).then((code) => process.exit(code));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actioneer/ads-lint",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.67",
|
|
4
4
|
"description": "Design linter for the Actioneer Design System (ADS 1.0). Ships in lockstep with @actioneer/ads: install the same version. Flags deviations from ADS principles on changed files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/cli.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// ads-lint CLI — the command, as a function. Both the ads-lint bin and
|
|
2
|
+
// `npx @actioneer/ads lint` call runLint(argv), so the two never diverge.
|
|
3
|
+
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { loadConfig } from "./config.mjs";
|
|
6
|
+
import { resolveFiles, lintFiles, formatFindings } from "./runner.mjs";
|
|
7
|
+
import { staleLinterFinding } from "./version-check.mjs";
|
|
8
|
+
|
|
9
|
+
function parseArgs(argv) {
|
|
10
|
+
const opts = { files: [], staged: false, diff: null, all: false, strict: false, quiet: false };
|
|
11
|
+
for (let i = 0; i < argv.length; i++) {
|
|
12
|
+
const a = argv[i];
|
|
13
|
+
if (a === "--staged") opts.staged = true;
|
|
14
|
+
else if (a === "--all") opts.all = true;
|
|
15
|
+
else if (a === "--strict") opts.strict = true;
|
|
16
|
+
else if (a === "--quiet") opts.quiet = true;
|
|
17
|
+
else if (a === "--diff") opts.diff = argv[++i];
|
|
18
|
+
else if (a === "-h" || a === "--help") opts.help = true;
|
|
19
|
+
else if (a.startsWith("-")) {
|
|
20
|
+
console.error(`ads-lint: unknown flag ${a}`);
|
|
21
|
+
process.exit(2);
|
|
22
|
+
} else opts.files.push(a);
|
|
23
|
+
}
|
|
24
|
+
return opts;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const HELP = `ads-lint — Actioneer Design System linter
|
|
28
|
+
|
|
29
|
+
ads-lint [files...] Lint the given files
|
|
30
|
+
ads-lint --staged Lint files staged for commit
|
|
31
|
+
ads-lint --diff <ref> Lint files changed vs <ref> (e.g. origin/main)
|
|
32
|
+
ads-lint --all Lint everything under the configured root
|
|
33
|
+
ads-lint --strict Fail on warnings too (default: errors only)
|
|
34
|
+
ads-lint --quiet Print only the summary line`;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Run the linter with CLI arguments (without the program name).
|
|
38
|
+
* @param {string[]} argv
|
|
39
|
+
* @param {{prog?: string}} [opts]
|
|
40
|
+
* @returns {Promise<number>} exit code
|
|
41
|
+
*/
|
|
42
|
+
export async function runLint(argv, { prog = "ads-lint" } = {}) {
|
|
43
|
+
const opts = parseArgs(argv);
|
|
44
|
+
if (opts.help) {
|
|
45
|
+
console.log(prog === "ads-lint" ? HELP : HELP.replaceAll("ads-lint ", `${prog} `));
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const cwd = process.cwd();
|
|
50
|
+
const cfg = await loadConfig(cwd);
|
|
51
|
+
const files = resolveFiles(opts, cfg, cwd);
|
|
52
|
+
const { findings, fileCount } = lintFiles(files, cfg, cwd);
|
|
53
|
+
// An older linter than the installed ADS skips every newer rule: say so first.
|
|
54
|
+
const stale = staleLinterFinding(cwd, cfg);
|
|
55
|
+
if (stale) findings.unshift(stale);
|
|
56
|
+
|
|
57
|
+
const errors = findings.filter((f) => f.severity === "error");
|
|
58
|
+
const warns = findings.filter((f) => f.severity === "warn");
|
|
59
|
+
|
|
60
|
+
if (findings.length && !opts.quiet) {
|
|
61
|
+
console.error(formatFindings(findings));
|
|
62
|
+
console.error("");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const summary = `ads-lint: ${fileCount} file(s) · ${errors.length} error(s) · ${warns.length} warning(s)`;
|
|
66
|
+
if (errors.length || (opts.strict && warns.length)) {
|
|
67
|
+
console.error(summary);
|
|
68
|
+
return 1;
|
|
69
|
+
}
|
|
70
|
+
console.log(summary);
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
package/src/rules/recipes.mjs
CHANGED
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
// words at the foot ("526 characters"); ScriptStart and ScriptDocument do.
|
|
19
19
|
// - script-opening-line-hand-rolled: an "Opening line" label drawn by hand.
|
|
20
20
|
// Use ScriptOpeningLine (editable on a draft, read-only once running).
|
|
21
|
+
// - script-ai-review-hand-rolled: a script's AI changes drawn by hand with
|
|
22
|
+
// <del>/<ins>. Use ScriptEditor mode="review" with ScriptReviewBar.
|
|
23
|
+
// - script-ask-hand-rolled: an "Ask for a change" field drawn by hand. Use
|
|
24
|
+
// ScriptAskBar.
|
|
21
25
|
|
|
22
26
|
import { matchesAny } from "../config.mjs";
|
|
23
27
|
import { elementEnd } from "../jsx.mjs";
|
|
@@ -53,6 +57,18 @@ export const RECIPE_RULES = [
|
|
|
53
57
|
guidance:
|
|
54
58
|
"The opening line is the ADS ScriptOpeningLine — editable on a draft, read-only once the campaign runs, with its word count and info icon. Never draw the \"Opening line\" label and field by hand.",
|
|
55
59
|
},
|
|
60
|
+
{
|
|
61
|
+
name: "script-ai-review-hand-rolled",
|
|
62
|
+
severity: "error",
|
|
63
|
+
guidance:
|
|
64
|
+
"Review the AI's changes to a script in the ADS ScriptEditor: mode=\"review\" with `changes` (ScriptChange[]), `undone` and onToggleChange shows removals struck through on red and additions on green with Undo on each, and ScriptReviewBar carries Discard and Update script (applyScriptChanges builds the result). Never draw the <del>/<ins> review by hand.",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "script-ask-hand-rolled",
|
|
68
|
+
severity: "error",
|
|
69
|
+
guidance:
|
|
70
|
+
"Asking the AI to change a script is the ADS ScriptAskBar (`value`, `onChange`, `onSubmit`, `busy`) under the script in edit mode and on the saved script; while the AI works, ScriptAIStatus takes its place. Never a hand-drawn input with a send button.",
|
|
71
|
+
},
|
|
56
72
|
{
|
|
57
73
|
name: "alert-hand-rolled",
|
|
58
74
|
severity: "error",
|
|
@@ -141,6 +157,18 @@ export function lintRecipes(relPath, source, cfg) {
|
|
|
141
157
|
if (m) push("script-opening-line-hand-rolled", m.index, m[0]);
|
|
142
158
|
}
|
|
143
159
|
|
|
160
|
+
// script-ai-review-hand-rolled: <del> and <ins> in a script screen without ScriptEditor.
|
|
161
|
+
if (/<del\b/.test(source) && /<ins\b/.test(source) && /script/i.test(source) && !/<ScriptEditor(?![\w.])/.test(source)) {
|
|
162
|
+
const at = source.search(/<del\b/);
|
|
163
|
+
push("script-ai-review-hand-rolled", at, "<del> … <ins>");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// script-ask-hand-rolled: an "Ask for a change" placeholder without ScriptAskBar.
|
|
167
|
+
if (!/<ScriptAskBar(?![\w.])/.test(source)) {
|
|
168
|
+
const m = /placeholder=["'{`][^"'`]*Ask (?:for a change|the AI to (?:change|write))/.exec(source);
|
|
169
|
+
if (m) push("script-ask-hand-rolled", m.index, m[0]);
|
|
170
|
+
}
|
|
171
|
+
|
|
144
172
|
// alert-hand-rolled: a status-tinted container holding a status glyph.
|
|
145
173
|
for (const m of source.matchAll(/<div\b[^>]*className=(?:"[^"]*|\{`[^`]*|\{cn\([^)]*)\bbg-(?:warning|danger|info|success)(?:-50|-100|\/\d+)\b/g)) {
|
|
146
174
|
// An icon disc (rounded-full) is an illustration, not a banner.
|