@actioneer/ads-lint 1.0.65 → 1.0.66
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 +3 -2
- package/package.json +1 -1
- package/src/config.mjs +3 -0
- package/src/index.mjs +2 -1
- package/src/rules/buttons.mjs +33 -5
- package/src/rules/literals.mjs +13 -0
- package/src/rules/overrides.mjs +43 -0
- package/src/rules/tables.mjs +1 -1
- package/src/runner.mjs +16 -6
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ error (`versionCheck: false` in the config turns this off for a deliberate pin).
|
|
|
29
29
|
| `deep-import` — reaching past the barrel (`@actioneer/ads/button`) | error | P7 |
|
|
30
30
|
| `barrel-default-import` / `-namespace-import` / `-aliased-import` | error | P7 |
|
|
31
31
|
| `icon-package-import` — importing Phosphor or another icon package outside the registry | error | P4 icons |
|
|
32
|
-
| `hardcoded-hex` — a raw `#rrggbb` in code | error | tokens-only |
|
|
32
|
+
| `hardcoded-hex` — a raw `#rrggbb` in code (not in comments: "PR #836" is not a color) | error | tokens-only |
|
|
33
33
|
| `arbitrary-color` — `bg-[#fff]` / `text-[rgb(...)]` | error | tokens-only |
|
|
34
34
|
| `arbitrary-dimension` — `w-[13px]` / `gap-[1.5rem]` | warn | tokens-only |
|
|
35
35
|
| 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 |
|
|
@@ -47,7 +47,8 @@ error (`versionCheck: false` in the config turns this off for a deliberate pin).
|
|
|
47
47
|
| `shadow-static-surface` — `shadow-card` on a `div`/`section`/`Card` nobody can press (no `onClick`, `href`, `isPressable`, `role="button"`) | error | elevation |
|
|
48
48
|
| `selected-edge-action` — a strong `border`/`ring`/`outline` on a selection prefix (`aria-selected:`, `data-[state=on]:` …) or in a `selected ? "…"` / `isActive && "…"` class | error | selection |
|
|
49
49
|
| `insight-findings-hand-rolled` (a "What changed" heading without `InsightFindings`), `insight-finding-action` (a button or link inside `InsightFindings`), `monitor-outcome-grid` ("Outcome distribution", an outcomes-by-day table) | error | charts, P15 Program dashboard |
|
|
50
|
-
| `chart-dual-axis` (any `dualAxis` but `{false}`), `export-button-no-icon` (`Export`, `{"Export"}`, `{t("export")}`, "Download CSV"), `empty-state-no-description` (missing or empty) | error | charts, P8 |
|
|
50
|
+
| `chart-dual-axis` (any `dualAxis` but `{false}`), `export-button-no-icon` (`Export`, `{"Export"}`, `{t("export")}`, "Download CSV"), `empty-state-no-description` (missing or empty), `link-underline` (`underline` / `hover:underline` on an `<a>`, `<Link>` or `<button>`) | error | charts, P4, P8 |
|
|
51
|
+
| `ads-internal-override` (`[&_[data-slot=…]]`, `[&>[data-slot=…]]` restyling an ADS component from outside; `overrides.allow` exempts the library itself) | error | P7 |
|
|
51
52
|
| Screen kinds: every rule of the declared kind (`screen-collection-…`, `screen-monitor-…` — order, required parts, forbidden parts, one hero, charts in `ChartCard`), `screen-kind-unknown`, and `screen-kind-missing` (warn: a `BodyPageHeader` screen with a `Table`, `StatStrip` or `ChartCard` that never declares its kind). The rules are generated from `@actioneer/ads`'s `SCREEN_KINDS`, the same rules `AdsScreen` checks at runtime | error / warn | P16, screen kinds |
|
|
52
53
|
|
|
53
54
|
Errors fail the run (exit 1); warnings don't unless `--strict`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actioneer/ads-lint",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.66",
|
|
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/config.mjs
CHANGED
|
@@ -107,6 +107,9 @@ export const DEFAULT_CONFIG = {
|
|
|
107
107
|
tableAllow: ["src/components/**"],
|
|
108
108
|
},
|
|
109
109
|
buttons: { enabled: true, allow: [] },
|
|
110
|
+
// Restyling an ADS component from outside through its slots (2026-12-01).
|
|
111
|
+
// The library styles its own parts; products never do.
|
|
112
|
+
overrides: { enabled: true, allow: ["src/components/**"] },
|
|
110
113
|
// Selected items take the subtle T5 edge (border-border-selected).
|
|
111
114
|
selection: { enabled: true, allow: [] },
|
|
112
115
|
// shadow-ask is the AskActioneer button's own lift (user-mandated 2026-11-29):
|
package/src/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// eventual ESLint bridge). The CLI in bin/ads-lint.mjs is a thin wrapper.
|
|
3
3
|
|
|
4
4
|
export { loadConfig, DEFAULT_CONFIG } from "./config.mjs";
|
|
5
|
-
export { resolveFiles, lintFiles, formatFindings } from "./runner.mjs";
|
|
5
|
+
export { resolveFiles, lintFiles, lintSource, RULE_FNS, formatFindings } from "./runner.mjs";
|
|
6
6
|
export { lintImports } from "./rules/imports.mjs";
|
|
7
7
|
export { lintMotion } from "./rules/motion.mjs";
|
|
8
8
|
export { lintLiterals } from "./rules/literals.mjs";
|
|
@@ -18,4 +18,5 @@ export { lintControls, CONTROL_RULES } from "./rules/controls.mjs";
|
|
|
18
18
|
export { staleLinterFinding, compareVersions, VERSION_RULE } from "./version-check.mjs";
|
|
19
19
|
export { lintRecipes, RECIPE_RULES } from "./rules/recipes.mjs";
|
|
20
20
|
export { lintScreens, SCREEN_RULES } from "./rules/screens.mjs";
|
|
21
|
+
export { lintOverrides, OVERRIDE_RULES } from "./rules/overrides.mjs";
|
|
21
22
|
export { SCREEN_KINDS, validateScreen } from "./screen-grammar.gen.mjs";
|
package/src/rules/buttons.mjs
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
// Buttons are text-only by default (principle 8), with one named exception:
|
|
4
4
|
// an Export action always leads with the Download glyph, so it reads as "this
|
|
5
5
|
// gives you a file" at a glance and looks the same on every screen.
|
|
6
|
+
//
|
|
7
|
+
// Text links never underline (principle 4; user-reported 2026-11-30 on the
|
|
8
|
+
// Voice campaigns list, where every Journey cell was underlined): a link reads
|
|
9
|
+
// as a bare label that turns teal on hover, like the ADS link Button. A table
|
|
10
|
+
// row's record name doesn't underline either (user-mandated 2026-12-01), so
|
|
11
|
+
// buttons styled as text links are checked too.
|
|
6
12
|
|
|
7
13
|
import { matchesAny } from "../config.mjs";
|
|
8
14
|
|
|
@@ -13,13 +19,19 @@ export const BUTTON_RULES = [
|
|
|
13
19
|
guidance:
|
|
14
20
|
"Lead every Export button with the Download glyph: `<Button variant=\"outline\" startContent={<Download />}>Export</Button>` (Download from @/lib/icons). On a page it sits in the header bar, with the page's filters to its right.",
|
|
15
21
|
},
|
|
22
|
+
{
|
|
23
|
+
name: "link-underline",
|
|
24
|
+
severity: "error",
|
|
25
|
+
guidance:
|
|
26
|
+
"Text links never underline (principle 4). Drop `underline` / `hover:underline`: a link is a bare label that turns teal on hover — `text-on-white-primary hover:text-action-primary-text` (or the ADS `Button variant=\"link\"`). A record's name in its own column is `TableRecordName`, which turns teal on hover without an underline (2026-12-01).",
|
|
27
|
+
},
|
|
16
28
|
];
|
|
17
29
|
|
|
18
30
|
const RULE = Object.fromEntries(BUTTON_RULES.map((r) => [r.name, r]));
|
|
19
31
|
|
|
20
|
-
/** Finds each `<Button …>` opening tag, attribute expressions included, and the text after it. */
|
|
21
|
-
function* buttonTags(source) {
|
|
22
|
-
for (const m of source.matchAll(
|
|
32
|
+
/** Finds each `<Button …>` (or other named) opening tag, attribute expressions included, and the text after it. */
|
|
33
|
+
function* buttonTags(source, pattern = /<Button\b/g) {
|
|
34
|
+
for (const m of source.matchAll(pattern)) {
|
|
23
35
|
let i = m.index + m[0].length;
|
|
24
36
|
let depth = 0;
|
|
25
37
|
let quote = null;
|
|
@@ -56,9 +68,25 @@ export function lintButtons(relPath, source, cfg) {
|
|
|
56
68
|
if (cfg.buttons?.enabled === false) return [];
|
|
57
69
|
if (matchesAny(relPath, cfg.buttons?.allow ?? [])) return [];
|
|
58
70
|
if (!/\.(tsx|jsx)$/.test(relPath)) return [];
|
|
59
|
-
if (!/<Button\b/.test(source)) return [];
|
|
60
|
-
|
|
61
71
|
const findings = [];
|
|
72
|
+
// A link styled with an underline: `underline` or any `…:underline` variant,
|
|
73
|
+
// never `no-underline` or `underline-offset-*`.
|
|
74
|
+
for (const { index, tag } of buttonTags(source, /<(?:a|Link|NextLink|button)\b/g)) {
|
|
75
|
+
const cls = tag.match(/\bclassName=(?:"([^"]*)"|\{([\s\S]*?)\}(?=\s|\/?>))/);
|
|
76
|
+
if (!cls) continue;
|
|
77
|
+
const text = cls[1] ?? cls[2] ?? "";
|
|
78
|
+
if (!/(?:^|[\s"'`:])underline(?![-\w])/.test(text.replace(/\bno-underline\b/g, ""))) continue;
|
|
79
|
+
const match = tag.replace(/\s+/g, " ");
|
|
80
|
+
findings.push({
|
|
81
|
+
line: source.slice(0, index).split("\n").length,
|
|
82
|
+
rule: "link-underline",
|
|
83
|
+
severity: RULE["link-underline"].severity,
|
|
84
|
+
match: match.length > 80 ? `${match.slice(0, 77)}...` : match,
|
|
85
|
+
guidance: RULE["link-underline"].guidance,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (!/<Button\b/.test(source)) return findings;
|
|
89
|
+
|
|
62
90
|
for (const { index, tag, label } of buttonTags(source)) {
|
|
63
91
|
if (tag.endsWith("/>")) continue;
|
|
64
92
|
if (!isExportLabel(label)) continue;
|
package/src/rules/literals.mjs
CHANGED
|
@@ -29,6 +29,17 @@ function lineOf(source, index) {
|
|
|
29
29
|
return source.slice(0, index).split("\n").length;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// True when `index` sits inside a code comment: a `//` line comment (not the
|
|
33
|
+
// `//` of a URL such as https://) or a `/* … */` block. Comments name issue and
|
|
34
|
+
// pull-request numbers ("backend #626"), which read as 3-digit hex colors.
|
|
35
|
+
function inComment(source, index) {
|
|
36
|
+
const lineStart = source.lastIndexOf("\n", index - 1) + 1;
|
|
37
|
+
const before = source.slice(lineStart, index);
|
|
38
|
+
if (/^\s*(?:\/\/|\/\*|\*)/.test(before)) return true;
|
|
39
|
+
if (/(?:^|[^:])\/\//.test(before)) return true;
|
|
40
|
+
return source.lastIndexOf("/*", index) > source.lastIndexOf("*/", index);
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
export function lintLiterals(relPath, source, cfg) {
|
|
33
44
|
const c = cfg.literals ?? {};
|
|
34
45
|
if (matchesAny(relPath, c.allow ?? [])) return [];
|
|
@@ -44,6 +55,8 @@ export function lintLiterals(relPath, source, cfg) {
|
|
|
44
55
|
if (prev === "[" || prev === "." || prev === "#") continue;
|
|
45
56
|
// DOM selector / URL-fragment argument, not a color value.
|
|
46
57
|
if (NON_COLOR_CTX.test(source.slice(Math.max(0, m.index - 48), m.index))) continue;
|
|
58
|
+
// Issue and pull-request numbers in comments, not colors.
|
|
59
|
+
if (inComment(source, m.index)) continue;
|
|
47
60
|
findings.push({
|
|
48
61
|
line: lineOf(source, m.index),
|
|
49
62
|
rule: "hardcoded-hex",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Reaching inside ADS components (user-reported 2026-12-01).
|
|
2
|
+
//
|
|
3
|
+
// A product that styles an ADS component's insides through its slots —
|
|
4
|
+
// `[&_[data-slot=stat-sparkline]]:w-16`, `[&>[data-slot=panel]]:rounded-none` —
|
|
5
|
+
// hides a gap in ADS instead of reporting it. Research Analyst squeezed the
|
|
6
|
+
// StatStrip sparklines and slimmed the Call funnel this way: the page looked
|
|
7
|
+
// fixed, ADS never learned it broke at 916px, and the next app hit it again.
|
|
8
|
+
// Fix the component (a prop, a container query) and use it as shipped.
|
|
9
|
+
|
|
10
|
+
import { matchesAny } from "../config.mjs";
|
|
11
|
+
|
|
12
|
+
export const OVERRIDE_RULES = [
|
|
13
|
+
{
|
|
14
|
+
name: "ads-internal-override",
|
|
15
|
+
severity: "error",
|
|
16
|
+
guidance:
|
|
17
|
+
"Don't restyle an ADS component from outside through its slots (`[&_[data-slot=…]]`, `[&>[data-slot=…]]`). If it looks wrong at your size, the fix belongs in ADS — a prop such as FunnelBarsHorizontal size=\"sm\", or a layout rule in the component — so every app gets it. Report it and use the component as shipped.",
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const RULE = Object.fromEntries(OVERRIDE_RULES.map((r) => [r.name, r]));
|
|
22
|
+
|
|
23
|
+
// An arbitrary variant that targets a data-slot inside the element:
|
|
24
|
+
// [&_[data-slot=x]]:…, [&>[data-slot=x]]:…, [&_[data-slot]]:…, [&_*[data-slot=x]]:…
|
|
25
|
+
const SLOT_VARIANT = /\[&(?:_|>|\s)[^\]\s"'`]*\[data-slot(?:[=~^$*|]?=[^\]]*)?\][^\s"'`]*\]:[^\s"'`]+/g;
|
|
26
|
+
|
|
27
|
+
export function lintOverrides(relPath, source, cfg) {
|
|
28
|
+
if (cfg.overrides?.enabled === false) return [];
|
|
29
|
+
if (matchesAny(relPath, cfg.overrides?.allow ?? [])) return [];
|
|
30
|
+
if (!/\.(tsx|jsx|ts|js)$/.test(relPath)) return [];
|
|
31
|
+
if (!source.includes("data-slot")) return [];
|
|
32
|
+
const findings = [];
|
|
33
|
+
for (const m of source.matchAll(SLOT_VARIANT)) {
|
|
34
|
+
findings.push({
|
|
35
|
+
line: source.slice(0, m.index).split("\n").length,
|
|
36
|
+
rule: "ads-internal-override",
|
|
37
|
+
severity: RULE["ads-internal-override"].severity,
|
|
38
|
+
match: m[0].length > 80 ? `${m[0].slice(0, 77)}...` : m[0],
|
|
39
|
+
guidance: RULE["ads-internal-override"].guidance,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return findings;
|
|
43
|
+
}
|
package/src/rules/tables.mjs
CHANGED
|
@@ -96,7 +96,7 @@ export const TABLE_RULES = [
|
|
|
96
96
|
name: "table-record-name-missing",
|
|
97
97
|
severity: "error",
|
|
98
98
|
guidance:
|
|
99
|
-
"A row that opens its record (a page or a detail panel) shows its name as <TableRecordName onOpen={…} opens=\"page\"|\"panel\"> — the name
|
|
99
|
+
"A row that opens its record (a page or a detail panel) shows its name as <TableRecordName onOpen={…} opens=\"page\"|\"panel\"> — the name turns teal on hover (never underlined) and the open button says where it goes. A bare text name with a row onClick gives no visible way in.",
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
name: "table-cell-two-values",
|
package/src/runner.mjs
CHANGED
|
@@ -18,8 +18,9 @@ import { lintElevation } from "./rules/elevation.mjs";
|
|
|
18
18
|
import { lintControls } from "./rules/controls.mjs";
|
|
19
19
|
import { lintRecipes } from "./rules/recipes.mjs";
|
|
20
20
|
import { lintScreens } from "./rules/screens.mjs";
|
|
21
|
+
import { lintOverrides } from "./rules/overrides.mjs";
|
|
21
22
|
|
|
22
|
-
const RULE_FNS = [lintImports, lintMotion, lintLiterals, lintModals, lintTables, lintEmptyStates, lintCharts, lintButtons, lintCollections, lintSelection, lintElevation, lintControls, lintRecipes, lintScreens];
|
|
23
|
+
export const RULE_FNS = [lintImports, lintMotion, lintLiterals, lintModals, lintTables, lintEmptyStates, lintCharts, lintButtons, lintCollections, lintSelection, lintElevation, lintControls, lintRecipes, lintScreens, lintOverrides];
|
|
23
24
|
|
|
24
25
|
function toPosix(p) {
|
|
25
26
|
return p.split(path.sep).join("/");
|
|
@@ -93,17 +94,26 @@ export function resolveFiles(opts, cfg, cwd) {
|
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Run EVERY rule on one source string. The CLI and the MCP lint_snippet tool
|
|
99
|
+
* both go through here, so an agent's self-check sees the same rules CI does
|
|
100
|
+
* (ads-mcp once ran three of fifteen groups and passed screens CI rejected).
|
|
101
|
+
*/
|
|
102
|
+
export function lintSource(relPath, source, cfg) {
|
|
103
|
+
const findings = [];
|
|
104
|
+
for (const fn of RULE_FNS) {
|
|
105
|
+
for (const f of fn(relPath, source, cfg)) findings.push({ file: relPath, ...f });
|
|
106
|
+
}
|
|
107
|
+
return findings;
|
|
108
|
+
}
|
|
109
|
+
|
|
96
110
|
/** Lint one resolved file set. Returns { findings, fileCount }. */
|
|
97
111
|
export function lintFiles(absFiles, cfg, cwd) {
|
|
98
112
|
const findings = [];
|
|
99
113
|
for (const abs of absFiles) {
|
|
100
114
|
const rel = toPosix(path.relative(cwd, abs));
|
|
101
115
|
const source = fs.readFileSync(abs, "utf8");
|
|
102
|
-
|
|
103
|
-
for (const f of fn(rel, source, cfg)) {
|
|
104
|
-
findings.push({ file: rel, ...f });
|
|
105
|
-
}
|
|
106
|
-
}
|
|
116
|
+
findings.push(...lintSource(rel, source, cfg));
|
|
107
117
|
}
|
|
108
118
|
findings.sort(
|
|
109
119
|
(a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.rule.localeCompare(b.rule)
|