@nldd/design-system 0.26.3 → 0.26.5
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/custom-elements.json +3 -3
- package/dist/components/content/image/image.d.ts +1 -1
- package/dist/components/content/image/image.js +1 -1
- package/dist/components/content/image/lqip-encoder-element.d.ts +5 -4
- package/dist/components/content/image/lqip-encoder-element.d.ts.map +1 -1
- package/dist/components/content/image/lqip-encoder-element.js +5 -4
- package/dist/components/content/image/lqip-encoder-element.js.map +1 -1
- package/dist/components/content/image/lqip-encoder.d.ts +1 -1
- package/dist/components/content/image/lqip-encoder.js +2 -2
- package/dist/components/content/image/lqip-encoder.js.map +1 -1
- package/dist/components/content/keyboard-shortcut/keyboard-shortcut.d.ts +2 -2
- package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js +2 -2
- package/dist/components/layout/page-sections/page-section-controls.d.ts +1 -1
- package/dist/components/layout/page-sections/page-section-controls.js +1 -1
- package/dist/types/react.d.ts +2 -2
- package/dist/types/vue.d.ts +3 -3
- package/dist/utilities/os.d.ts +1 -1
- package/dist/utilities/os.js +1 -1
- package/lint/format.js +7 -4
- package/lint/frontends.js +347 -0
- package/lint/linter.js +1 -1
- package/lint/main.js +1 -0
- package/lint/project.js +8 -1
- package/lint/session.js +30 -8
- package/package.json +1 -1
package/custom-elements.json
CHANGED
|
@@ -6974,7 +6974,7 @@
|
|
|
6974
6974
|
},
|
|
6975
6975
|
"default": "''",
|
|
6976
6976
|
"fieldName": "lqip",
|
|
6977
|
-
"description": "Loading preview (LQIP, low-quality image placeholder) as a CSV string `\"base,c1,c2,c3,c4,c5,c6\"`: seven 0-255 bytes, each packing an 8-bit Oklab triplet (2 bits L, 3 bits a, 3 bits b). The first is the base color shown outside the cell gradients; the other six are per-cell colors in row-major 3×2 order. Generate via the encoder in `lqip-encoder.ts` or via the
|
|
6977
|
+
"description": "Loading preview (LQIP, low-quality image placeholder) as a CSV string `\"base,c1,c2,c3,c4,c5,c6\"`: seven 0-255 bytes, each packing an 8-bit Oklab triplet (2 bits L, 3 bits a, 3 bits b). The first is the base color shown outside the cell gradients; the other six are per-cell colors in row-major 3×2 order. Generate via the encoder in `lqip-encoder.ts` or via the LQIP-encoder example on `/componenten/image/`. Extends Lean Rada's CSS-only LQIP (https://leanrada.com/notes/css-only-lqip/) with per-cell hue. Lean's original format encodes grayscale cells only, while ours encodes a color per cell so multi-color subjects survive the preview."
|
|
6978
6978
|
},
|
|
6979
6979
|
{
|
|
6980
6980
|
"name": "translations",
|
|
@@ -7324,7 +7324,7 @@
|
|
|
7324
7324
|
},
|
|
7325
7325
|
{
|
|
7326
7326
|
"name": "debug-os",
|
|
7327
|
-
"description": "Development aid: overrides the OS detection for this instance, so you can show several platform variants side by side in
|
|
7327
|
+
"description": "Development aid: overrides the OS detection for this instance, so you can show several platform variants side by side in documentation. Not meant for production use; leave it empty (default) so the real OS detection applies.",
|
|
7328
7328
|
"type": {
|
|
7329
7329
|
"text": "'mac'|'windows'|'linux'|'other'"
|
|
7330
7330
|
}
|
|
@@ -40594,7 +40594,7 @@
|
|
|
40594
40594
|
"text": "object"
|
|
40595
40595
|
},
|
|
40596
40596
|
"default": "{ background: 'inherit', width: '', height: '', grow: false, paddingBlock: '', paddingTop: '', paddingBottom: '', smPaddingBlock: '', smPaddingTop: '', smPaddingBottom: '', mdPaddingBlock: '', mdPaddingTop: '', mdPaddingBottom: '', lgPaddingBlock: '', lgPaddingTop: '', lgPaddingBottom: '', }",
|
|
40597
|
-
"description": "Shared
|
|
40597
|
+
"description": "Shared story controls for the PageSectionMixin surface API\n(background, width, height, grow and the 12 block-padding overrides).\nSpread into a section story's `args` / `argTypes`, and bind onto the host\nelement in `render` with the `pageSectionAttrs` directive."
|
|
40598
40598
|
},
|
|
40599
40599
|
{
|
|
40600
40600
|
"kind": "variable",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
* Oklab triplet (2 bits L, 3 bits a, 3 bits b). The first is the base
|
|
51
51
|
* color shown outside the cell gradients; the other six are per-cell
|
|
52
52
|
* colors in row-major 3×2 order. Generate via the encoder in
|
|
53
|
-
* `lqip-encoder.ts` or via the
|
|
53
|
+
* `lqip-encoder.ts` or via the LQIP-encoder example on `/componenten/image/`.
|
|
54
54
|
* Extends Lean Rada's CSS-only LQIP (https://leanrada.com/notes/css-only-lqip/)
|
|
55
55
|
* with per-cell hue. Lean's original format encodes grayscale cells only,
|
|
56
56
|
* while ours encodes a color per cell so multi-color subjects survive the
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
* Oklab triplet (2 bits L, 3 bits a, 3 bits b). The first is the base
|
|
51
51
|
* color shown outside the cell gradients; the other six are per-cell
|
|
52
52
|
* colors in row-major 3×2 order. Generate via the encoder in
|
|
53
|
-
* `lqip-encoder.ts` or via the
|
|
53
|
+
* `lqip-encoder.ts` or via the LQIP-encoder example on `/componenten/image/`.
|
|
54
54
|
* Extends Lean Rada's CSS-only LQIP (https://leanrada.com/notes/css-only-lqip/)
|
|
55
55
|
* with per-cell hue. Lean's original format encodes grayscale cells only,
|
|
56
56
|
* while ours encodes a color per cell so multi-color subjects survive the
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* separate module from the pure encoder so consumers
|
|
4
|
-
* functions (e.g. a Node build pipeline) don't
|
|
5
|
-
* `nldd-lqip-encoder` custom element into their
|
|
2
|
+
* UI element for the documentation site, wrapping `encodeLqip()` in a
|
|
3
|
+
* file-picker. Kept in a separate module from the pure encoder so consumers
|
|
4
|
+
* importing just the functions (e.g. a Node build pipeline) don't
|
|
5
|
+
* accidentally register the `nldd-lqip-encoder` custom element into their
|
|
6
|
+
* registry.
|
|
6
7
|
*
|
|
7
8
|
* Intentionally NOT exported from `src/components/index.ts`: this is a
|
|
8
9
|
* developer tool, not a design-system component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lqip-encoder-element.d.ts","sourceRoot":"","sources":["../../../../src/components/content/image/lqip-encoder-element.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"lqip-encoder-element.d.ts","sourceRoot":"","sources":["../../../../src/components/content/image/lqip-encoder-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C,OAAO,YAAY,CAAC;AAMpB,eAAO,MAAM,2BAA2B;;;;;;;CAOvC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,OAAO,2BAA2B,CAAC;AAM7E,qBACa,eAAgB,SAAQ,UAAU;IAE9C,YAAY,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAM;IAE/C,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,MAAM,CAAM;IAEtB,EAAE,CAAC,GAAG,EAAE,MAAM,2BAA2B,GAAG,MAAM;IAIzD,OAAgB,MAAM,0BA0FpB;IAEF,OAAO,CAAC,iBAAiB,CA0BvB;IAEO,oBAAoB,IAAI,IAAI;IAK5B,MAAM;CA4Cf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,mBAAmB,EAAE,eAAe,CAAC;KACrC;CACD"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* separate module from the pure encoder so consumers
|
|
4
|
-
* functions (e.g. a Node build pipeline) don't
|
|
5
|
-
* `nldd-lqip-encoder` custom element into their
|
|
2
|
+
* UI element for the documentation site, wrapping `encodeLqip()` in a
|
|
3
|
+
* file-picker. Kept in a separate module from the pure encoder so consumers
|
|
4
|
+
* importing just the functions (e.g. a Node build pipeline) don't
|
|
5
|
+
* accidentally register the `nldd-lqip-encoder` custom element into their
|
|
6
|
+
* registry.
|
|
6
7
|
*
|
|
7
8
|
* Intentionally NOT exported from `src/components/index.ts`: this is a
|
|
8
9
|
* developer tool, not a design-system component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lqip-encoder-element.js","sourceRoot":"","sources":["../../../../src/components/content/image/lqip-encoder-element.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"lqip-encoder-element.js","sourceRoot":"","sources":["../../../../src/components/content/image/lqip-encoder-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,YAAY,CAAC;AAEpB;;2EAE2E;AAE3E,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,sCAAsC,EAAE,qBAAqB;IAC7D,0CAA0C,EAAE,UAAU;IACtD,+CAA+C,EAAE,6CAA6C;IAC9F,8CAA8C,EAAE,mBAAmB;IACnE,4CAA4C,EAAE,kBAAkB;IAChE,6CAA6C,EAAE,sBAAsB;CACrE,CAAC;AAIF;;2EAE2E;AAGpE,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QAEN,iBAAY,GAAyC,EAAE,CAAC;QAEvC,UAAK,GAAkB,IAAI,CAAC;QAC5B,cAAS,GAAG,EAAE,CAAC;QACf,cAAS,GAAG,EAAE,CAAC;QACf,iBAAY,GAAG,MAAM,CAAC;QACtB,WAAM,GAAG,EAAE,CAAC;QAkGrB,sBAAiB,GAAG,KAAK,EAAE,CAAQ,EAAiB,EAAE;YAC7D,MAAM,KAAK,GAAG,CAAC,CAAC,MAA0B,CAAC;YAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CA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KAAK,EAAE;kDAAwB;AACf;IAAhB,KAAK,EAAE;qDAA+B;AACtB;IAAhB,KAAK,EAAE;+CAAqB;AARjB,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAuL3B"}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* This module is intentionally pure: no Lit imports, no custom-element
|
|
23
23
|
* registration side effects. Consumers (Node build pipelines, Workers,
|
|
24
|
-
* tests) can import just the encoder without dragging in the
|
|
24
|
+
* tests) can import just the encoder without dragging in the file-picker
|
|
25
25
|
* UI. The file-picker UI lives in `lqip-encoder-element.ts` and registers
|
|
26
26
|
* `<nldd-lqip-encoder>` separately.
|
|
27
27
|
*/
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* This module is intentionally pure: no Lit imports, no custom-element
|
|
23
23
|
* registration side effects. Consumers (Node build pipelines, Workers,
|
|
24
|
-
* tests) can import just the encoder without dragging in the
|
|
24
|
+
* tests) can import just the encoder without dragging in the file-picker
|
|
25
25
|
* UI. The file-picker UI lives in `lqip-encoder-element.ts` and registers
|
|
26
26
|
* `<nldd-lqip-encoder>` separately.
|
|
27
27
|
*/
|
|
@@ -254,7 +254,7 @@ export function encodePixelDataToLqip(data, width, height) {
|
|
|
254
254
|
export async function encodeLqip(source) {
|
|
255
255
|
// When we create the bitmap from a File / HTMLImageElement we own its
|
|
256
256
|
// lifecycle and must close it. When the caller passes an ImageBitmap they
|
|
257
|
-
// own it (the
|
|
257
|
+
// own it (the `nldd-lqip-encoder` element, for one, reuses + closes its own),
|
|
258
258
|
// so we leave that case untouched.
|
|
259
259
|
const ownsBitmap = source instanceof File || source instanceof HTMLImageElement;
|
|
260
260
|
const bitmap = ownsBitmap ? await createImageBitmap(source) : source;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lqip-encoder.js","sourceRoot":"","sources":["../../../../src/components/content/image/lqip-encoder.ts"],"names":[],"mappings":"A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7 @@
|
|
|
39
39
|
* highlighted row.
|
|
40
40
|
* @attr {'mac'|'windows'|'linux'|'other'} debug-os - Development aid: overrides the OS
|
|
41
41
|
* detection for this instance, so you can show several platform variants side by side in
|
|
42
|
-
*
|
|
42
|
+
* documentation. Not meant for production use; leave it empty (default) so
|
|
43
43
|
* the real OS detection applies.
|
|
44
44
|
*
|
|
45
45
|
* @slot - Optional custom <kbd> elements. Ignored when keys is set.
|
|
@@ -75,7 +75,7 @@ export declare class NLDDKeyboardShortcut extends LitElement {
|
|
|
75
75
|
* @internal Development only.
|
|
76
76
|
*
|
|
77
77
|
* Per-instance OS override that bypasses `detectOS()`. Same pattern as
|
|
78
|
-
* `debug-safe-triangle` on `nldd-menu`: useful in
|
|
78
|
+
* `debug-safe-triangle` on `nldd-menu`: useful in stories or
|
|
79
79
|
* documentation comparisons where you need different instances on the
|
|
80
80
|
* page to render as different operating systems. Don't ship this in
|
|
81
81
|
* production markup. Production should rely on real OS detection.
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
* highlighted row.
|
|
40
40
|
* @attr {'mac'|'windows'|'linux'|'other'} debug-os - Development aid: overrides the OS
|
|
41
41
|
* detection for this instance, so you can show several platform variants side by side in
|
|
42
|
-
*
|
|
42
|
+
* documentation. Not meant for production use; leave it empty (default) so
|
|
43
43
|
* the real OS detection applies.
|
|
44
44
|
*
|
|
45
45
|
* @slot - Optional custom <kbd> elements. Ignored when keys is set.
|
|
@@ -84,7 +84,7 @@ let NLDDKeyboardShortcut = class NLDDKeyboardShortcut extends LitElement {
|
|
|
84
84
|
* @internal Development only.
|
|
85
85
|
*
|
|
86
86
|
* Per-instance OS override that bypasses `detectOS()`. Same pattern as
|
|
87
|
-
* `debug-safe-triangle` on `nldd-menu`: useful in
|
|
87
|
+
* `debug-safe-triangle` on `nldd-menu`: useful in stories or
|
|
88
88
|
* documentation comparisons where you need different instances on the
|
|
89
89
|
* page to render as different operating systems. Don't ship this in
|
|
90
90
|
* production markup. Production should rely on real OS detection.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Directive, type ElementPart, type PartInfo } from 'lit/directive.js';
|
|
2
2
|
/**
|
|
3
|
-
* Shared
|
|
3
|
+
* Shared story controls for the PageSectionMixin surface API
|
|
4
4
|
* (background, width, height, grow and the 12 block-padding overrides).
|
|
5
5
|
* Spread into a section story's `args` / `argTypes`, and bind onto the host
|
|
6
6
|
* element in `render` with the `pageSectionAttrs` directive.
|
|
@@ -13,7 +13,7 @@ const paddingControl = (name, description) => ({
|
|
|
13
13
|
table: { defaultValue: { summary: '(auto)' } },
|
|
14
14
|
});
|
|
15
15
|
/**
|
|
16
|
-
* Shared
|
|
16
|
+
* Shared story controls for the PageSectionMixin surface API
|
|
17
17
|
* (background, width, height, grow and the 12 block-padding overrides).
|
|
18
18
|
* Spread into a section story's `args` / `argTypes`, and bind onto the host
|
|
19
19
|
* element in `render` with the `pageSectionAttrs` directive.
|
package/dist/types/react.d.ts
CHANGED
|
@@ -1241,7 +1241,7 @@ type NlddImageProps = {
|
|
|
1241
1241
|
'credit'?: NLDDImage['credit'];
|
|
1242
1242
|
/** Decorative image: alt is forced empty + aria-hidden */
|
|
1243
1243
|
'decorative'?: true;
|
|
1244
|
-
/** Loading preview (LQIP, low-quality image placeholder) as a CSV string `"base,c1,c2,c3,c4,c5,c6"`: seven 0-255 bytes, each packing an 8-bit Oklab triplet (2 bits L, 3 bits a, 3 bits b). The first is the base color shown outside the cell gradients; the other six are per-cell colors in row-major 3×2 order. Generate via the encoder in `lqip-encoder.ts` or via the
|
|
1244
|
+
/** Loading preview (LQIP, low-quality image placeholder) as a CSV string `"base,c1,c2,c3,c4,c5,c6"`: seven 0-255 bytes, each packing an 8-bit Oklab triplet (2 bits L, 3 bits a, 3 bits b). The first is the base color shown outside the cell gradients; the other six are per-cell colors in row-major 3×2 order. Generate via the encoder in `lqip-encoder.ts` or via the LQIP-encoder example on `/componenten/image/`. Extends Lean Rada's CSS-only LQIP (https://leanrada.com/notes/css-only-lqip/) with per-cell hue. Lean's original format encodes grayscale cells only, while ours encodes a color per cell so multi-color subjects survive the preview. */
|
|
1245
1245
|
'lqip'?: NLDDImage['lqip'];
|
|
1246
1246
|
/** Override translation keys (e.g. the message shown when the image fails to load); unset keys fall back to Dutch. */
|
|
1247
1247
|
'translations'?: NLDDImage['translations'];
|
|
@@ -1322,7 +1322,7 @@ type NlddKeyboardShortcutProps = {
|
|
|
1322
1322
|
'color'?: NLDDKeyboardShortcut['color'];
|
|
1323
1323
|
/** Show on touch-only devices too, where shortcuts cannot be invoked. */
|
|
1324
1324
|
'always-visible'?: true;
|
|
1325
|
-
/** Development aid: overrides the OS detection for this instance, so you can show several platform variants side by side in
|
|
1325
|
+
/** Development aid: overrides the OS detection for this instance, so you can show several platform variants side by side in documentation. Not meant for production use; leave it empty (default) so the real OS detection applies. */
|
|
1326
1326
|
'debug-os'?: NLDDKeyboardShortcut['debugOs'];
|
|
1327
1327
|
};
|
|
1328
1328
|
|
package/dist/types/vue.d.ts
CHANGED
|
@@ -1767,7 +1767,7 @@ declare module 'vue' {
|
|
|
1767
1767
|
'credit'?: NLDDImage['credit'];
|
|
1768
1768
|
/** Decorative image: alt is forced empty + aria-hidden */
|
|
1769
1769
|
'decorative'?: NLDDImage['decorative'];
|
|
1770
|
-
/** Loading preview (LQIP, low-quality image placeholder) as a CSV string `"base,c1,c2,c3,c4,c5,c6"`: seven 0-255 bytes, each packing an 8-bit Oklab triplet (2 bits L, 3 bits a, 3 bits b). The first is the base color shown outside the cell gradients; the other six are per-cell colors in row-major 3×2 order. Generate via the encoder in `lqip-encoder.ts` or via the
|
|
1770
|
+
/** Loading preview (LQIP, low-quality image placeholder) as a CSV string `"base,c1,c2,c3,c4,c5,c6"`: seven 0-255 bytes, each packing an 8-bit Oklab triplet (2 bits L, 3 bits a, 3 bits b). The first is the base color shown outside the cell gradients; the other six are per-cell colors in row-major 3×2 order. Generate via the encoder in `lqip-encoder.ts` or via the LQIP-encoder example on `/componenten/image/`. Extends Lean Rada's CSS-only LQIP (https://leanrada.com/notes/css-only-lqip/) with per-cell hue. Lean's original format encodes grayscale cells only, while ours encodes a color per cell so multi-color subjects survive the preview. */
|
|
1771
1771
|
'lqip'?: NLDDImage['lqip'];
|
|
1772
1772
|
/** Override translation keys (e.g. the message shown when the image fails to load); unset keys fall back to Dutch. */
|
|
1773
1773
|
'translations'?: NLDDImage['translations'];
|
|
@@ -1886,9 +1886,9 @@ declare module 'vue' {
|
|
|
1886
1886
|
'always-visible'?: NLDDKeyboardShortcut['alwaysVisible'];
|
|
1887
1887
|
/** Show on touch-only devices too, where shortcuts cannot be invoked. */
|
|
1888
1888
|
'alwaysVisible'?: NLDDKeyboardShortcut['alwaysVisible'];
|
|
1889
|
-
/** Development aid: overrides the OS detection for this instance, so you can show several platform variants side by side in
|
|
1889
|
+
/** Development aid: overrides the OS detection for this instance, so you can show several platform variants side by side in documentation. Not meant for production use; leave it empty (default) so the real OS detection applies. */
|
|
1890
1890
|
'debug-os'?: NLDDKeyboardShortcut['debugOs'];
|
|
1891
|
-
/** Development aid: overrides the OS detection for this instance, so you can show several platform variants side by side in
|
|
1891
|
+
/** Development aid: overrides the OS detection for this instance, so you can show several platform variants side by side in documentation. Not meant for production use; leave it empty (default) so the real OS detection applies. */
|
|
1892
1892
|
'debugOs'?: NLDDKeyboardShortcut['debugOs'];
|
|
1893
1893
|
};
|
|
1894
1894
|
|
package/dist/utilities/os.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare function detectOS(): OS;
|
|
|
12
12
|
/**
|
|
13
13
|
* @internal — test/dev only.
|
|
14
14
|
*
|
|
15
|
-
* Force a specific OS for the duration of
|
|
15
|
+
* Force a specific OS for the duration of a test or a story.
|
|
16
16
|
* Pass `null` to clear the override and fall back to real detection.
|
|
17
17
|
* Mutates module-level singleton state and affects every component on
|
|
18
18
|
* the page that calls `detectOS()` — not a supported public API
|
package/dist/utilities/os.js
CHANGED
|
@@ -41,7 +41,7 @@ export function detectOS() {
|
|
|
41
41
|
/**
|
|
42
42
|
* @internal — test/dev only.
|
|
43
43
|
*
|
|
44
|
-
* Force a specific OS for the duration of
|
|
44
|
+
* Force a specific OS for the duration of a test or a story.
|
|
45
45
|
* Pass `null` to clear the override and fall back to real detection.
|
|
46
46
|
* Mutates module-level singleton state and affects every component on
|
|
47
47
|
* the page that calls `detectOS()` — not a supported public API
|
package/lint/format.js
CHANGED
|
@@ -45,7 +45,10 @@ function hintSummary(results, root, explainRule) {
|
|
|
45
45
|
return lines;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
/** `in 2 files`, and how many with our markup the linter could not read besides. */
|
|
49
|
+
const inFiles = (files, unread) => `in ${plural(files, 'file')}${unread ? ` (${unread} not read)` : ''}`;
|
|
50
|
+
|
|
51
|
+
export function formatText(results, { root, files, unread, ms, skipped, loose, explainRule }) {
|
|
49
52
|
const lines = [];
|
|
50
53
|
for (const { filename, source, findings } of results) {
|
|
51
54
|
const sourceLines = source.split('\n');
|
|
@@ -66,7 +69,7 @@ export function formatText(results, { root, files, ms, skipped, loose, explainRu
|
|
|
66
69
|
const warnings = count('warn');
|
|
67
70
|
const hints = count('hint') ? `, ${plural(count('hint'), 'hint')}` : '';
|
|
68
71
|
const known = (skipped ? dim(` (${skipped} in baseline)`) : '') + (loose ? dim(` (${loose} accepted no longer found: run --tighten-baseline)`) : '');
|
|
69
|
-
const summary = `${plural(errors, 'error')}, ${plural(warnings, 'warning')}${hints}
|
|
72
|
+
const summary = `${plural(errors, 'error')}, ${plural(warnings, 'warning')}${hints} ${inFiles(files, unread)} (${ms} ms)`;
|
|
70
73
|
const fixable = all.filter(({ fix }) => fix).length;
|
|
71
74
|
const canFix = fixable ? `, ${fixable} fixable with --fix` : '';
|
|
72
75
|
lines.push(`${errors + warnings ? red('✖') : '✔'} ${summary}${known}${canFix}`);
|
|
@@ -74,7 +77,7 @@ export function formatText(results, { root, files, ms, skipped, loose, explainRu
|
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
/** A count per rule, most first: where to start when a project has hundreds. */
|
|
77
|
-
export function formatStatistics(results, { files, ms, skipped }) {
|
|
80
|
+
export function formatStatistics(results, { files, unread, ms, skipped }) {
|
|
78
81
|
const counts = new Map();
|
|
79
82
|
for (const { rule, severity, fix } of results.flatMap(({ findings }) => findings)) {
|
|
80
83
|
const entry = counts.get(rule) ?? { rule, severity, count: 0 };
|
|
@@ -88,7 +91,7 @@ export function formatStatistics(results, { files, ms, skipped }) {
|
|
|
88
91
|
return [
|
|
89
92
|
...rows.map(({ count, severity, rule, fixable }) => `${String(count).padStart(width)} ${severity.padEnd(5)} ${rule}${fixable ? ' [--fix]' : ''}`),
|
|
90
93
|
...(rows.length > 0 ? [''] : []),
|
|
91
|
-
`${plural(total, 'finding')}
|
|
94
|
+
`${plural(total, 'finding')} ${inFiles(files, unread)} (${ms} ms)${skipped ? ` (${skipped} in baseline)` : ''}`,
|
|
92
95
|
].join('\n');
|
|
93
96
|
}
|
|
94
97
|
|
package/lint/frontends.js
CHANGED
|
@@ -115,6 +115,8 @@ function readHtmlChildren(children, parent, given) {
|
|
|
115
115
|
for (const block of styleBlocks(node)) appendChild(parent, styleNode(block));
|
|
116
116
|
continue;
|
|
117
117
|
}
|
|
118
|
+
// Content a frontend already knows nobody can read here.
|
|
119
|
+
if (node.type === 'hole') appendUnknown(parent, node.startIndex);
|
|
118
120
|
if (node.type !== 'tag') continue;
|
|
119
121
|
const { name, attribs } = node;
|
|
120
122
|
// In a document, a template is inert until something stamps it out, here or elsewhere.
|
|
@@ -390,6 +392,350 @@ function mdxAsHtml(mdx) {
|
|
|
390
392
|
return out.join('');
|
|
391
393
|
}
|
|
392
394
|
|
|
395
|
+
/** Private-use characters that stand in the text for an expression, one per brace. */
|
|
396
|
+
const HOLE = '\uE000';
|
|
397
|
+
const OPENS_CONDITION = '\uE001';
|
|
398
|
+
const OPENS_LOOP = '\uE002';
|
|
399
|
+
const OPENS_BOTH = '\uE003';
|
|
400
|
+
const CLOSES = '\uE004';
|
|
401
|
+
const MARKS = new Set([HOLE, OPENS_CONDITION, OPENS_LOOP, OPENS_BOTH, CLOSES]);
|
|
402
|
+
|
|
403
|
+
/** Elements HTML never closes, so they do not nest inside an expression either. */
|
|
404
|
+
const VOID = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
|
|
405
|
+
|
|
406
|
+
/** Stands for an element in the script of an expression, when that script is judged. */
|
|
407
|
+
const ELEMENT = '\uE005';
|
|
408
|
+
|
|
409
|
+
const ONLY_COMMENTS = /^(\/\*[\s\S]*?\*\/\s*)+$/;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Whether the script around the elements of an expression can render something
|
|
413
|
+
* else: a branch of `? :`, `||` or `??` that is no element and not nothing.
|
|
414
|
+
*/
|
|
415
|
+
function rendersMore(script) {
|
|
416
|
+
const parts = [];
|
|
417
|
+
// The bracket depth of every `?` that waits for its `:`.
|
|
418
|
+
const ternaries = [];
|
|
419
|
+
let depth = 0;
|
|
420
|
+
let glue = false;
|
|
421
|
+
for (const piece of script.replace(/\s/g, '').split(/(\?\?|\|\||\?(?!\.)|:)/)) {
|
|
422
|
+
// A `:` at another depth than the open `?` is a type or a key, `(item: Item) =>`: part of the operand.
|
|
423
|
+
const isType = piece === ':' && ternaries.at(-1) !== depth;
|
|
424
|
+
const part = piece.replace(/[()]/g, '');
|
|
425
|
+
if (isType || glue) parts.push(parts.pop() + part);
|
|
426
|
+
else parts.push(part);
|
|
427
|
+
glue = isType;
|
|
428
|
+
if (piece === '?') ternaries.push(depth);
|
|
429
|
+
else if (piece === ':' && !isType) ternaries.pop();
|
|
430
|
+
else depth += (piece.match(/[([{]/g)?.length ?? 0) - (piece.match(/[)\]}]/g)?.length ?? 0);
|
|
431
|
+
}
|
|
432
|
+
const rendersNothingElse = (part) => part.includes(ELEMENT) || /^(null|undefined|false|''|"")?[}\];,]*$/.test(part);
|
|
433
|
+
for (let at = 1; at < parts.length; at += 2) {
|
|
434
|
+
// What stands left of `||` and `??` is rendered when it is there.
|
|
435
|
+
const leftRenders = parts[at] !== '?' && parts[at] !== ':' && !parts[at - 1].includes(ELEMENT);
|
|
436
|
+
// Before a `?` stands a condition, `a ? <x /> : b ? <y /> : null`, not a branch.
|
|
437
|
+
const isCondition = parts[at + 2] === '?';
|
|
438
|
+
if (leftRenders || (!isCondition && !rendersNothingElse(parts[at + 1]))) return true;
|
|
439
|
+
}
|
|
440
|
+
return false;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** After these a `<` starts an element; after any other word it compares. */
|
|
444
|
+
const BEFORE_ELEMENT = new Set(['return', 'yield', 'await', 'case', 'default', 'else', 'do', 'typeof', 'void', 'in', 'of']);
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Astro as HTML of the same length. The frontmatter goes. An expression in a value
|
|
448
|
+
* reads as bound, a spread or a shorthand as a spread. An expression between the
|
|
449
|
+
* tags keeps the elements it holds and loses its script: a mark where it starts
|
|
450
|
+
* says whether they are behind a condition or in a loop, and one where it ends
|
|
451
|
+
* closes that. An expression without elements leaves one mark, for content nobody
|
|
452
|
+
* can read here.
|
|
453
|
+
*/
|
|
454
|
+
function astroAsHtml(source) {
|
|
455
|
+
const out = source.split('');
|
|
456
|
+
const { length } = source;
|
|
457
|
+
const put = (at, text) => {
|
|
458
|
+
for (let i = 0; i < text.length; i += 1) out[at + i] = text[i];
|
|
459
|
+
};
|
|
460
|
+
const clear = (from, to) => {
|
|
461
|
+
for (let i = from; i < to; i += 1) if (out[i] !== '\n') out[i] = ' ';
|
|
462
|
+
};
|
|
463
|
+
const find = (text, from) => {
|
|
464
|
+
const at = source.indexOf(text, from);
|
|
465
|
+
return at === -1 ? length : at;
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
// The same characters in the file itself are no marks.
|
|
469
|
+
for (let i = 0; i < length; i += 1) if (MARKS.has(out[i])) out[i] = ' ';
|
|
470
|
+
|
|
471
|
+
const frontmatter = /^\s*---[ \t]*\r?\n(?:[\s\S]*?\n)?---[ \t]*\r?(?:\n|$)/.exec(source);
|
|
472
|
+
if (frontmatter) clear(0, frontmatter[0].length);
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Whether the `<` here opens an element, going by the script before it: `last` is
|
|
476
|
+
* where that ends, past any comment and whitespace, or -1 at the start.
|
|
477
|
+
*/
|
|
478
|
+
function opensElement(at, last) {
|
|
479
|
+
if (!/[a-zA-Z>]/.test(source[at + 1] ?? '')) return false;
|
|
480
|
+
const before = source.slice(Math.max(0, last - 20), last + 1);
|
|
481
|
+
const word = /(?<![\w$.])[a-z]+$/.exec(before)?.[0];
|
|
482
|
+
if (word) return BEFORE_ELEMENT.has(word);
|
|
483
|
+
// After a value, a `<` compares: a name, a call, an index or a string.
|
|
484
|
+
return !/[\w$)\]'"`.]$/.test(before);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** From the `/` of a regex to the one that closes it, on the same line; else nowhere. */
|
|
488
|
+
function endOfRegex(start) {
|
|
489
|
+
let inClass = false;
|
|
490
|
+
for (let at = start + 1; at < length && source[at] !== '\n'; at += 1) {
|
|
491
|
+
if (source[at] === '\\') at += 1;
|
|
492
|
+
else if (source[at] === '[') inClass = true;
|
|
493
|
+
else if (source[at] === ']') inClass = false;
|
|
494
|
+
else if (source[at] === '/' && !inClass) return at;
|
|
495
|
+
}
|
|
496
|
+
return start;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/** From a backtick to the one that closes it, past every `${…}`. */
|
|
500
|
+
function endOfTemplate(start) {
|
|
501
|
+
let at = start + 1;
|
|
502
|
+
while (at < length && source[at] !== '`') {
|
|
503
|
+
if (source[at] === '\\') at += 1;
|
|
504
|
+
else if (source.startsWith('${', at)) at = endOfScript(at + 1);
|
|
505
|
+
at += 1;
|
|
506
|
+
}
|
|
507
|
+
return at;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* From a `{` to the `}` that closes it, past strings, comments and nested braces.
|
|
512
|
+
* With `elements`, every element in it is read as markup and listed there.
|
|
513
|
+
*/
|
|
514
|
+
function endOfScript(start, elements) {
|
|
515
|
+
let depth = 0;
|
|
516
|
+
let at = start;
|
|
517
|
+
// The last character of script so far: a comment says nothing about what follows it.
|
|
518
|
+
let last = -1;
|
|
519
|
+
while (at < length) {
|
|
520
|
+
const char = source[at];
|
|
521
|
+
const isComment = source.startsWith('/*', at) || source.startsWith('//', at);
|
|
522
|
+
if (char === '"' || char === "'") at = endOfString(source, at);
|
|
523
|
+
else if (char === '`') at = endOfTemplate(at);
|
|
524
|
+
else if (isComment) at = source[at + 1] === '*' ? find('*/', at + 2) + 1 : find('\n', at);
|
|
525
|
+
// After a value a `/` divides; anywhere else it opens a regex, which may hold a quote.
|
|
526
|
+
else if (char === '/' && !/[\w$)\]'"`]/.test(source[last] ?? '')) at = endOfRegex(at);
|
|
527
|
+
else if (char === '{') depth += 1;
|
|
528
|
+
else if (char === '}' && --depth === 0) return at;
|
|
529
|
+
else if (char === '<' && elements && opensElement(at, last)) {
|
|
530
|
+
const end = readMarkup(at, true);
|
|
531
|
+
elements.push([at, end]);
|
|
532
|
+
at = end - 1;
|
|
533
|
+
}
|
|
534
|
+
if (!isComment && /\S/.test(source[at] ?? '') && at > start) last = at;
|
|
535
|
+
at += 1;
|
|
536
|
+
}
|
|
537
|
+
return length - 1;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** An expression as a value, or loose in a tag: a filler without spaces, so it stays one attribute. */
|
|
541
|
+
function fillInTag(start, end, isValue) {
|
|
542
|
+
const size = end - start + 1;
|
|
543
|
+
// Straight before `/>` an unquoted value would swallow the slash.
|
|
544
|
+
const room = isValue && source[end + 1] === '/' ? size - 1 : size;
|
|
545
|
+
clear(start, end + 1);
|
|
546
|
+
// A comment between the attributes sets nothing.
|
|
547
|
+
if (!isValue && ONLY_COMMENTS.test(source.slice(start + 1, end).trim())) return;
|
|
548
|
+
if (!isValue) put(start, size >= 3 ? `:[${'x'.repeat(size - 3)}]` : '');
|
|
549
|
+
else if (room >= 3) put(start, `\${${'x'.repeat(room - 3)}}`);
|
|
550
|
+
else put(start, room === 2 && size === 3 ? '{{' : '""');
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** One start tag, from its `<`. Says where it ends and whether its content is raw text. */
|
|
554
|
+
function readTag(start) {
|
|
555
|
+
const name = /^[^\s/>]*/.exec(source.slice(start + 1))[0];
|
|
556
|
+
let at = start + 1 + name.length;
|
|
557
|
+
let raw = /^(script|style)$/i.test(name);
|
|
558
|
+
while (at < length && source[at] !== '>') {
|
|
559
|
+
const char = source[at];
|
|
560
|
+
if (char === '{') {
|
|
561
|
+
const end = endOfScript(at);
|
|
562
|
+
fillInTag(at, end, false);
|
|
563
|
+
at = end + 1;
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
if (/[\s/]/.test(char)) {
|
|
567
|
+
at += 1;
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
const written = /^[^\s=/>{]+/.exec(source.slice(at))?.[0] ?? char;
|
|
571
|
+
if (written === 'is:raw') raw = true;
|
|
572
|
+
at += written.length;
|
|
573
|
+
const equals = /^\s*=\s*/.exec(source.slice(at));
|
|
574
|
+
if (!equals) continue;
|
|
575
|
+
at += equals[0].length;
|
|
576
|
+
const first = source[at];
|
|
577
|
+
if (first === '"' || first === "'") at = find(first, at + 1) + 1;
|
|
578
|
+
else if (first === '{' || first === '`') {
|
|
579
|
+
const end = first === '{' ? endOfScript(at) : endOfTemplate(at);
|
|
580
|
+
fillInTag(at, end, true);
|
|
581
|
+
at = end + 1;
|
|
582
|
+
} else at += /^[^\s>]*/.exec(source.slice(at))[0].length;
|
|
583
|
+
}
|
|
584
|
+
return { name, end: at, selfClosing: source[at - 1] === '/', raw };
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/** What an expression between the tags leaves behind. */
|
|
588
|
+
function fillExpression(start, end, elements) {
|
|
589
|
+
const script = [];
|
|
590
|
+
let from = start;
|
|
591
|
+
// A place in the script, between the braces, where a mark can stand.
|
|
592
|
+
let free = -1;
|
|
593
|
+
for (const [elementStart, elementEnd] of [...elements, [end + 1, end + 1]]) {
|
|
594
|
+
script.push(source.slice(from, elementStart));
|
|
595
|
+
clear(from, elementStart);
|
|
596
|
+
const first = Math.max(from, start + 1);
|
|
597
|
+
if (free === -1 && first < Math.min(elementStart, end)) free = first;
|
|
598
|
+
from = elementEnd;
|
|
599
|
+
}
|
|
600
|
+
if (elements.length > 0) {
|
|
601
|
+
// A string goes first, so a `//` in `'https://…'` is no comment that eats the line.
|
|
602
|
+
const strings = /'(?:\\.|[^'\\\n])+'|"(?:\\.|[^"\\\n])+"|`(?:\\.|[^`\\])+`/g;
|
|
603
|
+
const text = script.map((part) => part.replace(strings, "'x'")).join(ELEMENT).replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '');
|
|
604
|
+
// Only an element between the braces: it is there, as if written without them.
|
|
605
|
+
if (!/[^\s(){}\uE005]/.test(text)) return;
|
|
606
|
+
const loop = /=>|\bfunction\b/.test(text);
|
|
607
|
+
const condition = /&&|\|\||\?/.test(text) || !loop;
|
|
608
|
+
put(start, loop && condition ? OPENS_BOTH : loop ? OPENS_LOOP : OPENS_CONDITION);
|
|
609
|
+
put(end, CLOSES);
|
|
610
|
+
// `a ? 'tekst' : <x />` and `a || <x />` can render something that is no element.
|
|
611
|
+
if (free !== -1 && rendersMore(text)) put(free, HOLE);
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
const inner = source.slice(start + 1, end).trim();
|
|
615
|
+
const literal = /^(["'])([^"'<&{}\\\n]*)\1$/.exec(inner);
|
|
616
|
+
// A string written out is text, and a comment renders nothing.
|
|
617
|
+
if (literal) put(source.indexOf(literal[2], start), literal[2]);
|
|
618
|
+
else if (inner !== '' && !ONLY_COMMENTS.test(inner)) put(start, HOLE);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Markup from `at`. Inside an expression it reads one element, or one fragment,
|
|
623
|
+
* and returns where that ends, so the script around it can go on.
|
|
624
|
+
*/
|
|
625
|
+
function readMarkup(start, oneElement = false) {
|
|
626
|
+
let at = start;
|
|
627
|
+
let depth = 0;
|
|
628
|
+
while (at < length) {
|
|
629
|
+
if (source.startsWith('<!--', at)) {
|
|
630
|
+
at = Math.min(find('-->', at + 4) + 3, length);
|
|
631
|
+
} else if (source.startsWith('</', at)) {
|
|
632
|
+
const end = find('>', at);
|
|
633
|
+
if (end === at + 2) clear(at, end + 1);
|
|
634
|
+
at = end + 1;
|
|
635
|
+
depth -= 1;
|
|
636
|
+
if (oneElement && depth <= 0) return at;
|
|
637
|
+
} else if (source.startsWith('<>', at)) {
|
|
638
|
+
clear(at, at + 2);
|
|
639
|
+
at += 2;
|
|
640
|
+
depth += 1;
|
|
641
|
+
} else if (source[at] === '<' && /[a-zA-Z]/.test(source[at + 1] ?? '')) {
|
|
642
|
+
const tag = readTag(at);
|
|
643
|
+
at = tag.end + 1;
|
|
644
|
+
const closes = tag.selfClosing || VOID.has(tag.name.toLowerCase());
|
|
645
|
+
if (!closes) depth += 1;
|
|
646
|
+
if (tag.raw && !closes) {
|
|
647
|
+
// Case-insensitive without lowering the source, which can change its length.
|
|
648
|
+
const closer = new RegExp(`</${tag.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'gi');
|
|
649
|
+
closer.lastIndex = at;
|
|
650
|
+
const end = closer.exec(source)?.index ?? length;
|
|
651
|
+
// What `is:raw` holds is text as it stands, not elements and not expressions.
|
|
652
|
+
if (!/^(script|style)$/i.test(tag.name)) for (let i = at; i < end; i += 1) if (/[<{}]/.test(out[i])) out[i] = ' ';
|
|
653
|
+
at = end;
|
|
654
|
+
}
|
|
655
|
+
if (oneElement && depth <= 0) return at;
|
|
656
|
+
} else if (source[at] === '{') {
|
|
657
|
+
const elements = [];
|
|
658
|
+
const end = endOfScript(at, elements);
|
|
659
|
+
fillExpression(at, end, elements);
|
|
660
|
+
at = end + 1;
|
|
661
|
+
} else at += 1;
|
|
662
|
+
}
|
|
663
|
+
return length;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
readMarkup(frontmatter ? frontmatter[0].length : 0);
|
|
667
|
+
return out.join('');
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/** Directives of Astro itself: they tell the compiler something and set no attribute. */
|
|
671
|
+
const ASTRO_DIRECTIVE = /^(client|set|is|define|transition|server|class):/;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Turns the marks of `astroAsHtml` into what the tree builder already knows: a
|
|
675
|
+
* wrapper with a condition or a loop around the elements of an expression, and a
|
|
676
|
+
* hole for content that is filled in. `set:html` fills an element the same way.
|
|
677
|
+
*/
|
|
678
|
+
function liftAstro(children) {
|
|
679
|
+
const out = [];
|
|
680
|
+
const open = [out];
|
|
681
|
+
const hole = (startIndex) => ({ type: 'hole', startIndex });
|
|
682
|
+
for (const node of children) {
|
|
683
|
+
if (node.type === 'text') {
|
|
684
|
+
let from = 0;
|
|
685
|
+
const flush = (to) => {
|
|
686
|
+
if (to > from) open.at(-1).push({ type: 'text', data: node.data.slice(from, to), startIndex: (node.startIndex ?? 0) + from });
|
|
687
|
+
from = to + 1;
|
|
688
|
+
};
|
|
689
|
+
for (let at = 0; at < node.data.length; at += 1) {
|
|
690
|
+
const mark = node.data[at];
|
|
691
|
+
if (!MARKS.has(mark)) continue;
|
|
692
|
+
flush(at);
|
|
693
|
+
const startIndex = (node.startIndex ?? 0) + at;
|
|
694
|
+
if (mark === HOLE) open.at(-1).push(hole(startIndex));
|
|
695
|
+
else if (mark === CLOSES) {
|
|
696
|
+
if (open.length > 1) open.pop();
|
|
697
|
+
} else {
|
|
698
|
+
const attribs = {};
|
|
699
|
+
if (mark !== OPENS_LOOP) attribs['v-if'] = '';
|
|
700
|
+
if (mark !== OPENS_CONDITION) attribs['v-for'] = '';
|
|
701
|
+
const wrapper = { type: 'tag', name: 'Fragment', attribs, children: [], startIndex };
|
|
702
|
+
open.at(-1).push(wrapper);
|
|
703
|
+
open.push(wrapper.children);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
flush(node.data.length);
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (node.type === 'tag') {
|
|
710
|
+
const names = Object.keys(node.attribs);
|
|
711
|
+
const filled = names.some((name) => name === 'set:html' || name === 'set:text');
|
|
712
|
+
// An inert template, and a fragment that is filled in: unknown here. A fragment
|
|
713
|
+
// that names a slot of its component renders nothing itself, so it reads through.
|
|
714
|
+
if (node.name === 'template' || (node.name === 'Fragment' && filled)) {
|
|
715
|
+
open.at(-1).push(hole(node.startIndex ?? 0));
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
if (names.includes('class:list')) node.attribs.class ??= '${}';
|
|
719
|
+
for (const name of names) if (ASTRO_DIRECTIVE.test(name)) delete node.attribs[name];
|
|
720
|
+
node.children = filled ? [hole(node.startIndex ?? 0)] : liftAstro(node.children);
|
|
721
|
+
}
|
|
722
|
+
open.at(-1).push(node);
|
|
723
|
+
}
|
|
724
|
+
return out;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* An Astro component: frontmatter, then a template that is HTML with expressions.
|
|
729
|
+
* Its root stays open, also for a layout with an `<html>`: the page comes in
|
|
730
|
+
* through a slot.
|
|
731
|
+
*/
|
|
732
|
+
export function parseAstro(source) {
|
|
733
|
+
const root = createRoot();
|
|
734
|
+
const document = parseMarkup(astroAsHtml(source), { selfClosing: true, original: source });
|
|
735
|
+
readHtmlChildren(liftAstro(document.children), root, {});
|
|
736
|
+
return [root];
|
|
737
|
+
}
|
|
738
|
+
|
|
393
739
|
/**
|
|
394
740
|
* Which text in an element Markdown writes a paragraph around. Raw HTML in Markdown
|
|
395
741
|
* runs to the first blank line, and what follows is Markdown again. In MDX, an
|
|
@@ -880,6 +1226,7 @@ const PARSERS = {
|
|
|
880
1226
|
'.jinja': parseHtml,
|
|
881
1227
|
'.jinja2': parseHtml,
|
|
882
1228
|
'.vue': parseVue,
|
|
1229
|
+
'.astro': parseAstro,
|
|
883
1230
|
'.md': parseMarkdown,
|
|
884
1231
|
'.mdx': parseMarkdown,
|
|
885
1232
|
'.jsx': parseJsx,
|
package/lint/linter.js
CHANGED
|
@@ -193,7 +193,7 @@ function createPositions(source) {
|
|
|
193
193
|
|
|
194
194
|
|
|
195
195
|
/** Files where `//` is no comment: in markup it starts a url, and a built page is one line. */
|
|
196
|
-
const MARKUP_FILE = /\.(html?|j2|jinja2?|tmpl|gohtml|vue|md)$/;
|
|
196
|
+
const MARKUP_FILE = /\.(html?|j2|jinja2?|tmpl|gohtml|vue|astro|md)$/;
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
199
|
* A stylesheet a page links to, on disk next to it: relative to the page, or from the
|
package/lint/main.js
CHANGED
package/lint/project.js
CHANGED
|
@@ -7,7 +7,14 @@ import { declarations, TOKEN_PREFIX } from './css.js';
|
|
|
7
7
|
|
|
8
8
|
export const IGNORED_DIRECTORIES = new Set(['node_modules', 'dist', 'build', 'coverage', '.git', '.next', '.nuxt']);
|
|
9
9
|
/** Markdown is linted on request: documentation is full of deliberately wrong examples. */
|
|
10
|
-
export const DEFAULT_EXTENSIONS = ['.html', '.htm', '.j2', '.jinja', '.jinja2', '.tmpl', '.gohtml', '.vue', '.jsx', '.tsx', '.js'];
|
|
10
|
+
export const DEFAULT_EXTENSIONS = ['.html', '.htm', '.j2', '.jinja', '.jinja2', '.tmpl', '.gohtml', '.vue', '.astro', '.jsx', '.tsx', '.js'];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Templates the linter has no parser for. A scan of a directory still opens them:
|
|
14
|
+
* one with `nldd-*` markup gets `file-not-read`, so a project in such a language
|
|
15
|
+
* does not read as checked and clean.
|
|
16
|
+
*/
|
|
17
|
+
export const UNREAD_EXTENSIONS = ['.svelte', '.php', '.twig', '.erb', '.ejs', '.hbs', '.handlebars', '.mustache', '.njk', '.liquid', '.cshtml', '.razor'];
|
|
11
18
|
|
|
12
19
|
/** An app's own stylesheets: read for the tokens they name, and in full when the group pure is on. */
|
|
13
20
|
export const STYLESHEET_EXTENSIONS = ['.css', '.scss', '.sass', '.less'];
|
package/lint/session.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* corpus measures the linter consumers run.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { readFileSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import { readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
10
10
|
import { extname, relative, resolve, sep } from 'node:path';
|
|
11
11
|
import { applyFixes, linesNaming, renameReferences } from './fix.js';
|
|
12
12
|
import { BUILT_IN_RULES, GROUPS, OPT_IN_GROUPS } from './rule-data.js';
|
|
13
|
-
import { DEFAULT_EXTENSIONS, findFiles, IGNORED_DIRECTORIES, isBundle, isRelevant, projectTokens, REFERENCE_EXTENSIONS, STYLESHEET_EXTENSIONS } from './project.js';
|
|
13
|
+
import { DEFAULT_EXTENSIONS, findFiles, IGNORED_DIRECTORIES, isBundle, isRelevant, projectTokens, REFERENCE_EXTENSIONS, STYLESHEET_EXTENSIONS, UNREAD_EXTENSIONS } from './project.js';
|
|
14
14
|
|
|
15
15
|
/** Every name `--select`, `--ignore` and .nldd-lint.json may use: rule ids, aliases and groups. */
|
|
16
16
|
export function knownKeys(data) {
|
|
@@ -46,9 +46,21 @@ async function fixUntilStable(linter, original, filename) {
|
|
|
46
46
|
return { source, fixed, renamedTags, findings: (await linter.lintSource(source, filename)).findings };
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
const isUnread = (filename) => UNREAD_EXTENSIONS.includes(extname(filename));
|
|
50
|
+
const hasOurMarkup = (source) => /<nldd-[a-z]/.test(source);
|
|
51
|
+
|
|
52
|
+
/** In a directory a build writes to, such as `dist`: output, not the app's own source. */
|
|
53
|
+
const isBuilt = (file, root) => relative(root, file).split(sep).some((part) => IGNORED_DIRECTORIES.has(part));
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A script a bundler wrote. Its chunks hold the design system's own component
|
|
57
|
+
* styles and markup in strings, which read as an app overriding them. The pages
|
|
58
|
+
* and stylesheets next to it are what a build has to show.
|
|
59
|
+
*/
|
|
60
|
+
const isBuiltScript = (file, root) => /\.[cm]?js$/.test(file) && isBuilt(file, root);
|
|
61
|
+
|
|
49
62
|
/** The tag is gone from the markup; what still names it would break or stop matching. */
|
|
50
63
|
function fixReferences(renamedTags, paths, root, exclude) {
|
|
51
|
-
const isBuilt = (file) => relative(root, file).split(sep).some((part) => IGNORED_DIRECTORIES.has(part));
|
|
52
64
|
const inMarkup = findFiles(paths, root, exclude);
|
|
53
65
|
const elsewhere = findFiles(paths, root, exclude, REFERENCE_EXTENSIONS).filter((file) => REFERENCE_EXTENSIONS.includes(extname(file)) && !inMarkup.includes(file));
|
|
54
66
|
let fixed = 0;
|
|
@@ -58,7 +70,7 @@ function fixReferences(renamedTags, paths, root, exclude) {
|
|
|
58
70
|
for (const list of [inMarkup, elsewhere]) {
|
|
59
71
|
for (const filename of list.filter((file) => !/\.min\.[cm]?js$/.test(file))) {
|
|
60
72
|
const source = readFileSync(filename, 'utf8');
|
|
61
|
-
const change = isBuilt(filename) ? { source, fixed: 0 } : renameReferences(source, renamedTags, kindOf(filename));
|
|
73
|
+
const change = isBuilt(filename, root) ? { source, fixed: 0 } : renameReferences(source, renamedTags, kindOf(filename));
|
|
62
74
|
if (change.fixed > 0 && isUtf8(filename)) {
|
|
63
75
|
writeFileSync(filename, change.source);
|
|
64
76
|
fixed += change.fixed;
|
|
@@ -80,22 +92,29 @@ function fixReferences(renamedTags, paths, root, exclude) {
|
|
|
80
92
|
* @param {{ filename: string, source: string }} [options.input] - one snippet instead of files
|
|
81
93
|
* @param {boolean} [options.fix] - write the fixes that are certain
|
|
82
94
|
* @param {(filename: string) => boolean} [options.keep] - read this file even without a component
|
|
83
|
-
* @returns {Promise<{ results: object[], files: number, fixed: number, fixedFiles: number,
|
|
95
|
+
* @returns {Promise<{ results: object[], files: number, unread: number, fixed: number, fixedFiles: number,
|
|
84
96
|
* notUtf8: string[], references?: { fixed: number, files: number, remaining: string[] } }>}
|
|
85
97
|
*/
|
|
86
98
|
export async function lintProject(data, { root, paths = [], config = {}, severities, input, fix = false, keep = () => false }) {
|
|
87
99
|
const everything = readsEverything(data, severities);
|
|
100
|
+
// A script named on the command line is read, also in `dist`: only a scan skips it.
|
|
101
|
+
const named = new Set(paths.map((path) => resolve(root, path)).filter((path) => statSync(path, { throwIfNoEntry: false })?.isFile()));
|
|
88
102
|
const inputs = input
|
|
89
103
|
? [{ filename: resolve(root, input.filename), source: input.source }]
|
|
90
|
-
: findFiles(paths, root, config.exclude, [...DEFAULT_EXTENSIONS, ...STYLESHEET_EXTENSIONS])
|
|
104
|
+
: findFiles(paths, root, config.exclude, [...DEFAULT_EXTENSIONS, ...STYLESHEET_EXTENSIONS, ...UNREAD_EXTENSIONS])
|
|
105
|
+
.filter((filename) => named.has(resolve(filename)) || !isBuiltScript(filename, root))
|
|
91
106
|
.map((filename) => ({ filename, source: readFileSync(filename, 'utf8') }))
|
|
107
|
+
// A template the linter cannot read matters only with our markup; the rest is let go.
|
|
108
|
+
.filter(({ filename, source }) => !isUnread(filename) || hasOurMarkup(source))
|
|
92
109
|
.filter(({ filename, source }) => !isBundle(filename, source));
|
|
93
110
|
|
|
94
111
|
// Most files in an app use no component at all, and those need no parser either.
|
|
95
112
|
// A stylesheet is still read for the tokens it declares.
|
|
96
113
|
const isStylesheet = (filename) => STYLESHEET_EXTENSIONS.includes(extname(filename));
|
|
97
114
|
const relevant = everything ? inputs : inputs.filter((one) => isRelevant(one, { wrappers: config.wrappers, keep }));
|
|
98
|
-
|
|
115
|
+
// A file without a parser was opened and not checked, so it does not count as one.
|
|
116
|
+
const checked = inputs.filter(({ filename }) => !isUnread(filename));
|
|
117
|
+
const files = everything ? checked.length : checked.filter(({ filename }) => !isStylesheet(filename)).length + relevant.filter(({ filename }) => isStylesheet(filename)).length;
|
|
99
118
|
|
|
100
119
|
const results = [];
|
|
101
120
|
const notUtf8 = [];
|
|
@@ -123,5 +142,8 @@ export async function lintProject(data, { root, paths = [], config = {}, severit
|
|
|
123
142
|
}
|
|
124
143
|
}
|
|
125
144
|
const references = renamedTags.size > 0 ? fixReferences(renamedTags, paths, root, config.exclude) : undefined;
|
|
126
|
-
|
|
145
|
+
// Not in `files`: what has our markup and was not read, so the summary can say so.
|
|
146
|
+
// Counted on the markup, so a suppressed `file-not-read` does not make it read.
|
|
147
|
+
const unread = inputs.filter(({ filename, source }) => isUnread(filename) && hasOurMarkup(source)).length;
|
|
148
|
+
return { results, files, unread, fixed, fixedFiles, notUtf8, references };
|
|
127
149
|
}
|