@bfrs/agentic-components 0.6.5 → 0.6.6
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/BFRS_AGENTIC_COMPONENTS.md +56 -12
- package/README.md +13 -0
- package/dist/components/data-display/DataTable/TableViewSelector.d.ts +1 -1
- package/dist/custom-elements.js +6957 -6988
- package/dist/custom-elements.js.map +1 -1
- package/dist/index.js +5164 -5195
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +9 -6
- package/scripts/lint/cli.cjs +894 -0
- package/scripts/postinstall.cjs +79 -2
|
@@ -0,0 +1,894 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { execFileSync } = require("node:child_process");
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const postcss = require("postcss");
|
|
8
|
+
const ts = require("typescript");
|
|
9
|
+
|
|
10
|
+
const STYLE_EXTENSIONS = new Set([".css", ".scss", ".sass", ".less"]);
|
|
11
|
+
const UI_EXTENSIONS = new Set([".tsx", ".jsx"]);
|
|
12
|
+
const TOKEN_SOURCE_EXTENSIONS = new Set([".ts", ".tsx", ".jsx", ".css", ".scss", ".sass", ".less"]);
|
|
13
|
+
const CUSTOM_SOURCE_EXTENSIONS = new Set([".ts", ".tsx", ".jsx"]);
|
|
14
|
+
|
|
15
|
+
const STYLE_EXCEPTION_MARKER = "lint-ignore: library-style-overrides";
|
|
16
|
+
const UI_EXCEPTION_MARKER = "lint-ignore: library-ui";
|
|
17
|
+
const THEME_TOKEN_EXCEPTION_MARKER = "lint-ignore: theme-token";
|
|
18
|
+
const LIBRARY_COMPONENT_EXCEPTION_MARKER = "lint-ignore: library-component";
|
|
19
|
+
|
|
20
|
+
const STYLE_ALLOWLISTED_FILES = new Set([
|
|
21
|
+
"src/theme/bfrs-tailwind-theme.css",
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const THEME_TOKEN_ALLOWLISTED_FILES = new Set([
|
|
25
|
+
"src/theme/bfrs-tailwind-theme.css",
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
function runGit(gitArgs, cwd) {
|
|
29
|
+
try {
|
|
30
|
+
const output = execFileSync("git", gitArgs, { cwd, encoding: "utf8" }).trim();
|
|
31
|
+
return output ? output.split(/\r?\n/).filter(Boolean) : [];
|
|
32
|
+
} catch {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function toPosixPath(filePath) {
|
|
38
|
+
return filePath.split(path.sep).join("/");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function normalizeInputFile(filePath, cwd) {
|
|
42
|
+
const absolutePath = path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
|
|
43
|
+
const relativePath = path.relative(cwd, absolutePath);
|
|
44
|
+
const filePathForOutput =
|
|
45
|
+
relativePath && !relativePath.startsWith("..") && !path.isAbsolute(relativePath)
|
|
46
|
+
? toPosixPath(relativePath)
|
|
47
|
+
: toPosixPath(absolutePath);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
filePath: filePathForOutput,
|
|
51
|
+
absolutePath,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getTargetFiles(argv, cwd, extensions, allowlistedFiles = new Set()) {
|
|
56
|
+
const explicitFiles = argv.filter((arg) => !arg.startsWith("-"));
|
|
57
|
+
const files = explicitFiles.length > 0 ? explicitFiles : runGit(["ls-files", "src"], cwd);
|
|
58
|
+
|
|
59
|
+
return files
|
|
60
|
+
.map((filePath) => normalizeInputFile(filePath, cwd))
|
|
61
|
+
.filter(({ filePath, absolutePath }) => extensions.has(path.extname(filePath)) && fs.existsSync(absolutePath))
|
|
62
|
+
.filter(({ filePath }) => !allowlistedFiles.has(filePath))
|
|
63
|
+
.sort((a, b) => a.filePath.localeCompare(b.filePath));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function normalizeSelector(selector) {
|
|
67
|
+
return selector.trim().replace(/\s+/g, " ");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function normalizeValue(value) {
|
|
71
|
+
return String(value || "").trim().replace(/\s+/g, " ");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function splitSelectorList(selectorText) {
|
|
75
|
+
const selectors = [];
|
|
76
|
+
let current = "";
|
|
77
|
+
let bracketDepth = 0;
|
|
78
|
+
let parenDepth = 0;
|
|
79
|
+
let quote = "";
|
|
80
|
+
let escaped = false;
|
|
81
|
+
|
|
82
|
+
for (const char of selectorText) {
|
|
83
|
+
if (escaped) {
|
|
84
|
+
current += char;
|
|
85
|
+
escaped = false;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (char === "\\") {
|
|
90
|
+
current += char;
|
|
91
|
+
escaped = true;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (quote) {
|
|
96
|
+
current += char;
|
|
97
|
+
if (char === quote) quote = "";
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (char === "\"" || char === "'") {
|
|
102
|
+
current += char;
|
|
103
|
+
quote = char;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (char === "[") bracketDepth += 1;
|
|
108
|
+
if (char === "]" && bracketDepth > 0) bracketDepth -= 1;
|
|
109
|
+
if (char === "(") parenDepth += 1;
|
|
110
|
+
if (char === ")" && parenDepth > 0) parenDepth -= 1;
|
|
111
|
+
|
|
112
|
+
if (char === "," && bracketDepth === 0 && parenDepth === 0) {
|
|
113
|
+
if (current.trim()) selectors.push(current.trim());
|
|
114
|
+
current = "";
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
current += char;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (current.trim()) selectors.push(current.trim());
|
|
122
|
+
return selectors;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function isIdentifierChar(char) {
|
|
126
|
+
return /[A-Za-z0-9_-]/.test(char);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function isIdentifierStart(char) {
|
|
130
|
+
return /[A-Za-z_-]/.test(char);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function previousNonWhitespaceIndex(input, startIndex) {
|
|
134
|
+
for (let index = startIndex - 1; index >= 0; index -= 1) {
|
|
135
|
+
if (!/\s/.test(input[index])) return index;
|
|
136
|
+
}
|
|
137
|
+
return -1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function isInsideNonSelectorFunction(selector, index) {
|
|
141
|
+
const before = selector.slice(0, index);
|
|
142
|
+
const match = before.match(/:{1,2}([A-Za-z-]+)\([^()]*$/);
|
|
143
|
+
if (!match) return false;
|
|
144
|
+
|
|
145
|
+
return new Set([
|
|
146
|
+
"dir",
|
|
147
|
+
"lang",
|
|
148
|
+
"nth-child",
|
|
149
|
+
"nth-last-child",
|
|
150
|
+
"nth-last-of-type",
|
|
151
|
+
"nth-of-type",
|
|
152
|
+
"part",
|
|
153
|
+
]).has(match[1].toLowerCase());
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function findElementSelectors(selector) {
|
|
157
|
+
const matches = [];
|
|
158
|
+
let bracketDepth = 0;
|
|
159
|
+
let quote = "";
|
|
160
|
+
let escaped = false;
|
|
161
|
+
|
|
162
|
+
for (let index = 0; index < selector.length; index += 1) {
|
|
163
|
+
const char = selector[index];
|
|
164
|
+
|
|
165
|
+
if (escaped) {
|
|
166
|
+
escaped = false;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (char === "\\") {
|
|
171
|
+
escaped = true;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (quote) {
|
|
176
|
+
if (char === quote) quote = "";
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (char === "\"" || char === "'") {
|
|
181
|
+
quote = char;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (char === "[") {
|
|
186
|
+
bracketDepth += 1;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (char === "]" && bracketDepth > 0) {
|
|
191
|
+
bracketDepth -= 1;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (bracketDepth > 0) continue;
|
|
196
|
+
|
|
197
|
+
if (char === "*") {
|
|
198
|
+
matches.push("*");
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!isIdentifierStart(char)) continue;
|
|
203
|
+
if (index > 0 && isIdentifierChar(selector[index - 1])) continue;
|
|
204
|
+
|
|
205
|
+
let end = index + 1;
|
|
206
|
+
while (end < selector.length && isIdentifierChar(selector[end])) end += 1;
|
|
207
|
+
|
|
208
|
+
const previousIndex = previousNonWhitespaceIndex(selector, index);
|
|
209
|
+
const previous = previousIndex >= 0 ? selector[previousIndex] : "";
|
|
210
|
+
const hasWhitespaceBefore = index > 0 && /\s/.test(selector[index - 1]);
|
|
211
|
+
const startsSelector =
|
|
212
|
+
previousIndex === -1 ||
|
|
213
|
+
hasWhitespaceBefore ||
|
|
214
|
+
[">", "+", "~", ",", "(", "|"].includes(previous);
|
|
215
|
+
|
|
216
|
+
if (
|
|
217
|
+
startsSelector &&
|
|
218
|
+
![".", "#", ":", "[", "="].includes(previous) &&
|
|
219
|
+
!isInsideNonSelectorFunction(selector, index)
|
|
220
|
+
) {
|
|
221
|
+
matches.push(selector.slice(index, end));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
index = end - 1;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return matches;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function isInsideKeyframes(rule) {
|
|
231
|
+
let parent = rule.parent;
|
|
232
|
+
while (parent) {
|
|
233
|
+
if (parent.type === "atrule" && /keyframes$/i.test(parent.name)) return true;
|
|
234
|
+
parent = parent.parent;
|
|
235
|
+
}
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function hasSelectorException(sourceLines, rule, marker) {
|
|
240
|
+
const startLine = Math.max((rule.source && rule.source.start ? rule.source.start.line : 1) - 1, 0);
|
|
241
|
+
for (let index = startLine; index < sourceLines.length; index += 1) {
|
|
242
|
+
const line = sourceLines[index];
|
|
243
|
+
if (line.includes(marker)) return true;
|
|
244
|
+
if (line.includes("{")) return false;
|
|
245
|
+
}
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function hasLineException(sourceLines, lineNumber, marker) {
|
|
250
|
+
return (sourceLines[lineNumber - 1] || "").includes(marker);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const LIBRARY_INTERNAL_SELECTOR_PATTERN =
|
|
254
|
+
/\.bfrs-|\.Agentic[A-Za-z0-9_-]|\.[A-Za-z0-9_-]*Agentic[A-Za-z0-9_-]*|\[class[^\]]*(?:bfrs-|Agentic|css-[a-z0-9]+)[^\]]*\]/i;
|
|
255
|
+
const RADIX_INTERNAL_SELECTOR_PATTERN = /\[data-radix-[^\]]+\]/i;
|
|
256
|
+
const STRUCTURAL_ATTRIBUTE_SELECTOR_PATTERN =
|
|
257
|
+
/\[(?:role|aria-[a-z0-9_-]+|data-state|data-disabled|data-placeholder|data-highlighted|data-selected|data-side|data-align|data-orientation)\b/i;
|
|
258
|
+
const HAS_SELECTOR_PATTERN = /:{1,2}has\s*\(/i;
|
|
259
|
+
const LIBRARY_VARIABLE_DECLARATION_PATTERN = /^--(?:bfrs|dcl|color)-/i;
|
|
260
|
+
|
|
261
|
+
function selectorRuleViolations(filePath, rule, sourceLines) {
|
|
262
|
+
if (!rule.selector || isInsideKeyframes(rule) || hasSelectorException(sourceLines, rule, STYLE_EXCEPTION_MARKER)) return [];
|
|
263
|
+
|
|
264
|
+
const violations = [];
|
|
265
|
+
const line = rule.source && rule.source.start ? rule.source.start.line : 1;
|
|
266
|
+
|
|
267
|
+
for (const selector of splitSelectorList(rule.selector)) {
|
|
268
|
+
const normalizedSelector = normalizeSelector(selector);
|
|
269
|
+
const elementTargets = findElementSelectors(normalizedSelector);
|
|
270
|
+
|
|
271
|
+
if (elementTargets.length > 0) {
|
|
272
|
+
violations.push({
|
|
273
|
+
filePath,
|
|
274
|
+
line,
|
|
275
|
+
ruleId: "no-tag-selector-overrides",
|
|
276
|
+
selector: normalizedSelector,
|
|
277
|
+
detail: `tag selector${elementTargets.length === 1 ? "" : "s"}: ${[...new Set(elementTargets)].join(", ")}`,
|
|
278
|
+
message: "Do not style through raw HTML tags; use app-owned classes or library slot props.",
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (HAS_SELECTOR_PATTERN.test(normalizedSelector)) {
|
|
283
|
+
violations.push({
|
|
284
|
+
filePath,
|
|
285
|
+
line,
|
|
286
|
+
ruleId: "no-has-selector-overrides",
|
|
287
|
+
selector: normalizedSelector,
|
|
288
|
+
detail: ":has() reaches through component DOM and becomes a fragile style override.",
|
|
289
|
+
message: "Do not use :has() / ::has() to override component structure.",
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (LIBRARY_INTERNAL_SELECTOR_PATTERN.test(normalizedSelector) || RADIX_INTERNAL_SELECTOR_PATTERN.test(normalizedSelector)) {
|
|
294
|
+
violations.push({
|
|
295
|
+
filePath,
|
|
296
|
+
line,
|
|
297
|
+
ruleId: "no-library-internal-selectors",
|
|
298
|
+
selector: normalizedSelector,
|
|
299
|
+
detail: "selector targets bfrs/Agentic/Radix internals.",
|
|
300
|
+
message: "Do not target component-library implementation classes or third-party internals.",
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (STRUCTURAL_ATTRIBUTE_SELECTOR_PATTERN.test(normalizedSelector)) {
|
|
305
|
+
violations.push({
|
|
306
|
+
filePath,
|
|
307
|
+
line,
|
|
308
|
+
ruleId: "no-structural-attribute-selectors",
|
|
309
|
+
selector: normalizedSelector,
|
|
310
|
+
detail: "selector targets role/aria/data-state structure instead of a supported slot.",
|
|
311
|
+
message: "Do not style component internals through role, aria, or data-state selectors.",
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return violations;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function declarationRuleViolations(filePath, declaration, sourceLines) {
|
|
320
|
+
const line = declaration.source && declaration.source.start ? declaration.source.start.line : 1;
|
|
321
|
+
if (hasLineException(sourceLines, line, STYLE_EXCEPTION_MARKER)) return [];
|
|
322
|
+
|
|
323
|
+
const selector = normalizeSelector(declaration.parent && declaration.parent.selector ? declaration.parent.selector : "");
|
|
324
|
+
const value = normalizeValue(declaration.value);
|
|
325
|
+
const violations = [];
|
|
326
|
+
|
|
327
|
+
if (declaration.important) {
|
|
328
|
+
violations.push({
|
|
329
|
+
filePath,
|
|
330
|
+
line,
|
|
331
|
+
ruleId: "no-important-style-overrides",
|
|
332
|
+
selector,
|
|
333
|
+
detail: `${declaration.prop}: ${value} !important`,
|
|
334
|
+
message: "Do not use !important to win specificity against the component library.",
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (LIBRARY_VARIABLE_DECLARATION_PATTERN.test(declaration.prop)) {
|
|
339
|
+
violations.push({
|
|
340
|
+
filePath,
|
|
341
|
+
line,
|
|
342
|
+
ruleId: "no-library-token-overrides",
|
|
343
|
+
selector,
|
|
344
|
+
detail: `${declaration.prop}: ${value}`,
|
|
345
|
+
message: "Do not override component-library CSS variables from app stylesheets.",
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return violations;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function checkStyleFile(target) {
|
|
353
|
+
const source = fs.readFileSync(target.absolutePath, "utf8");
|
|
354
|
+
const sourceLines = source.split(/\r?\n/);
|
|
355
|
+
const violations = [];
|
|
356
|
+
let root;
|
|
357
|
+
|
|
358
|
+
try {
|
|
359
|
+
root = postcss.parse(source, { from: target.filePath });
|
|
360
|
+
} catch (error) {
|
|
361
|
+
return [{
|
|
362
|
+
filePath: target.filePath,
|
|
363
|
+
line: error.line || 1,
|
|
364
|
+
ruleId: "parse-error",
|
|
365
|
+
detail: error.reason || error.message,
|
|
366
|
+
message: "Unable to parse stylesheet.",
|
|
367
|
+
}];
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
root.walkRules((rule) => {
|
|
371
|
+
violations.push(...selectorRuleViolations(target.filePath, rule, sourceLines));
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
root.walkDecls((declaration) => {
|
|
375
|
+
violations.push(...declarationRuleViolations(target.filePath, declaration, sourceLines));
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
return violations;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function printStyleRules() {
|
|
382
|
+
console.log("Component-library style override guard - 6 rules:");
|
|
383
|
+
console.log(" - no-tag-selector-overrides: no raw element/universal selectors in app stylesheets");
|
|
384
|
+
console.log(" - no-has-selector-overrides: no :has() / ::has() style overrides");
|
|
385
|
+
console.log(" - no-library-internal-selectors: no bfrs/Agentic/Radix internal selectors");
|
|
386
|
+
console.log(" - no-structural-attribute-selectors: no role/aria/data-state selectors for styling internals");
|
|
387
|
+
console.log(" - no-important-style-overrides: no !important declarations");
|
|
388
|
+
console.log(" - no-library-token-overrides: no app overrides of --bfrs/--dcl/--color CSS variables");
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function runStyleOverrides(argv, options = {}) {
|
|
392
|
+
const cwd = process.cwd();
|
|
393
|
+
const files = getTargetFiles(argv, cwd, STYLE_EXTENSIONS, STYLE_ALLOWLISTED_FILES);
|
|
394
|
+
const violations = files.flatMap((target) => checkStyleFile(target));
|
|
395
|
+
|
|
396
|
+
if (violations.length > 0) {
|
|
397
|
+
console.error(`Component-library style override guard failed (${violations.length} violation${violations.length === 1 ? "" : "s"}).\n`);
|
|
398
|
+
console.error("Do not override @bfrs/agentic-components from app stylesheets via tags, :has(), internals, structural attributes, tokens, or !important.");
|
|
399
|
+
console.error("Use app-owned classes for layout, supported library slot props, or add the missing styling API in the component library.\n");
|
|
400
|
+
|
|
401
|
+
for (const violation of violations) {
|
|
402
|
+
console.error(`${violation.filePath}:${violation.line} [${violation.ruleId}]`);
|
|
403
|
+
console.error(` Issue: ${violation.message}`);
|
|
404
|
+
if (violation.selector) console.error(` Selector: ${violation.selector}`);
|
|
405
|
+
if (violation.detail) console.error(` Found: ${violation.detail}`);
|
|
406
|
+
console.error(` Hint: Prefer a library change or a focused slot/state. Reviewed exception: add /* ${STYLE_EXCEPTION_MARKER} */ on the selector/declaration line.\n`);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if (options.exit !== false) process.exit(1);
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (!options.quietSuccess) {
|
|
414
|
+
console.log(`Component-library style override guard passed (${files.length} stylesheet${files.length === 1 ? "" : "s"} checked).`);
|
|
415
|
+
}
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const rawTagRules = [
|
|
420
|
+
{
|
|
421
|
+
id: "use-library-slider",
|
|
422
|
+
tags: ["input"],
|
|
423
|
+
matches: (node, sourceFile) => attrValue(node, sourceFile, "type") === "range",
|
|
424
|
+
component: "Slider",
|
|
425
|
+
reason: "range sliders need an exact component-library control; flag this gap instead of building one-off sliders",
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
id: "use-library-color-picker",
|
|
429
|
+
tags: ["input"],
|
|
430
|
+
matches: (node, sourceFile) => attrValue(node, sourceFile, "type") === "color",
|
|
431
|
+
component: "ColorPicker",
|
|
432
|
+
reason: "color inputs need an exact component-library control; flag this gap instead of building one-off color pickers",
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
id: "use-library-color-swatch-group",
|
|
436
|
+
tags: ["button"],
|
|
437
|
+
matches: (node, sourceFile) => attrText(node, sourceFile, "className") === "twk-chip",
|
|
438
|
+
component: "ColorSwatchGroup",
|
|
439
|
+
reason: "color swatch choices need an exact component-library control; flag this gap instead of building one-off swatch groups",
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
id: "use-library-button",
|
|
443
|
+
tags: ["button"],
|
|
444
|
+
matches: (node, sourceFile) => attrText(node, sourceFile, "className") !== "twk-chip",
|
|
445
|
+
component: "Button or IconButton",
|
|
446
|
+
reason: "raw buttons duplicate the component-library button system",
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
id: "use-library-input",
|
|
450
|
+
tags: ["input"],
|
|
451
|
+
matches: (node, sourceFile) => !["range", "color", "file"].includes(attrValue(node, sourceFile, "type") || ""),
|
|
452
|
+
component: "Input, Checkbox, Radio, Switch, DateRangePicker, or SearchableSelect",
|
|
453
|
+
reason: "raw inputs duplicate form controls from the component library",
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
id: "use-library-textarea",
|
|
457
|
+
tags: ["textarea"],
|
|
458
|
+
component: "Textarea or ChatComposer",
|
|
459
|
+
reason: "raw textareas duplicate component-library text entry controls",
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
id: "use-library-select",
|
|
463
|
+
tags: ["select"],
|
|
464
|
+
component: "Select or SearchableSelect",
|
|
465
|
+
reason: "raw selects duplicate component-library select controls",
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
id: "use-library-label",
|
|
469
|
+
tags: ["label"],
|
|
470
|
+
component: "FormField or Label",
|
|
471
|
+
reason: "raw labels bypass the component-library form-field contract",
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
id: "use-library-dialog",
|
|
475
|
+
tags: ["dialog"],
|
|
476
|
+
component: "Modal, Drawer, or ConfirmDialog",
|
|
477
|
+
reason: "raw dialogs duplicate component-library overlays",
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
id: "use-library-data-table",
|
|
481
|
+
tags: ["table"],
|
|
482
|
+
component: "DataTable",
|
|
483
|
+
reason: "raw tables duplicate component-library data-display behavior",
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
id: "use-library-data-table-renderers",
|
|
487
|
+
tags: ["thead", "tbody", "tr", "th", "td"],
|
|
488
|
+
component: "DataTable column/cell renderers",
|
|
489
|
+
reason: "raw table internals should stay inside the shared table components",
|
|
490
|
+
},
|
|
491
|
+
];
|
|
492
|
+
|
|
493
|
+
function tagNameText(tagName) {
|
|
494
|
+
return ts.isIdentifier(tagName) ? tagName.text : null;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function attr(node, name) {
|
|
498
|
+
return node.attributes.properties.find((property) => ts.isJsxAttribute(property) && property.name.text === name);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function attrText(node, sourceFile, name) {
|
|
502
|
+
const attribute = attr(node, name);
|
|
503
|
+
if (!attribute || !attribute.initializer) return undefined;
|
|
504
|
+
if (ts.isStringLiteral(attribute.initializer)) return attribute.initializer.text;
|
|
505
|
+
return attribute.initializer.getText(sourceFile);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function attrValue(node, sourceFile, name) {
|
|
509
|
+
return (attrText(node, sourceFile, name) || "").replace(/^["']|["']$/g, "");
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function firstLine(source) {
|
|
513
|
+
return source.trim().replace(/\s+/g, " ");
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function checkUiFile(target) {
|
|
517
|
+
const source = fs.readFileSync(target.absolutePath, "utf8");
|
|
518
|
+
const sourceLines = source.split(/\r?\n/);
|
|
519
|
+
const scriptKind = path.extname(target.filePath) === ".jsx" ? ts.ScriptKind.JSX : ts.ScriptKind.TSX;
|
|
520
|
+
const sourceFile = ts.createSourceFile(target.filePath, source, ts.ScriptTarget.Latest, true, scriptKind);
|
|
521
|
+
const violations = [];
|
|
522
|
+
|
|
523
|
+
function visit(node) {
|
|
524
|
+
if (ts.isJsxSelfClosingElement(node) || ts.isJsxOpeningElement(node)) {
|
|
525
|
+
const tagName = tagNameText(node.tagName);
|
|
526
|
+
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
527
|
+
|
|
528
|
+
if (
|
|
529
|
+
tagName &&
|
|
530
|
+
tagName === tagName.toLowerCase() &&
|
|
531
|
+
!hasLineException(sourceLines, line + 1, UI_EXCEPTION_MARKER)
|
|
532
|
+
) {
|
|
533
|
+
for (const rule of rawTagRules) {
|
|
534
|
+
if (!rule.tags.includes(tagName)) continue;
|
|
535
|
+
if (rule.matches && !rule.matches(node, sourceFile)) continue;
|
|
536
|
+
|
|
537
|
+
violations.push({
|
|
538
|
+
filePath: target.filePath,
|
|
539
|
+
line: line + 1,
|
|
540
|
+
ruleId: rule.id,
|
|
541
|
+
component: rule.component,
|
|
542
|
+
reason: rule.reason,
|
|
543
|
+
source: firstLine(node.getText(sourceFile)),
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
ts.forEachChild(node, visit);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
visit(sourceFile);
|
|
553
|
+
return violations;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function printUiRules() {
|
|
557
|
+
console.log(`Component-library UI guard - ${rawTagRules.length} rules:`);
|
|
558
|
+
for (const rule of rawTagRules) {
|
|
559
|
+
console.log(` - ${rule.id}: ${rule.reason}`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function runUiLibrary(argv, options = {}) {
|
|
564
|
+
const cwd = process.cwd();
|
|
565
|
+
const files = getTargetFiles(argv, cwd, UI_EXTENSIONS);
|
|
566
|
+
const violations = files.flatMap((target) => checkUiFile(target));
|
|
567
|
+
|
|
568
|
+
if (violations.length > 0) {
|
|
569
|
+
console.error("Component-library UI guard failed.");
|
|
570
|
+
console.error("Use @bfrs/agentic-components for UI primitives. If no exact component exists, flag the component-library gap.\n");
|
|
571
|
+
|
|
572
|
+
for (const violation of violations) {
|
|
573
|
+
console.error(`${violation.filePath}:${violation.line} [${violation.ruleId}]`);
|
|
574
|
+
console.error(` Use: ${violation.component}`);
|
|
575
|
+
console.error(` Why: ${violation.reason}`);
|
|
576
|
+
console.error(` Found: ${violation.source}`);
|
|
577
|
+
console.error(` Hint: Reviewed exception: add {/* ${UI_EXCEPTION_MARKER} */} on the JSX line.\n`);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if (options.exit !== false) process.exit(1);
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (!options.quietSuccess) {
|
|
585
|
+
console.log(`Component-library UI guard passed (${files.length} TSX/JSX file${files.length === 1 ? "" : "s"} checked).`);
|
|
586
|
+
}
|
|
587
|
+
return true;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const TOKEN_HSL_PATTERN = /\bhsla?\(\s*var\(\s*--[a-zA-Z0-9_-]+\s*\)\s*(?:\/\s*[^)]*)?\)/g;
|
|
591
|
+
const CSS_VAR_PATTERN = /\bvar\(\s*--[a-zA-Z0-9_-]+\s*(?:,\s*[^)]*)?\)/g;
|
|
592
|
+
const COLOR_MIX_TOKEN_PATTERN = /\bcolor-mix\(\s*in\s+srgb\s*,\s*var\(\s*--[a-zA-Z0-9_-]+\s*\)\s+[^,]+,\s*transparent\s*\)/g;
|
|
593
|
+
|
|
594
|
+
const rawColorRules = [
|
|
595
|
+
{
|
|
596
|
+
id: "no-app-owned-color-alias",
|
|
597
|
+
name: "app-owned color alias",
|
|
598
|
+
pattern: /^\s*--(?:app|sr)-[a-z0-9-]+\s*:/gi,
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
id: "no-library-color-variable-override",
|
|
602
|
+
name: "library color variable override",
|
|
603
|
+
pattern: /^\s*--(?:color|dcl-color)-[a-z0-9-]+\s*:/gi,
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
id: "no-raw-hex",
|
|
607
|
+
name: "raw hex",
|
|
608
|
+
pattern: /(?<![\w-])#[0-9a-fA-F]{3,8}\b/g,
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
id: "no-raw-rgb",
|
|
612
|
+
name: "raw rgb/rgba",
|
|
613
|
+
pattern: /\brgba?\s*\(/g,
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
id: "no-raw-hsl",
|
|
617
|
+
name: "raw hsl/hsla",
|
|
618
|
+
pattern: /\bhsla?\s*\(/g,
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
id: "no-arbitrary-tailwind-color",
|
|
622
|
+
name: "arbitrary Tailwind color",
|
|
623
|
+
pattern: /\b(?:bg|text|border|from|via|to|ring|outline|decoration|shadow|fill|stroke)-\[(?:#[^\]]+|rgba?\([^\]]+|hsla?\([^\]]+)\]/g,
|
|
624
|
+
},
|
|
625
|
+
];
|
|
626
|
+
|
|
627
|
+
function stripAllowedTokenExpressions(line) {
|
|
628
|
+
return line
|
|
629
|
+
.replace(COLOR_MIX_TOKEN_PATTERN, "")
|
|
630
|
+
.replace(TOKEN_HSL_PATTERN, "")
|
|
631
|
+
.replace(CSS_VAR_PATTERN, "");
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
function checkThemeTokenFile(target) {
|
|
635
|
+
const source = fs.readFileSync(target.absolutePath, "utf8");
|
|
636
|
+
const violations = [];
|
|
637
|
+
const lines = source.split(/\r?\n/);
|
|
638
|
+
|
|
639
|
+
lines.forEach((line, index) => {
|
|
640
|
+
if (line.includes(THEME_TOKEN_EXCEPTION_MARKER)) return;
|
|
641
|
+
|
|
642
|
+
const lineToCheck = stripAllowedTokenExpressions(line);
|
|
643
|
+
|
|
644
|
+
for (const rule of rawColorRules) {
|
|
645
|
+
rule.pattern.lastIndex = 0;
|
|
646
|
+
if (!rule.pattern.test(lineToCheck)) continue;
|
|
647
|
+
|
|
648
|
+
violations.push({
|
|
649
|
+
filePath: target.filePath,
|
|
650
|
+
line: index + 1,
|
|
651
|
+
ruleId: rule.id,
|
|
652
|
+
rule: rule.name,
|
|
653
|
+
source: line.trim(),
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
return violations;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function printThemeTokenRules() {
|
|
662
|
+
console.log(`Theme-token guard - ${rawColorRules.length} rules:`);
|
|
663
|
+
for (const rule of rawColorRules) {
|
|
664
|
+
console.log(` - ${rule.id}: no ${rule.name}`);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function runThemeTokens(argv, options = {}) {
|
|
669
|
+
const cwd = process.cwd();
|
|
670
|
+
const files = getTargetFiles(argv, cwd, TOKEN_SOURCE_EXTENSIONS, THEME_TOKEN_ALLOWLISTED_FILES);
|
|
671
|
+
const violations = files.flatMap((target) => checkThemeTokenFile(target));
|
|
672
|
+
|
|
673
|
+
if (violations.length > 0) {
|
|
674
|
+
console.error("Theme-token guard failed.");
|
|
675
|
+
console.error("Use @bfrs/agentic-components/theme exports or CSS variables from @bfrs/agentic-components/styles instead of raw color literals.\n");
|
|
676
|
+
|
|
677
|
+
for (const violation of violations) {
|
|
678
|
+
console.error(`${violation.filePath}:${violation.line} [${violation.ruleId}]`);
|
|
679
|
+
console.error(` Rule: ${violation.rule}`);
|
|
680
|
+
console.error(` Found: ${violation.source}`);
|
|
681
|
+
console.error(` Hint: Reviewed exception: add /* ${THEME_TOKEN_EXCEPTION_MARKER} */ or // ${THEME_TOKEN_EXCEPTION_MARKER} on the line.\n`);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
if (options.exit !== false) process.exit(1);
|
|
685
|
+
return false;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
if (!options.quietSuccess) {
|
|
689
|
+
console.log(`Theme-token guard passed (${files.length} source file${files.length === 1 ? "" : "s"} checked).`);
|
|
690
|
+
}
|
|
691
|
+
return true;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
const LIBRARY_COMPONENTS = [
|
|
695
|
+
"Accordion", "ActionMenu", "Alert", "Avatar", "Badge", "Box", "Breadcrumbs",
|
|
696
|
+
"BusinessInfoDisplayCard", "BusinessInfoDisplayCardSkeleton", "Button", "ButtonGroup",
|
|
697
|
+
"Card", "CardContent", "CardFooter", "CardHeader", "ChatBubble",
|
|
698
|
+
"ChatComposer", "Checkbox", "Chip", "ColorPicker", "ColorSwatchGroup",
|
|
699
|
+
"Collapsible", "CommandMenu", "ConfirmDialog", "Container", "DataTable", "DateRangePicker",
|
|
700
|
+
"Dialog", "Drawer", "Dropdown", "EmptyState", "EntityDisplayCard", "ErrorState",
|
|
701
|
+
"FieldLabel", "FileDropzone", "FilterBar",
|
|
702
|
+
"FilterDrawer", "FormField", "FormSection", "FullPageLoader", "Grid",
|
|
703
|
+
"HelperText", "HorizontalStepper", "Icon", "IconButton", "InfoCard", "InlineError",
|
|
704
|
+
"Input", "KpiCard", "Label", "LayoutShell", "ListPageLayout", "LoadingState",
|
|
705
|
+
"MetricCard", "Modal", "MultiSelect", "NumberStepper", "OptionCardGroup", "PageHeader",
|
|
706
|
+
"Pagination", "Paper", "Popover", "ProgressBar", "Radio", "RevealAndCopy", "RevealField",
|
|
707
|
+
"SearchableSelect", "SectionHeader", "SelectableChipGroup", "Select", "SideNav", "Skeleton",
|
|
708
|
+
"Slider", "Spinner", "Stack", "StepProgressCard", "StepProgressCardSkeleton",
|
|
709
|
+
"SuggestInput", "SummaryBar", "Switch", "Table", "TableBulkActions", "TableColumnVisibility",
|
|
710
|
+
"TableEmptyState", "TableErrorState", "TablePagination", "TableRowActions",
|
|
711
|
+
"TableSaveView", "TableSkeleton", "TableToolbar", "TableViewSelector", "Tabs",
|
|
712
|
+
"TagInput", "TagsInput", "Text", "Textarea", "Tip", "ToastManager", "ToastProvider",
|
|
713
|
+
"Tooltip", "WorkspaceHeader",
|
|
714
|
+
];
|
|
715
|
+
|
|
716
|
+
function toKebab(name) {
|
|
717
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const customRules = [
|
|
721
|
+
...LIBRARY_COMPONENTS.map((name) => ({
|
|
722
|
+
id: `use-library-${toKebab(name)}`,
|
|
723
|
+
description: `Import ${name} from @bfrs/agentic-components instead of defining a local component with the same name`,
|
|
724
|
+
pattern: new RegExp(
|
|
725
|
+
`\\b(?:export\\s+)?(?:default\\s+)?(?:async\\s+)?(?:function|class)\\s+${name}\\b` +
|
|
726
|
+
`|\\b(?:export\\s+)?(?:const|let|var)\\s+${name}\\s*[:=]`,
|
|
727
|
+
"g"
|
|
728
|
+
),
|
|
729
|
+
message: `Local definition of "${name}" re-creates a @bfrs/agentic-components component.`,
|
|
730
|
+
hint: `import { ${name} } from "@bfrs/agentic-components";`,
|
|
731
|
+
lineExceptionMarker: LIBRARY_COMPONENT_EXCEPTION_MARKER,
|
|
732
|
+
})),
|
|
733
|
+
{
|
|
734
|
+
id: "use-library-progressbar",
|
|
735
|
+
description: "Use ProgressBar instead of raw <progress>",
|
|
736
|
+
pattern: /<\s*progress\b/g,
|
|
737
|
+
message: "Raw <progress> duplicates the component-library progress indicator.",
|
|
738
|
+
hint: `import { ProgressBar } from "@bfrs/agentic-components";`,
|
|
739
|
+
lineExceptionMarker: UI_EXCEPTION_MARKER,
|
|
740
|
+
},
|
|
741
|
+
];
|
|
742
|
+
|
|
743
|
+
function checkCustomRuleFile(target) {
|
|
744
|
+
const source = fs.readFileSync(target.absolutePath, "utf8");
|
|
745
|
+
const lines = source.split(/\r?\n/);
|
|
746
|
+
const violations = [];
|
|
747
|
+
|
|
748
|
+
for (const rule of customRules) {
|
|
749
|
+
lines.forEach((line, index) => {
|
|
750
|
+
if (rule.lineExceptionMarker && line.includes(rule.lineExceptionMarker)) return;
|
|
751
|
+
rule.pattern.lastIndex = 0;
|
|
752
|
+
if (!rule.pattern.test(line)) return;
|
|
753
|
+
|
|
754
|
+
violations.push({
|
|
755
|
+
filePath: target.filePath,
|
|
756
|
+
line: index + 1,
|
|
757
|
+
ruleId: rule.id,
|
|
758
|
+
message: rule.message,
|
|
759
|
+
hint: rule.hint,
|
|
760
|
+
source: line.trim(),
|
|
761
|
+
});
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
return violations;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function printCustomRules() {
|
|
769
|
+
console.log(`Custom rules guard - ${customRules.length} rules:`);
|
|
770
|
+
for (const rule of customRules) {
|
|
771
|
+
console.log(` - ${rule.id}: ${rule.description}`);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
function runCustomRules(argv, options = {}) {
|
|
776
|
+
const cwd = process.cwd();
|
|
777
|
+
const files = getTargetFiles(argv, cwd, CUSTOM_SOURCE_EXTENSIONS);
|
|
778
|
+
const violations = files.flatMap((target) => checkCustomRuleFile(target));
|
|
779
|
+
|
|
780
|
+
if (violations.length > 0) {
|
|
781
|
+
console.error(`Custom rules guard failed (${violations.length} violation${violations.length === 1 ? "" : "s"}).\n`);
|
|
782
|
+
|
|
783
|
+
for (const violation of violations) {
|
|
784
|
+
console.error(`${violation.filePath}:${violation.line} [${violation.ruleId}]`);
|
|
785
|
+
console.error(` Issue: ${violation.message}`);
|
|
786
|
+
if (violation.hint) console.error(` Hint: ${violation.hint}`);
|
|
787
|
+
console.error(` Found: ${violation.source}\n`);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
if (options.exit !== false) process.exit(1);
|
|
791
|
+
return false;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
if (!options.quietSuccess) {
|
|
795
|
+
console.log(`Custom rules guard passed (${customRules.length} rule${customRules.length === 1 ? "" : "s"}, ${files.length} source file${files.length === 1 ? "" : "s"} checked).`);
|
|
796
|
+
}
|
|
797
|
+
return true;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function printAllRules() {
|
|
801
|
+
printStyleRules();
|
|
802
|
+
console.log("");
|
|
803
|
+
printUiRules();
|
|
804
|
+
console.log("");
|
|
805
|
+
printThemeTokenRules();
|
|
806
|
+
console.log("");
|
|
807
|
+
printCustomRules();
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function runAll(argv) {
|
|
811
|
+
const options = { exit: false, quietSuccess: true };
|
|
812
|
+
const results = [
|
|
813
|
+
runStyleOverrides(argv, options),
|
|
814
|
+
runUiLibrary(argv, options),
|
|
815
|
+
runThemeTokens(argv, options),
|
|
816
|
+
runCustomRules(argv, options),
|
|
817
|
+
];
|
|
818
|
+
|
|
819
|
+
if (results.some((result) => !result)) {
|
|
820
|
+
process.exit(1);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
console.log("BFRS agentic lint passed.");
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
function printHelp() {
|
|
827
|
+
console.log("Usage: bfrs-agentic-lint [all] [files...]");
|
|
828
|
+
console.log(" bfrs-agentic-lint style-overrides [files...]");
|
|
829
|
+
console.log(" bfrs-agentic-lint ui-library [files...]");
|
|
830
|
+
console.log(" bfrs-agentic-lint theme-tokens [files...]");
|
|
831
|
+
console.log(" bfrs-agentic-lint custom-rules [files...]");
|
|
832
|
+
console.log(" bfrs-agentic-lint --list");
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
const commands = new Set([
|
|
836
|
+
"all",
|
|
837
|
+
"style-overrides",
|
|
838
|
+
"style-selectors",
|
|
839
|
+
"ui-library",
|
|
840
|
+
"theme-tokens",
|
|
841
|
+
"custom-rules",
|
|
842
|
+
]);
|
|
843
|
+
|
|
844
|
+
const rawArgs = process.argv.slice(2);
|
|
845
|
+
let command = "all";
|
|
846
|
+
let commandArgs = rawArgs;
|
|
847
|
+
|
|
848
|
+
if (rawArgs[0] && commands.has(rawArgs[0])) {
|
|
849
|
+
command = rawArgs[0];
|
|
850
|
+
commandArgs = rawArgs.slice(1);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
if (commandArgs.includes("--help") || commandArgs.includes("-h") || rawArgs[0] === "help") {
|
|
854
|
+
printHelp();
|
|
855
|
+
process.exit(0);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
if (commandArgs.includes("--list") || rawArgs[0] === "--list" || rawArgs[0] === "list") {
|
|
859
|
+
if (command === "style-overrides" || command === "style-selectors") printStyleRules();
|
|
860
|
+
else if (command === "ui-library") printUiRules();
|
|
861
|
+
else if (command === "theme-tokens") printThemeTokenRules();
|
|
862
|
+
else if (command === "custom-rules") printCustomRules();
|
|
863
|
+
else printAllRules();
|
|
864
|
+
process.exit(0);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
if (command === "all") {
|
|
868
|
+
runAll(commandArgs);
|
|
869
|
+
process.exit(0);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
if (command === "style-overrides" || command === "style-selectors") {
|
|
873
|
+
runStyleOverrides(commandArgs);
|
|
874
|
+
process.exit(0);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
if (command === "ui-library") {
|
|
878
|
+
runUiLibrary(commandArgs);
|
|
879
|
+
process.exit(0);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
if (command === "theme-tokens") {
|
|
883
|
+
runThemeTokens(commandArgs);
|
|
884
|
+
process.exit(0);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
if (command === "custom-rules") {
|
|
888
|
+
runCustomRules(commandArgs);
|
|
889
|
+
process.exit(0);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
console.error(`Unknown bfrs-agentic-lint command: ${command}`);
|
|
893
|
+
printHelp();
|
|
894
|
+
process.exit(2);
|