@terrazzo/parser 0.7.2 → 0.8.0
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 +20 -0
- package/dist/index.d.ts +707 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4598 -12
- package/dist/index.js.map +1 -1
- package/package.json +11 -7
- package/rolldown.config.ts +24 -0
- package/src/build/index.ts +2 -2
- package/src/index.ts +76 -1
- package/src/parse/index.ts +72 -13
- package/src/parse/json.ts +35 -29
- package/src/parse/normalize.ts +4 -14
- package/src/parse/validate.ts +81 -68
- package/dist/build/index.d.ts +0 -20
- package/dist/build/index.d.ts.map +0 -1
- package/dist/build/index.js +0 -166
- package/dist/build/index.js.map +0 -1
- package/dist/config.d.ts +0 -8
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -290
- package/dist/config.js.map +0 -1
- package/dist/lib/code-frame.d.ts +0 -31
- package/dist/lib/code-frame.d.ts.map +0 -1
- package/dist/lib/code-frame.js +0 -108
- package/dist/lib/code-frame.js.map +0 -1
- package/dist/lint/index.d.ts +0 -12
- package/dist/lint/index.d.ts.map +0 -1
- package/dist/lint/index.js +0 -105
- package/dist/lint/index.js.map +0 -1
- package/dist/lint/plugin-core/index.d.ts +0 -13
- package/dist/lint/plugin-core/index.d.ts.map +0 -1
- package/dist/lint/plugin-core/index.js +0 -40
- package/dist/lint/plugin-core/index.js.map +0 -1
- package/dist/lint/plugin-core/lib/docs.d.ts +0 -2
- package/dist/lint/plugin-core/lib/docs.d.ts.map +0 -1
- package/dist/lint/plugin-core/lib/docs.js +0 -4
- package/dist/lint/plugin-core/lib/docs.js.map +0 -1
- package/dist/lint/plugin-core/rules/a11y-min-contrast.d.ts +0 -40
- package/dist/lint/plugin-core/rules/a11y-min-contrast.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/a11y-min-contrast.js +0 -58
- package/dist/lint/plugin-core/rules/a11y-min-contrast.js.map +0 -1
- package/dist/lint/plugin-core/rules/a11y-min-font-size.d.ts +0 -14
- package/dist/lint/plugin-core/rules/a11y-min-font-size.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/a11y-min-font-size.js +0 -45
- package/dist/lint/plugin-core/rules/a11y-min-font-size.js.map +0 -1
- package/dist/lint/plugin-core/rules/colorspace.d.ts +0 -15
- package/dist/lint/plugin-core/rules/colorspace.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/colorspace.js +0 -85
- package/dist/lint/plugin-core/rules/colorspace.js.map +0 -1
- package/dist/lint/plugin-core/rules/consistent-naming.d.ts +0 -12
- package/dist/lint/plugin-core/rules/consistent-naming.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/consistent-naming.js +0 -49
- package/dist/lint/plugin-core/rules/consistent-naming.js.map +0 -1
- package/dist/lint/plugin-core/rules/descriptions.d.ts +0 -10
- package/dist/lint/plugin-core/rules/descriptions.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/descriptions.js +0 -32
- package/dist/lint/plugin-core/rules/descriptions.js.map +0 -1
- package/dist/lint/plugin-core/rules/duplicate-values.d.ts +0 -10
- package/dist/lint/plugin-core/rules/duplicate-values.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/duplicate-values.js +0 -65
- package/dist/lint/plugin-core/rules/duplicate-values.js.map +0 -1
- package/dist/lint/plugin-core/rules/max-gamut.d.ts +0 -15
- package/dist/lint/plugin-core/rules/max-gamut.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/max-gamut.js +0 -101
- package/dist/lint/plugin-core/rules/max-gamut.js.map +0 -1
- package/dist/lint/plugin-core/rules/required-children.d.ts +0 -19
- package/dist/lint/plugin-core/rules/required-children.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/required-children.js +0 -78
- package/dist/lint/plugin-core/rules/required-children.js.map +0 -1
- package/dist/lint/plugin-core/rules/required-modes.d.ts +0 -14
- package/dist/lint/plugin-core/rules/required-modes.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/required-modes.js +0 -52
- package/dist/lint/plugin-core/rules/required-modes.js.map +0 -1
- package/dist/lint/plugin-core/rules/required-typography-properties.d.ts +0 -11
- package/dist/lint/plugin-core/rules/required-typography-properties.d.ts.map +0 -1
- package/dist/lint/plugin-core/rules/required-typography-properties.js +0 -38
- package/dist/lint/plugin-core/rules/required-typography-properties.js.map +0 -1
- package/dist/logger.d.ts +0 -77
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -136
- package/dist/logger.js.map +0 -1
- package/dist/parse/alias.d.ts +0 -34
- package/dist/parse/alias.d.ts.map +0 -1
- package/dist/parse/alias.js +0 -302
- package/dist/parse/alias.js.map +0 -1
- package/dist/parse/index.d.ts +0 -36
- package/dist/parse/index.d.ts.map +0 -1
- package/dist/parse/index.js +0 -226
- package/dist/parse/index.js.map +0 -1
- package/dist/parse/json.d.ts +0 -52
- package/dist/parse/json.d.ts.map +0 -1
- package/dist/parse/json.js +0 -161
- package/dist/parse/json.js.map +0 -1
- package/dist/parse/normalize.d.ts +0 -24
- package/dist/parse/normalize.d.ts.map +0 -1
- package/dist/parse/normalize.js +0 -185
- package/dist/parse/normalize.js.map +0 -1
- package/dist/parse/validate.d.ts +0 -63
- package/dist/parse/validate.d.ts.map +0 -1
- package/dist/parse/validate.js +0 -798
- package/dist/parse/validate.js.map +0 -1
- package/dist/types.d.ts +0 -265
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lint/plugin-core/index.ts"],"names":[],"mappings":"AAIA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CA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;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/lib/docs.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/lib/docs.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,QAAgB;IACvC,OAAO,sCAAsC,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { LintRule } from '../../../types.js';
|
|
2
|
-
export declare const A11Y_MIN_CONTRAST = "a11y/min-contrast";
|
|
3
|
-
export interface RuleA11yMinContrastOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Whether to adhere to AA (minimum) or AAA (enhanced) contrast levels.
|
|
6
|
-
* @default "AA"
|
|
7
|
-
*/
|
|
8
|
-
level?: 'AA' | 'AAA';
|
|
9
|
-
/** Pairs of color tokens (and optionally typography) to test */
|
|
10
|
-
pairs: ContrastPair[];
|
|
11
|
-
}
|
|
12
|
-
export interface ContrastPair {
|
|
13
|
-
/** The foreground color token ID */
|
|
14
|
-
foreground: string;
|
|
15
|
-
/** The background color token ID */
|
|
16
|
-
background: string;
|
|
17
|
-
/**
|
|
18
|
-
* Is this pair for large text? Large text allows a smaller contrast ratio.
|
|
19
|
-
*
|
|
20
|
-
* Note: while WCAG has _suggested_ sizes and weights, those are merely
|
|
21
|
-
* suggestions. It’s always more reliable to determine what constitutes “large
|
|
22
|
-
* text” for your designs yourself, based on your typographic stack.
|
|
23
|
-
* @see https://www.w3.org/WAI/WCAG22/quickref/#contrast-minimum
|
|
24
|
-
*/
|
|
25
|
-
largeText?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export declare const WCAG2_MIN_CONTRAST: {
|
|
28
|
-
AA: {
|
|
29
|
-
default: number;
|
|
30
|
-
large: number;
|
|
31
|
-
};
|
|
32
|
-
AAA: {
|
|
33
|
-
default: number;
|
|
34
|
-
large: number;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
export declare const ERROR_INSUFFICIENT_CONTRAST = "INSUFFICIENT_CONTRAST";
|
|
38
|
-
declare const rule: LintRule<typeof ERROR_INSUFFICIENT_CONTRAST, RuleA11yMinContrastOptions>;
|
|
39
|
-
export default rule;
|
|
40
|
-
//# sourceMappingURL=a11y-min-contrast.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"a11y-min-contrast.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/a11y-min-contrast.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,KAAK,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC;IACrB,gEAAgE;IAChE,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;CAG9B,CAAC;AAEF,eAAO,MAAM,2BAA2B,0BAA0B,CAAC;AAEnE,QAAA,MAAM,IAAI,EAAE,QAAQ,CAAC,OAAO,2BAA2B,EAAE,0BAA0B,CAgDlF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { tokenToCulori } from '@terrazzo/token-tools';
|
|
2
|
-
import { wcagContrast } from 'culori';
|
|
3
|
-
import { docsLink } from '../lib/docs.js';
|
|
4
|
-
export const A11Y_MIN_CONTRAST = 'a11y/min-contrast';
|
|
5
|
-
export const WCAG2_MIN_CONTRAST = {
|
|
6
|
-
AA: { default: 4.5, large: 3 },
|
|
7
|
-
AAA: { default: 7, large: 4.5 },
|
|
8
|
-
};
|
|
9
|
-
export const ERROR_INSUFFICIENT_CONTRAST = 'INSUFFICIENT_CONTRAST';
|
|
10
|
-
const rule = {
|
|
11
|
-
meta: {
|
|
12
|
-
messages: {
|
|
13
|
-
[ERROR_INSUFFICIENT_CONTRAST]: 'Pair {{ index }} failed; expected {{ expected }}, got {{ actual }} ({{ level }})',
|
|
14
|
-
},
|
|
15
|
-
docs: {
|
|
16
|
-
description: 'Enforce colors meet minimum contrast checks for WCAG 2.',
|
|
17
|
-
url: docsLink(A11Y_MIN_CONTRAST),
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
defaultOptions: { level: 'AA', pairs: [] },
|
|
21
|
-
create({ tokens, options, report }) {
|
|
22
|
-
for (let i = 0; i < options.pairs.length; i++) {
|
|
23
|
-
const { foreground, background, largeText } = options.pairs[i];
|
|
24
|
-
if (!tokens[foreground]) {
|
|
25
|
-
throw new Error(`Token ${foreground} does not exist`);
|
|
26
|
-
}
|
|
27
|
-
if (tokens[foreground].$type !== 'color') {
|
|
28
|
-
throw new Error(`Token ${foreground} isn’t a color`);
|
|
29
|
-
}
|
|
30
|
-
if (!tokens[background]) {
|
|
31
|
-
throw new Error(`Token ${background} does not exist`);
|
|
32
|
-
}
|
|
33
|
-
if (tokens[background].$type !== 'color') {
|
|
34
|
-
throw new Error(`Token ${background} isn’t a color`);
|
|
35
|
-
}
|
|
36
|
-
// Note: if these culors were unparseable, they would have already thrown an error before the linter
|
|
37
|
-
const a = tokenToCulori(tokens[foreground].$value);
|
|
38
|
-
const b = tokenToCulori(tokens[background].$value);
|
|
39
|
-
// Note: for the purposes of WCAG 2, foreground and background don’t
|
|
40
|
-
// matter. But in other contrast algorithms, they do.
|
|
41
|
-
const contrast = wcagContrast(a, b);
|
|
42
|
-
const min = WCAG2_MIN_CONTRAST[options.level ?? 'AA'][largeText ? 'large' : 'default'];
|
|
43
|
-
if (contrast < min) {
|
|
44
|
-
report({
|
|
45
|
-
messageId: ERROR_INSUFFICIENT_CONTRAST,
|
|
46
|
-
data: {
|
|
47
|
-
index: i + 1,
|
|
48
|
-
expected: min,
|
|
49
|
-
actual: Math.round(contrast * 100) / 100,
|
|
50
|
-
level: options.level,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
export default rule;
|
|
58
|
-
//# sourceMappingURL=a11y-min-contrast.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"a11y-min-contrast.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/a11y-min-contrast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AA4BrD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE;IAC9B,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;CAChC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,uBAAuB,CAAC;AAEnE,MAAM,IAAI,GAA6E;IACrF,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,CAAC,2BAA2B,CAAC,EAAE,kFAAkF;SAClH;QACD,IAAI,EAAE;YACJ,WAAW,EA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CAAC,CAAC,CAAC;YACpC,MAAM,GAAG,GAAG,kBAAkB,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACvF,IAAI,QAAQ,GAAG,GAAG,EAAE,CAAC;gBACnB,MAAM,CAAC;oBACL,SAAS,EAAE,2BAA2B;oBACtC,IAAI,EAAE;wBACJ,KAAK,EAAE,CAAC,GAAG,CAAC;wBACZ,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,GAAG,GAAG;wBACxC,KAAK,EAAE,OAAO,CAAC,KAAK;qBACrB;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { LintRule } from '../../../types.js';
|
|
2
|
-
export declare const A11Y_MIN_FONT_SIZE = "a11y/min-font-size";
|
|
3
|
-
export interface RuleA11yMinFontSizeOptions {
|
|
4
|
-
/** Minimum font size (pixels) */
|
|
5
|
-
minSizePx?: number;
|
|
6
|
-
/** Minimum font size (rems) */
|
|
7
|
-
minSizeRem?: number;
|
|
8
|
-
/** Token IDs to ignore. Accepts globs. */
|
|
9
|
-
ignore?: string[];
|
|
10
|
-
}
|
|
11
|
-
export declare const ERROR_TOO_SMALL = "TOO_SMALL";
|
|
12
|
-
declare const rule: LintRule<typeof ERROR_TOO_SMALL, RuleA11yMinFontSizeOptions>;
|
|
13
|
-
export default rule;
|
|
14
|
-
//# sourceMappingURL=a11y-min-font-size.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"a11y-min-font-size.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/a11y-min-font-size.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,MAAM,WAAW,0BAA0B;IACzC,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,QAAA,MAAM,IAAI,EAAE,QAAQ,CAAC,OAAO,eAAe,EAAE,0BAA0B,CA4CtE,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { isTokenMatch } from '@terrazzo/token-tools';
|
|
2
|
-
import { docsLink } from '../lib/docs.js';
|
|
3
|
-
export const A11Y_MIN_FONT_SIZE = 'a11y/min-font-size';
|
|
4
|
-
export const ERROR_TOO_SMALL = 'TOO_SMALL';
|
|
5
|
-
const rule = {
|
|
6
|
-
meta: {
|
|
7
|
-
messages: {
|
|
8
|
-
[ERROR_TOO_SMALL]: '{{ id }} font size too small. Expected minimum of {{ min }}',
|
|
9
|
-
},
|
|
10
|
-
docs: {
|
|
11
|
-
description: 'Enforce font sizes are no smaller than the given value.',
|
|
12
|
-
url: docsLink(A11Y_MIN_FONT_SIZE),
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
defaultOptions: {},
|
|
16
|
-
create({ tokens, options, report }) {
|
|
17
|
-
if (!options.minSizePx && !options.minSizeRem) {
|
|
18
|
-
throw new Error('Must specify at least one of minSizePx or minSizeRem');
|
|
19
|
-
}
|
|
20
|
-
for (const t of Object.values(tokens)) {
|
|
21
|
-
if (options.ignore && isTokenMatch(t.id, options.ignore)) {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
// skip aliases
|
|
25
|
-
if (t.aliasOf) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (t.$type === 'typography' && 'fontSize' in t.$value) {
|
|
29
|
-
const fontSize = t.$value.fontSize;
|
|
30
|
-
if ((fontSize.unit === 'px' && options.minSizePx && fontSize.value < options.minSizePx) ||
|
|
31
|
-
(fontSize.unit === 'rem' && options.minSizeRem && fontSize.value < options.minSizeRem)) {
|
|
32
|
-
report({
|
|
33
|
-
messageId: ERROR_TOO_SMALL,
|
|
34
|
-
data: {
|
|
35
|
-
id: t.id,
|
|
36
|
-
min: options.minSizePx ? `${options.minSizePx}px` : `${options.minSizeRem}rem`,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
export default rule;
|
|
45
|
-
//# sourceMappingURL=a11y-min-font-size.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"a11y-min-font-size.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/a11y-min-font-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAWvD,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C,MAAM,IAAI,GAAiE;IACzE,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,CAAC,eAAe,CAAC,EAAE,6DAA6D;SACjF;QACD,IAAI,EAAE;YACJ,WAAW,EAAE,yDAAyD;YACtE,GAAG,EAAE,QAAQ,CAAC,kBAAkB,CAAC;SAClC;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;QAChC,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,IAAI,OAAO,CAAC,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzD,SAAS;YACX,CAAC;YAED,eAAe;YACf,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;gBACd,SAAS;YACX,CAAC;YAED,IAAI,CAAC,CAAC,KAAK,KAAK,YAAY,IAAI,UAAU,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBACvD,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,QAAS,CAAC;gBAEpC,IACE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,IAAI,OAAO,CAAC,SAAS,IAAI,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC;oBACnF,CAAC,QAAQ,CAAC,IAAI,KAAK,KAAK,IAAI,OAAO,CAAC,UAAU,IAAI,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,EACtF,CAAC;oBACD,MAAM,CAAC;wBACL,SAAS,EAAE,eAAe;wBAC1B,IAAI,EAAE;4BACJ,EAAE,EAAE,CAAC,CAAC,EAAE;4BACR,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,KAAK;yBAC/E;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ColorValueNormalized } from '@terrazzo/token-tools';
|
|
2
|
-
import type { LintRule } from '../../../types.js';
|
|
3
|
-
export declare const COLORSPACE = "core/colorspace";
|
|
4
|
-
export interface RuleColorspaceOptions {
|
|
5
|
-
colorSpace: ColorValueNormalized['colorSpace'];
|
|
6
|
-
/** (optional) Token IDs to ignore. Supports globs (`*`). */
|
|
7
|
-
ignore?: string[];
|
|
8
|
-
}
|
|
9
|
-
declare const ERROR_COLOR = "COLOR";
|
|
10
|
-
declare const ERROR_BORDER = "BORDER";
|
|
11
|
-
declare const ERROR_GRADIENT = "GRADIENT";
|
|
12
|
-
declare const ERROR_SHADOW = "SHADOW";
|
|
13
|
-
declare const rule: LintRule<typeof ERROR_COLOR | typeof ERROR_BORDER | typeof ERROR_GRADIENT | typeof ERROR_SHADOW, RuleColorspaceOptions>;
|
|
14
|
-
export default rule;
|
|
15
|
-
//# sourceMappingURL=colorspace.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"colorspace.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/colorspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAgB,MAAM,uBAAuB,CAAC;AAChF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAE5C,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAC/C,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,QAAA,MAAM,WAAW,UAAU,CAAC;AAC5B,QAAA,MAAM,YAAY,WAAW,CAAC;AAC9B,QAAA,MAAM,cAAc,aAAa,CAAC;AAClC,QAAA,MAAM,YAAY,WAAW,CAAC;AAE9B,QAAA,MAAM,IAAI,EAAE,QAAQ,CAClB,OAAO,WAAW,GAAG,OAAO,YAAY,GAAG,OAAO,cAAc,GAAG,OAAO,YAAY,EACtF,qBAAqB,CA+EtB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { isTokenMatch } from '@terrazzo/token-tools';
|
|
2
|
-
import { docsLink } from '../lib/docs.js';
|
|
3
|
-
export const COLORSPACE = 'core/colorspace';
|
|
4
|
-
const ERROR_COLOR = 'COLOR';
|
|
5
|
-
const ERROR_BORDER = 'BORDER';
|
|
6
|
-
const ERROR_GRADIENT = 'GRADIENT';
|
|
7
|
-
const ERROR_SHADOW = 'SHADOW';
|
|
8
|
-
const rule = {
|
|
9
|
-
meta: {
|
|
10
|
-
messages: {
|
|
11
|
-
[ERROR_COLOR]: 'Color {{ id }} not in colorspace {{ colorSpace }}',
|
|
12
|
-
[ERROR_BORDER]: 'Border {{ id }} not in colorspace {{ colorSpace }}',
|
|
13
|
-
[ERROR_GRADIENT]: 'Gradient {{ id }} not in colorspace {{ colorSpace }}',
|
|
14
|
-
[ERROR_SHADOW]: 'Shadow {{ id }} not in colorspace {{ colorSpace }}',
|
|
15
|
-
},
|
|
16
|
-
docs: {
|
|
17
|
-
description: 'Enforce that all colors are in a specific colorspace.',
|
|
18
|
-
url: docsLink(COLORSPACE),
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
defaultOptions: { colorSpace: 'srgb' },
|
|
22
|
-
create({ tokens, options, report }) {
|
|
23
|
-
if (!options.colorSpace) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
for (const t of Object.values(tokens)) {
|
|
27
|
-
// skip ignored tokens
|
|
28
|
-
if (options?.ignore && isTokenMatch(t.id, options.ignore)) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
// skip aliases
|
|
32
|
-
if (t.aliasOf) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
switch (t.$type) {
|
|
36
|
-
case 'color': {
|
|
37
|
-
if (t.$value.colorSpace !== options.colorSpace) {
|
|
38
|
-
report({
|
|
39
|
-
messageId: ERROR_COLOR,
|
|
40
|
-
data: { id: t.id, colorSpace: options.colorSpace },
|
|
41
|
-
node: t.source.node,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
case 'border': {
|
|
47
|
-
if (!t.partialAliasOf?.color && t.$value.color.colorSpace !== options.colorSpace) {
|
|
48
|
-
report({
|
|
49
|
-
messageId: ERROR_BORDER,
|
|
50
|
-
data: { id: t.id, colorSpace: options.colorSpace },
|
|
51
|
-
node: t.source.node,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
case 'gradient': {
|
|
57
|
-
for (let stopI = 0; stopI < t.$value.length; stopI++) {
|
|
58
|
-
if (!t.partialAliasOf?.[stopI]?.color && t.$value[stopI].color.colorSpace !== options.colorSpace) {
|
|
59
|
-
report({
|
|
60
|
-
messageId: ERROR_GRADIENT,
|
|
61
|
-
data: { id: t.id, colorSpace: options.colorSpace },
|
|
62
|
-
node: t.source.node,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
case 'shadow': {
|
|
69
|
-
for (let shadowI = 0; shadowI < t.$value.length; shadowI++) {
|
|
70
|
-
if (!t.partialAliasOf?.[shadowI]?.color && t.$value[shadowI].color.colorSpace !== options.colorSpace) {
|
|
71
|
-
report({
|
|
72
|
-
messageId: ERROR_SHADOW,
|
|
73
|
-
data: { id: t.id, colorSpace: options.colorSpace },
|
|
74
|
-
node: t.source.node,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
export default rule;
|
|
85
|
-
//# sourceMappingURL=colorspace.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"colorspace.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/colorspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,YAAY,EAAE,MAAM,uBAAuB,CA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D,KAAK,QAAQ,CAAC,CAAC,CAAC;oBACd,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;wBAC3D,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAE,CAAC,KAAK,CAAC,UAAU,KAAK,OAAO,CAAC,UAAU,EAAE,CAAC;4BACtG,MAAM,CAAC;gCACL,SAAS,EAAE,YAAY;gCACvB,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;gCAClD,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI;6BACpB,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;oBACD,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { LintRule } from '../../../types.js';
|
|
2
|
-
export declare const CONSISTENT_NAMING = "core/consistent-naming";
|
|
3
|
-
export declare const ERROR_WRONG_FORMAT = "ERROR_WRONG_FORMAT";
|
|
4
|
-
export interface RuleConsistentNamingOptions {
|
|
5
|
-
/** Specify format, or custom naming validator */
|
|
6
|
-
format: 'kebab-case' | 'camelCase' | 'PascalCase' | 'snake_case' | 'SCREAMING_SNAKE_CASE' | ((tokenID: string) => boolean);
|
|
7
|
-
/** Token IDs to ignore. Supports globs (`*`). */
|
|
8
|
-
ignore?: string[];
|
|
9
|
-
}
|
|
10
|
-
declare const rule: LintRule<typeof ERROR_WRONG_FORMAT, RuleConsistentNamingOptions>;
|
|
11
|
-
export default rule;
|
|
12
|
-
//# sourceMappingURL=consistent-naming.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consistent-naming.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/consistent-naming.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAC1D,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,MAAM,WAAW,2BAA2B;IAC1C,iDAAiD;IACjD,MAAM,EACF,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,sBAAsB,GACtB,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IACnC,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,QAAA,MAAM,IAAI,EAAE,QAAQ,CAAC,OAAO,kBAAkB,EAAE,2BAA2B,CA0C1E,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { camelCase, kebabCase, pascalCase, snakeCase } from 'scule';
|
|
2
|
-
import { docsLink } from '../lib/docs.js';
|
|
3
|
-
export const CONSISTENT_NAMING = 'core/consistent-naming';
|
|
4
|
-
export const ERROR_WRONG_FORMAT = 'ERROR_WRONG_FORMAT';
|
|
5
|
-
const rule = {
|
|
6
|
-
meta: {
|
|
7
|
-
messages: {
|
|
8
|
-
[ERROR_WRONG_FORMAT]: '{{ id }} doesn’t match format {{ format }}',
|
|
9
|
-
},
|
|
10
|
-
docs: {
|
|
11
|
-
description: 'Enforce consistent naming for tokens.',
|
|
12
|
-
url: docsLink(CONSISTENT_NAMING),
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
defaultOptions: { format: 'kebab-case' },
|
|
16
|
-
create({ tokens, options, report }) {
|
|
17
|
-
const basicFormatter = {
|
|
18
|
-
'kebab-case': kebabCase,
|
|
19
|
-
camelCase,
|
|
20
|
-
PascalCase: pascalCase,
|
|
21
|
-
snake_case: snakeCase,
|
|
22
|
-
SCREAMING_SNAKE_CASE: (name) => snakeCase(name).toLocaleUpperCase(),
|
|
23
|
-
}[String(options.format)];
|
|
24
|
-
for (const t of Object.values(tokens)) {
|
|
25
|
-
if (basicFormatter) {
|
|
26
|
-
const parts = t.id.split('.');
|
|
27
|
-
if (!parts.every((part) => basicFormatter(part) === part)) {
|
|
28
|
-
report({
|
|
29
|
-
messageId: ERROR_WRONG_FORMAT,
|
|
30
|
-
data: { id: t.id, format: options.format },
|
|
31
|
-
node: t.source.node,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else if (typeof options.format === 'function') {
|
|
36
|
-
const result = options.format(t.id);
|
|
37
|
-
if (result) {
|
|
38
|
-
report({
|
|
39
|
-
messageId: ERROR_WRONG_FORMAT,
|
|
40
|
-
data: { id: t.id, format: '(custom)' },
|
|
41
|
-
node: t.source.node,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
export default rule;
|
|
49
|
-
//# sourceMappingURL=consistent-naming.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consistent-naming.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/consistent-naming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AAC1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAevD,MAAM,IAAI,GAAqE;IAC7E,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,CAAC,kBAAkB,CAAC,EAAE,4CAA4C;SACnE;QACD,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;YACpD,GAAG,EAAE,QA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AE,EAAE,MAAM,EAAE,UAAU,EAAE;wBACtC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI;qBACpB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { LintRule } from '../../../types.js';
|
|
2
|
-
export declare const DESCRIPTIONS = "core/descriptions";
|
|
3
|
-
export interface RuleDescriptionsOptions {
|
|
4
|
-
/** Token IDs to ignore. Supports globs (`*`). */
|
|
5
|
-
ignore?: string[];
|
|
6
|
-
}
|
|
7
|
-
declare const ERROR_MISSING_DESCRIPTION = "MISSING_DESCRIPTION";
|
|
8
|
-
declare const rule: LintRule<typeof ERROR_MISSING_DESCRIPTION, RuleDescriptionsOptions>;
|
|
9
|
-
export default rule;
|
|
10
|
-
//# sourceMappingURL=descriptions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptions.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/descriptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,YAAY,sBAAsB,CAAC;AAEhD,MAAM,WAAW,uBAAuB;IACtC,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,QAAA,MAAM,yBAAyB,wBAAwB,CAAC;AAExD,QAAA,MAAM,IAAI,EAAE,QAAQ,CAAC,OAAO,yBAAyB,EAAE,uBAAuB,CAyB7E,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { isTokenMatch } from '@terrazzo/token-tools';
|
|
2
|
-
import { docsLink } from '../lib/docs.js';
|
|
3
|
-
export const DESCRIPTIONS = 'core/descriptions';
|
|
4
|
-
const ERROR_MISSING_DESCRIPTION = 'MISSING_DESCRIPTION';
|
|
5
|
-
const rule = {
|
|
6
|
-
meta: {
|
|
7
|
-
messages: {
|
|
8
|
-
[ERROR_MISSING_DESCRIPTION]: '{{ id }} missing description',
|
|
9
|
-
},
|
|
10
|
-
docs: {
|
|
11
|
-
description: 'Enforce tokens have descriptions.',
|
|
12
|
-
url: docsLink(DESCRIPTIONS),
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
defaultOptions: {},
|
|
16
|
-
create({ tokens, options, report }) {
|
|
17
|
-
for (const t of Object.values(tokens)) {
|
|
18
|
-
if (options.ignore && isTokenMatch(t.id, options.ignore)) {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
if (!t.$description) {
|
|
22
|
-
report({
|
|
23
|
-
messageId: ERROR_MISSING_DESCRIPTION,
|
|
24
|
-
data: { id: t.id },
|
|
25
|
-
node: t.source.node,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
export default rule;
|
|
32
|
-
//# sourceMappingURL=descriptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/descriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAOhD,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AAExD,MAAM,IAAI,GAAwE;IAChF,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,CAAC,yBAAyB,CAAC,EAAE,8BAA8B;SAC5D;QACD,IAAI,EAAE;YACJ,WAAW,EAAE,mCAAmC;YAChD,GAAG,EAAE,QAAQ,CAAC,YAAY,CAAC;SAC5B;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;QAChC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,IAAI,OAAO,CAAC,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzD,SAAS;YACX,CAAC;YACD,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;gBACpB,MAAM,CAAC;oBACL,SAAS,EAAE,yBAAyB;oBACpC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE;oBAClB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI;iBACpB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { LintRule } from '../../../types.js';
|
|
2
|
-
export declare const DUPLICATE_VALUES = "core/duplicate-values";
|
|
3
|
-
export interface RuleDuplicateValueOptions {
|
|
4
|
-
/** Token IDs to ignore. Supports globs (`*`). */
|
|
5
|
-
ignore?: string[];
|
|
6
|
-
}
|
|
7
|
-
declare const ERROR_DUPLICATE_VALUE = "ERROR_DUPLICATE_VALUE";
|
|
8
|
-
declare const rule: LintRule<typeof ERROR_DUPLICATE_VALUE, RuleDuplicateValueOptions>;
|
|
9
|
-
export default rule;
|
|
10
|
-
//# sourceMappingURL=duplicate-values.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate-values.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/duplicate-values.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,gBAAgB,0BAA0B,CAAC;AAExD,MAAM,WAAW,yBAAyB;IACxC,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,QAAA,MAAM,qBAAqB,0BAA0B,CAAC;AAEtD,QAAA,MAAM,IAAI,EAAE,QAAQ,CAAC,OAAO,qBAAqB,EAAE,yBAAyB,CAgE3E,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { isAlias, isTokenMatch } from '@terrazzo/token-tools';
|
|
2
|
-
import { docsLink } from '../lib/docs.js';
|
|
3
|
-
export const DUPLICATE_VALUES = 'core/duplicate-values';
|
|
4
|
-
const ERROR_DUPLICATE_VALUE = 'ERROR_DUPLICATE_VALUE';
|
|
5
|
-
const rule = {
|
|
6
|
-
meta: {
|
|
7
|
-
messages: {
|
|
8
|
-
[ERROR_DUPLICATE_VALUE]: '{{ id }} declared a duplicate value',
|
|
9
|
-
},
|
|
10
|
-
docs: {
|
|
11
|
-
description: 'Enforce tokens can’t redeclare the same value (excludes aliases).',
|
|
12
|
-
url: docsLink(DUPLICATE_VALUES),
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
defaultOptions: {},
|
|
16
|
-
create({ report, tokens, options }) {
|
|
17
|
-
const values = {};
|
|
18
|
-
for (const t of Object.values(tokens)) {
|
|
19
|
-
// skip ignored tokens
|
|
20
|
-
if (options.ignore && isTokenMatch(t.id, options.ignore)) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (!values[t.$type]) {
|
|
24
|
-
values[t.$type] = new Set();
|
|
25
|
-
}
|
|
26
|
-
// primitives: direct comparison is easy
|
|
27
|
-
if (t.$type === 'boolean' ||
|
|
28
|
-
t.$type === 'duration' ||
|
|
29
|
-
t.$type === 'fontWeight' ||
|
|
30
|
-
t.$type === 'link' ||
|
|
31
|
-
t.$type === 'number' ||
|
|
32
|
-
t.$type === 'string') {
|
|
33
|
-
// skip aliases (note: $value will be resolved)
|
|
34
|
-
if (typeof t.aliasOf === 'string' && isAlias(t.aliasOf)) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
if (values[t.$type]?.has(t.$value)) {
|
|
38
|
-
report({
|
|
39
|
-
messageId: ERROR_DUPLICATE_VALUE,
|
|
40
|
-
data: { id: t.id },
|
|
41
|
-
node: t.source.node,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
values[t.$type]?.add(t.$value);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
// everything else: use deepEqual
|
|
48
|
-
for (const v of values[t.$type].values() ?? []) {
|
|
49
|
-
// TODO: don’t JSON.stringify
|
|
50
|
-
if (JSON.stringify(t.$value) === JSON.stringify(v)) {
|
|
51
|
-
report({
|
|
52
|
-
messageId: ERROR_DUPLICATE_VALUE,
|
|
53
|
-
data: { id: t.id },
|
|
54
|
-
node: t.source.node,
|
|
55
|
-
});
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
values[t.$type].add(t.$value);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
export default rule;
|
|
65
|
-
//# sourceMappingURL=duplicate-values.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate-values.js","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/duplicate-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAOxD,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD,MAAM,IAAI,GAAsE;IAC9E,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,CAAC,qBAAqB,CAAC,EAAE,qCAAqC;SAC/D;QACD,IAAI,EAAE;YACJ,WAAW,EAAE,mEAAmE;YAChF,GAAG,EAAE,QAAQ,CAAC,gBAAgB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AAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACN,iCAAiC;gBACjC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;oBAChD,6BAA6B;oBAC7B,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;wBACnD,MAAM,CAAC;4BACL,SAAS,EAAE,qBAAqB;4BAChC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE;4BAClB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI;yBACpB,CAAC,CAAC;wBACH,MAAM;oBACR,CAAC;gBACH,CAAC;gBACD,MAAM,CAAC,CAAC,CAAC,KAAK,CAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { LintRule } from '../../../types.js';
|
|
2
|
-
export declare const MAX_GAMUT = "core/max-gamut";
|
|
3
|
-
export interface RuleMaxGamutOptions {
|
|
4
|
-
/** Gamut to constrain color tokens to. */
|
|
5
|
-
gamut: 'srgb' | 'p3' | 'rec2020';
|
|
6
|
-
/** (optional) Token IDs to ignore. Supports globs (`*`). */
|
|
7
|
-
ignore?: string[];
|
|
8
|
-
}
|
|
9
|
-
declare const ERROR_COLOR = "COLOR";
|
|
10
|
-
declare const ERROR_BORDER = "BORDER";
|
|
11
|
-
declare const ERROR_GRADIENT = "GRADIENT";
|
|
12
|
-
declare const ERROR_SHADOW = "SHADOW";
|
|
13
|
-
declare const rule: LintRule<typeof ERROR_COLOR | typeof ERROR_BORDER | typeof ERROR_GRADIENT | typeof ERROR_SHADOW, RuleMaxGamutOptions>;
|
|
14
|
-
export default rule;
|
|
15
|
-
//# sourceMappingURL=max-gamut.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"max-gamut.d.ts","sourceRoot":"","sources":["../../../../src/lint/plugin-core/rules/max-gamut.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,SAAS,mBAAmB,CAAC;AAE1C,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAiCD,QAAA,MAAM,WAAW,UAAU,CAAC;AAC5B,QAAA,MAAM,YAAY,WAAW,CAAC;AAC9B,QAAA,MAAM,cAAc,aAAa,CAAC;AAClC,QAAA,MAAM,YAAY,WAAW,CAAC;AAE9B,QAAA,MAAM,IAAI,EAAE,QAAQ,CAClB,OAAO,WAAW,GAAG,OAAO,YAAY,GAAG,OAAO,cAAc,GAAG,OAAO,YAAY,EACtF,mBAAmB,CAkEpB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|