@sixbell-telco/eslint-plugin-sdk 0.1.0 → 0.1.2
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/CHANGELOG.md +12 -0
- package/README.md +13 -0
- package/package.json +6 -1
- package/src/index.mjs +17 -1
- package/src/rules/style-rules.mjs +96 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.2] - 2026-12-02
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Rules**: `scroll-fade` (`DS_SCROLL_FADE`) reports a region that scrolls on its own (`overflow-y-auto` with `max-h-80`, `overflow-x-auto` with `w-96`) without `scroll-fade-y` or `scroll-fade-x`, and `dialog-content-scroll` (`UI_DIALOG_SCROLL_001`) reports a `max-h-*` or `overflow-*` box inside `st-dialog-content`, which already caps and scrolls the dialog body; both in `recommended` as warnings (NSU-157)
|
|
15
|
+
|
|
16
|
+
## [0.1.1] - 2026-11-13
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- The `@sixbell-telco/sdk` peer is optional, so installing the plugin (or `@sixbell-telco/sdk-tools`) where no app is installed does not pull an SDK; the rules read the app's SDK, as before
|
|
21
|
+
|
|
10
22
|
## [0.1.0] - 2026-11-13
|
|
11
23
|
|
|
12
24
|
First release. Needs Node 22.12+ or 24, ESLint 9, angular-eslint 19 and `@sixbell-telco/sdk` 4.6.0 or later; the rules read the installed SDK's `manifest.json`.
|
package/README.md
CHANGED
|
@@ -122,6 +122,8 @@ The `DS_*` design-system rules ship as warnings: the fleet still has hundreds of
|
|
|
122
122
|
| `DS_FONT_FAMILY` | [`font-family`](#font-family) | warn | `<div class="font-sans">` | inherit the theme font, or `font-heading` |
|
|
123
123
|
| `DS_BORDER_WIDTH` | [`border-width`](#border-width) | warn | `<div class="border-2">` | `<div class="border">`; `border-2 border-dashed` for a drop target |
|
|
124
124
|
| `DS_KIT_OVERRIDE` | [`kit-override`](#kit-override) | warn | `<st-button class="!p-0 [&_svg]:size-4">` | the component input (`size="sm"`), or a kit change |
|
|
125
|
+
| `DS_SCROLL_FADE` | [`scroll-fade`](#scroll-fade) | warn | `<ul class="max-h-80 overflow-y-auto">` | `<ul class="max-h-80 overflow-y-auto overscroll-contain scroll-fade-y">` |
|
|
126
|
+
| `UI_DIALOG_SCROLL_001` | [`dialog-content-scroll`](#dialog-content-scroll) | warn | `<st-dialog-content><div class="max-h-96 overflow-y-auto">` | `<st-dialog-content>...</st-dialog-content>`: the content scrolls there |
|
|
125
127
|
| `SDK_UI_003` | [`unknown-element`](#unknown-element) | error | `<st-card-content>` | `<st-card-body>` |
|
|
126
128
|
| `SDK_UI_004` | [`unknown-input`](#unknown-input) | error | `headerTitle="..."` on a kit element | the component's own input |
|
|
127
129
|
|
|
@@ -248,3 +250,14 @@ A Tailwind shadow step (`shadow`, `shadow-md`, `drop-shadow-lg`). Use `shadow-ra
|
|
|
248
250
|
### kit-override
|
|
249
251
|
|
|
250
252
|
`!` or `[&...]` on an `st-*` element (`!p-0`, `[&_svg]:size-4`, `[&>div]:items-start`): a class that forces a style onto kit internals breaks with the next kit release. Use the component input, or ask for a kit change. Color, typography, shape and effect classes are left to `shadcn/no-restyle`.
|
|
253
|
+
|
|
254
|
+
### scroll-fade
|
|
255
|
+
|
|
256
|
+
A region that scrolls on its own with no scroll fade: an `overflow-*-auto` or `overflow-*-scroll` class next to a size cap on the scroll axis (`max-h-*` or a fixed `h-*` or `size-*` for vertical scroll, `max-w-*` or a fixed `w-*` or `size-*` for horizontal scroll), and no `scroll-fade*` class. Add `scroll-fade-y` (a list, a side panel, a log, a fixed-height table body) or `scroll-fade-x` (a horizontal strip), with `overscroll-contain`; the fade shows only while there is more to scroll.
|
|
257
|
+
|
|
258
|
+
- **Not reported:** sizes that follow the parent or the page (`h-full`, `h-screen`, `w-1/2`, `max-h-none`), `overflow-hidden`, and `scroll-fade-none` (the region opts out on purpose).
|
|
259
|
+
- **Kit parts:** `st-*` elements are not checked: kit parts that scroll (`st-dialog-content`, the `st-select` and `st-combobox` panels, dropdown menu content) already have the fade. Inside `st-dialog-content`, [`dialog-content-scroll`](#dialog-content-scroll) reports the box instead.
|
|
260
|
+
|
|
261
|
+
### dialog-content-scroll
|
|
262
|
+
|
|
263
|
+
Inside `st-dialog-content`, an element with its own height or scroll box: `max-h-*`, `overflow-auto` or `overflow-scroll` on either axis, or `overflow-hidden` next to a fixed height. `st-dialog` caps its height to the screen and `st-dialog-content` scrolls with the fade, so the title and the actions stay visible; a second box scrolls twice or cuts the content off. Remove the classes and let the content scroll in `st-dialog-content`. One finding per element, naming every class to remove. A fixed height alone (a chart) and `overflow-hidden` alone (rounded media) are fine.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixbell-telco/eslint-plugin-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "ESLint rules that check Angular templates and imports against the @sixbell-telco/sdk component manifest",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -27,5 +27,10 @@
|
|
|
27
27
|
"@angular-eslint/utils": "^19.0.0",
|
|
28
28
|
"@sixbell-telco/sdk": ">=4.6.0",
|
|
29
29
|
"eslint": "^9.0.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"@sixbell-telco/sdk": {
|
|
33
|
+
"optional": true
|
|
34
|
+
}
|
|
30
35
|
}
|
|
31
36
|
}
|
package/src/index.mjs
CHANGED
|
@@ -30,7 +30,19 @@ import {
|
|
|
30
30
|
statusIllustration,
|
|
31
31
|
} from './rules/composition-rules.mjs';
|
|
32
32
|
import { entryPointImport } from './rules/import-rules.mjs';
|
|
33
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
borderWidth,
|
|
35
|
+
dialogContentScroll,
|
|
36
|
+
fontFamily,
|
|
37
|
+
kitOverride,
|
|
38
|
+
radiusRaw,
|
|
39
|
+
radiusRole,
|
|
40
|
+
scrollFade,
|
|
41
|
+
shadowRaw,
|
|
42
|
+
surfaceTint,
|
|
43
|
+
textRaw,
|
|
44
|
+
textTone,
|
|
45
|
+
} from './rules/style-rules.mjs';
|
|
34
46
|
import {
|
|
35
47
|
bannedUtility,
|
|
36
48
|
deprecatedInput,
|
|
@@ -80,6 +92,8 @@ const rules = {
|
|
|
80
92
|
'font-family': fontFamily,
|
|
81
93
|
'border-width': borderWidth,
|
|
82
94
|
'kit-override': kitOverride,
|
|
95
|
+
'scroll-fade': scrollFade,
|
|
96
|
+
'dialog-content-scroll': dialogContentScroll,
|
|
83
97
|
};
|
|
84
98
|
|
|
85
99
|
/** @type {import('eslint').Linter.Config[]} */
|
|
@@ -123,6 +137,8 @@ recommended.push(
|
|
|
123
137
|
'@sixbell-telco/sdk/font-family': 'warn',
|
|
124
138
|
'@sixbell-telco/sdk/border-width': 'warn',
|
|
125
139
|
'@sixbell-telco/sdk/kit-override': 'warn',
|
|
140
|
+
'@sixbell-telco/sdk/scroll-fade': 'warn',
|
|
141
|
+
'@sixbell-telco/sdk/dialog-content-scroll': 'warn',
|
|
126
142
|
},
|
|
127
143
|
},
|
|
128
144
|
{
|
|
@@ -46,6 +46,17 @@ const KIT_ELEMENT = /^st-/;
|
|
|
46
46
|
// element with or without `!`, so kit-override leaves them to it (one owner per finding).
|
|
47
47
|
const RESTYLE_OWNED =
|
|
48
48
|
/^(?:bg-|from-|via-|to-|fill-|stroke-|ring|outline|decoration-|caret-|accent-|rounded|shadow|drop-shadow|opacity-|border(?:$|-)|divide-|font-|leading-|tracking-|uppercase|lowercase|capitalize|italic|text-(?!left$|right$|center$|justify$|start$|end$|wrap$|nowrap$|pretty$|balance$|ellipsis$|clip$))/;
|
|
49
|
+
// A region that scrolls on its own: overflow auto or scroll, on both axes or on one.
|
|
50
|
+
const SCROLLS = /^overflow-(?:([xy])-)?(?:auto|scroll)$/;
|
|
51
|
+
const CLIPS = /^overflow-(?:[xy]-)?(?:hidden|clip)$/;
|
|
52
|
+
const SCROLL_FADE = /^scroll-fade(?:-|$)/;
|
|
53
|
+
// A fixed size: a spacing step, px, a container size, an arbitrary value or a CSS variable. Sizes
|
|
54
|
+
// that follow the parent or the page (auto, full, screen, fit, fractions, viewport units) are not.
|
|
55
|
+
const FIXED_SIZE = String.raw`(?:\d+(?:\.\d+)?|px|3xs|2xs|xs|sm|md|lg|xl|[2-7]xl|\[[^\]]+\]|\([^)]+\))`;
|
|
56
|
+
const HEIGHT_CAP = new RegExp(String.raw`^(?:max-h-(?!none$)\S+|(?:h|size)-${FIXED_SIZE})$`);
|
|
57
|
+
const WIDTH_CAP = new RegExp(String.raw`^(?:max-w-(?!none$)\S+|(?:w|size)-${FIXED_SIZE})$`);
|
|
58
|
+
// The kit part that already caps and scrolls a dialog's body (with scroll-fade-y).
|
|
59
|
+
const DIALOG_CONTENT = 'st-dialog-content';
|
|
49
60
|
|
|
50
61
|
/**
|
|
51
62
|
* Splits `md:hover:[&_svg]:size-4` on the `:` that are outside brackets and parentheses.
|
|
@@ -160,6 +171,44 @@ function classRule({ name, type, description, messages, kit = false, check }) {
|
|
|
160
171
|
});
|
|
161
172
|
}
|
|
162
173
|
|
|
174
|
+
/**
|
|
175
|
+
* A rule that reads all the class tokens of an element at once (a cap in `class` and an overflow in
|
|
176
|
+
* `[class.x]` are one box), each token with the span it came from; it reports at most once per element.
|
|
177
|
+
* @param {{ name: string, type?: 'problem' | 'suggestion', description: string, messages: Record<string, string>,
|
|
178
|
+
* check: (tokens: (StyleToken & { span: TemplateSpan })[], node: Node) => { token: StyleToken & { span: TemplateSpan }, messageId: string, data: Record<string, string> } | null }} definition
|
|
179
|
+
*/
|
|
180
|
+
function elementClassRule({ name, type, description, messages, check }) {
|
|
181
|
+
return idRule({
|
|
182
|
+
name,
|
|
183
|
+
type,
|
|
184
|
+
description,
|
|
185
|
+
messages,
|
|
186
|
+
create(context) {
|
|
187
|
+
const services = /** @type {{ convertNodeSourceSpanToLoc(span: TemplateSpan): import('eslint').AST.SourceLocation }} */ (
|
|
188
|
+
/** @type {unknown} */ (getTemplateParserServices(/** @type {any} */ (context)))
|
|
189
|
+
);
|
|
190
|
+
return {
|
|
191
|
+
/** @param {Node} node */
|
|
192
|
+
Element(node) {
|
|
193
|
+
const tokens = classSources(node).flatMap((source) => source.tokens.map((token) => ({ ...token, span: source.span })));
|
|
194
|
+
const finding = tokens.length ? check(tokens, node) : null;
|
|
195
|
+
if (finding)
|
|
196
|
+
context.report({ loc: services.convertNodeSourceSpanToLoc(finding.token.span), messageId: finding.messageId, data: finding.data });
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Whether the element sits inside `st-dialog-content`, through control flow.
|
|
205
|
+
* @param {Node} node
|
|
206
|
+
*/
|
|
207
|
+
function inDialogContent(node) {
|
|
208
|
+
for (let parent = node.parent; parent; parent = parent.parent) if (parent.name === DIALOG_CONTENT) return true;
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
|
|
163
212
|
/** Each token whose utility matches `pattern`. */
|
|
164
213
|
const eachMatch =
|
|
165
214
|
(/** @type {RegExp} */ pattern, /** @type {string} */ messageId) =>
|
|
@@ -292,3 +341,50 @@ export const kitOverride = classRule({
|
|
|
292
341
|
}
|
|
293
342
|
},
|
|
294
343
|
});
|
|
344
|
+
|
|
345
|
+
export const scrollFade = elementClassRule({
|
|
346
|
+
name: 'scroll-fade',
|
|
347
|
+
type: 'suggestion',
|
|
348
|
+
description: 'A region that scrolls on its own shows the scroll fade (scroll-fade-y, or scroll-fade-x for a horizontal strip)',
|
|
349
|
+
messages: {
|
|
350
|
+
DS_SCROLL_FADE:
|
|
351
|
+
'"{{token}}" with "{{bound}}" scrolls a region with no fade at its edge: add {{fix}} (with overscroll-contain) so the edge shows there is more to scroll.',
|
|
352
|
+
},
|
|
353
|
+
check(tokens, node) {
|
|
354
|
+
// Kit parts that scroll carry the fade; inside st-dialog-content, dialog-content-scroll owns the box.
|
|
355
|
+
if (KIT_ELEMENT.test(node.name) || inDialogContent(node)) return null;
|
|
356
|
+
if (tokens.some((token) => SCROLL_FADE.test(token.base))) return null;
|
|
357
|
+
for (const token of tokens) {
|
|
358
|
+
const scroll = SCROLLS.exec(token.base);
|
|
359
|
+
if (!scroll) continue;
|
|
360
|
+
const axis = scroll[1];
|
|
361
|
+
const height = axis !== 'x' ? tokens.find((candidate) => HEIGHT_CAP.test(candidate.base)) : undefined;
|
|
362
|
+
const width = axis !== 'y' ? tokens.find((candidate) => WIDTH_CAP.test(candidate.base)) : undefined;
|
|
363
|
+
const bound = height ?? width;
|
|
364
|
+
if (!bound) continue;
|
|
365
|
+
const fix = height && width ? 'scroll-fade-y (scroll-fade-x for a horizontal strip)' : height ? 'scroll-fade-y' : 'scroll-fade-x';
|
|
366
|
+
return { token, messageId: 'DS_SCROLL_FADE', data: { token: token.raw, bound: bound.raw, fix } };
|
|
367
|
+
}
|
|
368
|
+
return null;
|
|
369
|
+
},
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
export const dialogContentScroll = elementClassRule({
|
|
373
|
+
name: 'dialog-content-scroll',
|
|
374
|
+
type: 'suggestion',
|
|
375
|
+
description: 'Let st-dialog-content scroll the dialog body: no height or overflow box of your own inside it',
|
|
376
|
+
messages: {
|
|
377
|
+
UI_DIALOG_SCROLL_001:
|
|
378
|
+
'"{{token}}" inside <st-dialog-content> makes a second height or scroll box: st-dialog caps its height and st-dialog-content scrolls with the fade, so remove these classes and let the content scroll there.',
|
|
379
|
+
},
|
|
380
|
+
check(tokens, node) {
|
|
381
|
+
if (!inDialogContent(node)) return null;
|
|
382
|
+
const fixedHeight = tokens.some((token) => HEIGHT_CAP.test(token.base));
|
|
383
|
+
// A clip only cuts content off under a height cap; alone it rounds media or truncates.
|
|
384
|
+
const boxes = tokens.filter(
|
|
385
|
+
(token) => /^max-h-(?!none$)/.test(token.base) || SCROLLS.test(token.base) || (fixedHeight && CLIPS.test(token.base)),
|
|
386
|
+
);
|
|
387
|
+
if (!boxes.length) return null;
|
|
388
|
+
return { token: boxes[0], messageId: 'UI_DIALOG_SCROLL_001', data: { token: boxes.map((token) => token.raw).join(' ') } };
|
|
389
|
+
},
|
|
390
|
+
});
|