@greenharness/greenrack-eslint-plugin 0.0.0-stage → 7.0.1
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/LICENSE +21 -0
- package/README.md +195 -2
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/rules/index.d.ts +36 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +23 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/no-deprecated-table-parts.d.ts +17 -0
- package/dist/rules/no-deprecated-table-parts.d.ts.map +1 -0
- package/dist/rules/no-deprecated-table-parts.js +92 -0
- package/dist/rules/no-deprecated-table-parts.js.map +1 -0
- package/dist/rules/no-flex-grow-web.d.ts +22 -0
- package/dist/rules/no-flex-grow-web.d.ts.map +1 -0
- package/dist/rules/no-flex-grow-web.js +38 -0
- package/dist/rules/no-flex-grow-web.js.map +1 -0
- package/dist/rules/no-raw-breakpoint-query.d.ts +16 -0
- package/dist/rules/no-raw-breakpoint-query.d.ts.map +1 -0
- package/dist/rules/no-raw-breakpoint-query.js +78 -0
- package/dist/rules/no-raw-breakpoint-query.js.map +1 -0
- package/dist/rules/no-raw-design-values.d.ts +60 -0
- package/dist/rules/no-raw-design-values.d.ts.map +1 -0
- package/dist/rules/no-raw-design-values.js +657 -0
- package/dist/rules/no-raw-design-values.js.map +1 -0
- package/dist/rules/no-raw-html-element.d.ts +24 -0
- package/dist/rules/no-raw-html-element.d.ts.map +1 -0
- package/dist/rules/no-raw-html-element.js +112 -0
- package/dist/rules/no-raw-html-element.js.map +1 -0
- package/dist/rules/no-raw-layer-values.d.ts +28 -0
- package/dist/rules/no-raw-layer-values.d.ts.map +1 -0
- package/dist/rules/no-raw-layer-values.js +185 -0
- package/dist/rules/no-raw-layer-values.js.map +1 -0
- package/dist/rules/no-tokens-barrel-import.d.ts +17 -0
- package/dist/rules/no-tokens-barrel-import.d.ts.map +1 -0
- package/dist/rules/no-tokens-barrel-import.js +0 -0
- package/dist/rules/no-tokens-barrel-import.js.map +1 -0
- package/dist/rules/prefer-ds-form-components.d.ts +11 -0
- package/dist/rules/prefer-ds-form-components.d.ts.map +1 -0
- package/dist/rules/prefer-ds-form-components.js +92 -0
- package/dist/rules/prefer-ds-form-components.js.map +1 -0
- package/dist/util/glob.d.ts +5 -0
- package/dist/util/glob.d.ts.map +1 -0
- package/dist/util/glob.js +55 -0
- package/dist/util/glob.js.map +1 -0
- package/dist/util/imports.d.ts +20 -0
- package/dist/util/imports.d.ts.map +1 -0
- package/dist/util/imports.js +74 -0
- package/dist/util/imports.js.map +1 -0
- package/dist/util/jsx.d.ts +14 -0
- package/dist/util/jsx.d.ts.map +1 -0
- package/dist/util/jsx.js +121 -0
- package/dist/util/jsx.js.map +1 -0
- package/dist/util/tokens.d.ts +74 -0
- package/dist/util/tokens.d.ts.map +1 -0
- package/dist/util/tokens.js +510 -0
- package/dist/util/tokens.js.map +1 -0
- package/package.json +57 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Translate a glob (`**`, `*`, `?`, `{a,b}`) into an anchored RegExp. */
|
|
2
|
+
export function globToRegExp(glob) {
|
|
3
|
+
let out = '';
|
|
4
|
+
let depth = 0;
|
|
5
|
+
for (let i = 0; i < glob.length; i++) {
|
|
6
|
+
const c = glob[i];
|
|
7
|
+
if (c === '*') {
|
|
8
|
+
if (glob[i + 1] === '*') {
|
|
9
|
+
i++;
|
|
10
|
+
if (glob[i + 1] === '/') {
|
|
11
|
+
i++;
|
|
12
|
+
out += '(?:.*/)?';
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
out += '.*';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
out += '[^/]*';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else if (c === '?') {
|
|
23
|
+
out += '[^/]';
|
|
24
|
+
}
|
|
25
|
+
else if (c === '{') {
|
|
26
|
+
depth++;
|
|
27
|
+
out += '(?:';
|
|
28
|
+
}
|
|
29
|
+
else if (c === '}' && depth > 0) {
|
|
30
|
+
depth--;
|
|
31
|
+
out += ')';
|
|
32
|
+
}
|
|
33
|
+
else if (c === ',' && depth > 0) {
|
|
34
|
+
out += '|';
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
out += c.replace(/[.+^$()|[\]\\{}]/g, '\\$&');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return new RegExp(`^${out}$`);
|
|
41
|
+
}
|
|
42
|
+
const normalize = (path) => path.replace(/\\/g, '/');
|
|
43
|
+
/** Does `filename` match any glob, relative to `cwd` or as an absolute path? */
|
|
44
|
+
export function matchesAnyGlob(filename, cwd, globs) {
|
|
45
|
+
if (globs.length === 0)
|
|
46
|
+
return false;
|
|
47
|
+
const abs = normalize(filename);
|
|
48
|
+
const base = normalize(cwd).replace(/\/+$/, '');
|
|
49
|
+
const rel = abs.startsWith(`${base}/`) ? abs.slice(base.length + 1) : abs;
|
|
50
|
+
return globs.some((glob) => {
|
|
51
|
+
const re = globToRegExp(normalize(glob));
|
|
52
|
+
return re.test(rel) || re.test(abs);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=glob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/util/glob.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAE,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,EAAE,CA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A;IACpC,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;IAC/B,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC/C,MAAM,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACzE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,MAAM,EAAE,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;QACxC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
export interface EnsureImportResult {
|
|
3
|
+
/** The local name the caller should reference (respects aliases). */
|
|
4
|
+
local: string;
|
|
5
|
+
/** Fixes that add the import when it is missing (empty when present). */
|
|
6
|
+
fixes: TSESLint.RuleFix[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Is `name` bound to anything other than an import from `moduleName` in any
|
|
10
|
+
* scope enclosing `scope`? Used to bail out of fixes that would reference a
|
|
11
|
+
* shadowed binding.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isShadowed(scope: TSESLint.Scope.Scope | null, name: string, moduleName: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Ensure a named import for `importedName` from `moduleName` exists, returning
|
|
16
|
+
* the local name to reference plus the fixes that create/extend the import.
|
|
17
|
+
* Reuses an existing (possibly aliased) specifier when present.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ensureNamedImport(sourceCode: Readonly<TSESLint.SourceCode>, fixer: TSESLint.RuleFixer, moduleName: string, importedName: string): EnsureImportResult;
|
|
20
|
+
//# sourceMappingURL=imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../src/util/imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAW,MAAM,0BAA0B,CAAA;AAiBhE,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAA;IACb,yEAAyE;IACzE,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAA;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,EAClC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,OAAO,CAaT;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EACzC,KAAK,EAAE,QAAQ,CAAC,SAAS,EACzB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,kBAAkB,CA6CpB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find how a module import is written in this file so inserted imports match
|
|
3
|
+
* its style (quote char, trailing semicolon). Falls back to the repo default
|
|
4
|
+
* (single quotes, no semicolon) when the file has no imports.
|
|
5
|
+
*/
|
|
6
|
+
function importStyle(sourceCode) {
|
|
7
|
+
const first = sourceCode.ast.body.find((stmt) => stmt.type === 'ImportDeclaration');
|
|
8
|
+
if (!first)
|
|
9
|
+
return { quote: "'", semi: '' };
|
|
10
|
+
const raw = sourceCode.getText(first.source);
|
|
11
|
+
const text = sourceCode.getText(first);
|
|
12
|
+
return { quote: raw.startsWith('"') ? '"' : "'", semi: text.endsWith(';') ? ';' : '' };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Is `name` bound to anything other than an import from `moduleName` in any
|
|
16
|
+
* scope enclosing `scope`? Used to bail out of fixes that would reference a
|
|
17
|
+
* shadowed binding.
|
|
18
|
+
*/
|
|
19
|
+
export function isShadowed(scope, name, moduleName) {
|
|
20
|
+
for (let s = scope; s; s = s.upper) {
|
|
21
|
+
const variable = s.variables.find((v) => v.name === name);
|
|
22
|
+
if (!variable)
|
|
23
|
+
continue;
|
|
24
|
+
const fromModule = variable.defs.every((def) => def.type === 'ImportBinding' &&
|
|
25
|
+
def.parent.type === 'ImportDeclaration' &&
|
|
26
|
+
def.parent.source.value === moduleName);
|
|
27
|
+
if (!fromModule || variable.defs.length === 0)
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Ensure a named import for `importedName` from `moduleName` exists, returning
|
|
34
|
+
* the local name to reference plus the fixes that create/extend the import.
|
|
35
|
+
* Reuses an existing (possibly aliased) specifier when present.
|
|
36
|
+
*/
|
|
37
|
+
export function ensureNamedImport(sourceCode, fixer, moduleName, importedName) {
|
|
38
|
+
const imports = sourceCode.ast.body.filter((stmt) => stmt.type === 'ImportDeclaration');
|
|
39
|
+
const fromModule = imports.filter((decl) => decl.source.value === moduleName && decl.importKind !== 'type');
|
|
40
|
+
for (const decl of fromModule) {
|
|
41
|
+
for (const spec of decl.specifiers) {
|
|
42
|
+
if (spec.type === 'ImportSpecifier' &&
|
|
43
|
+
spec.imported.type === 'Identifier' &&
|
|
44
|
+
spec.imported.name === importedName &&
|
|
45
|
+
spec.importKind !== 'type') {
|
|
46
|
+
return { local: spec.local.name, fixes: [] };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Extend an existing value-import from the module when possible.
|
|
51
|
+
for (const decl of fromModule) {
|
|
52
|
+
const named = decl.specifiers.filter((spec) => spec.type === 'ImportSpecifier');
|
|
53
|
+
const last = named[named.length - 1];
|
|
54
|
+
if (last) {
|
|
55
|
+
return { local: importedName, fixes: [fixer.insertTextAfter(last, `, ${importedName}`)] };
|
|
56
|
+
}
|
|
57
|
+
const defaultSpec = decl.specifiers.find((spec) => spec.type === 'ImportDefaultSpecifier');
|
|
58
|
+
if (defaultSpec) {
|
|
59
|
+
return {
|
|
60
|
+
local: importedName,
|
|
61
|
+
fixes: [fixer.insertTextAfter(defaultSpec, `, {${importedName}}`)],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Add a fresh import declaration.
|
|
66
|
+
const { quote, semi } = importStyle(sourceCode);
|
|
67
|
+
const statement = `import {${importedName}} from ${quote}${moduleName}${quote}${semi}`;
|
|
68
|
+
const lastImport = imports[imports.length - 1];
|
|
69
|
+
if (lastImport) {
|
|
70
|
+
return { local: importedName, fixes: [fixer.insertTextAfter(lastImport, `\n${statement}`)] };
|
|
71
|
+
}
|
|
72
|
+
return { local: importedName, fixes: [fixer.insertTextBeforeRange([0, 0], `${statement}\n`)] };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.js","sourceRoot":"","sources":["../../src/util/imports.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,SAAS,WAAW,CAAC,UAAyC;IAC5D,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CACpC,CAAC,IAAI,EAAsC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAChF,CAAA;IACD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAC,CAAA;IACzC,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5C,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC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L,KAAK,EAAE,YAAY;gBACnB,KAAK,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,YAAY,GAAG,CAAC,CAAC;aACnE,CAAA;QACH,CAAC;IACH,CAAC;IAED,kCAAkC;IAClC,MAAM,EAAC,KAAK,EAAE,IAAI,EAAC,GAAG,WAAW,CAAC,UAAU,CAAC,CAAA;IAC7C,MAAM,SAAS,GAAG,WAAW,YAAY,UAAU,KAAK,GAAG,UAAU,GAAG,KAAK,GAAG,IAAI,EAAE,CAAA;IACtF,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC9C,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,EAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,UAAU,EAAE,KAAK,SAAS,EAAE,CAAC,CAAC,EAAC,CAAA;IAC5F,CAAC;IACD,OAAO,EAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,IAAI,CAAC,CAAC,EAAC,CAAA;AAC9F,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The html.* elements react-strict-dom actually exports (0.0.55). Raw tags in
|
|
3
|
+
* this set can be suggested as `html.<tag>`; raw tags outside it have no RSD
|
|
4
|
+
* equivalent at all.
|
|
5
|
+
*/
|
|
6
|
+
export declare const RSD_HTML_ELEMENTS: Set<string>;
|
|
7
|
+
/**
|
|
8
|
+
* SVG-only tags, skipped regardless of ancestry — icon helpers commonly return
|
|
9
|
+
* a bare <path> without the enclosing <svg> in the same function. Tags that
|
|
10
|
+
* exist in both namespaces (a, title, style, script, text…) are NOT in this
|
|
11
|
+
* set; those are handled by svg-depth tracking instead.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SVG_ONLY_TAGS: Set<string>;
|
|
14
|
+
//# sourceMappingURL=jsx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../../src/util/jsx.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,aAkD5B,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,aAyDxB,CAAA"}
|
package/dist/util/jsx.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The html.* elements react-strict-dom actually exports (0.0.55). Raw tags in
|
|
3
|
+
* this set can be suggested as `html.<tag>`; raw tags outside it have no RSD
|
|
4
|
+
* equivalent at all.
|
|
5
|
+
*/
|
|
6
|
+
export const RSD_HTML_ELEMENTS = new Set([
|
|
7
|
+
'a',
|
|
8
|
+
'article',
|
|
9
|
+
'aside',
|
|
10
|
+
'b',
|
|
11
|
+
'bdi',
|
|
12
|
+
'bdo',
|
|
13
|
+
'blockquote',
|
|
14
|
+
'br',
|
|
15
|
+
'button',
|
|
16
|
+
'code',
|
|
17
|
+
'del',
|
|
18
|
+
'div',
|
|
19
|
+
'em',
|
|
20
|
+
'fieldset',
|
|
21
|
+
'footer',
|
|
22
|
+
'form',
|
|
23
|
+
'h1',
|
|
24
|
+
'h2',
|
|
25
|
+
'h3',
|
|
26
|
+
'h4',
|
|
27
|
+
'h5',
|
|
28
|
+
'h6',
|
|
29
|
+
'header',
|
|
30
|
+
'hr',
|
|
31
|
+
'i',
|
|
32
|
+
'img',
|
|
33
|
+
'input',
|
|
34
|
+
'ins',
|
|
35
|
+
'kbd',
|
|
36
|
+
'label',
|
|
37
|
+
'li',
|
|
38
|
+
'main',
|
|
39
|
+
'mark',
|
|
40
|
+
'nav',
|
|
41
|
+
'ol',
|
|
42
|
+
'optgroup',
|
|
43
|
+
'option',
|
|
44
|
+
'p',
|
|
45
|
+
'pre',
|
|
46
|
+
's',
|
|
47
|
+
'section',
|
|
48
|
+
'select',
|
|
49
|
+
'span',
|
|
50
|
+
'strong',
|
|
51
|
+
'sub',
|
|
52
|
+
'sup',
|
|
53
|
+
'textarea',
|
|
54
|
+
'u',
|
|
55
|
+
'ul',
|
|
56
|
+
]);
|
|
57
|
+
/**
|
|
58
|
+
* SVG-only tags, skipped regardless of ancestry — icon helpers commonly return
|
|
59
|
+
* a bare <path> without the enclosing <svg> in the same function. Tags that
|
|
60
|
+
* exist in both namespaces (a, title, style, script, text…) are NOT in this
|
|
61
|
+
* set; those are handled by svg-depth tracking instead.
|
|
62
|
+
*/
|
|
63
|
+
export const SVG_ONLY_TAGS = new Set([
|
|
64
|
+
'svg',
|
|
65
|
+
'path',
|
|
66
|
+
'circle',
|
|
67
|
+
'ellipse',
|
|
68
|
+
'rect',
|
|
69
|
+
'line',
|
|
70
|
+
'polyline',
|
|
71
|
+
'polygon',
|
|
72
|
+
'g',
|
|
73
|
+
'defs',
|
|
74
|
+
'mask',
|
|
75
|
+
'clipPath',
|
|
76
|
+
'linearGradient',
|
|
77
|
+
'radialGradient',
|
|
78
|
+
'stop',
|
|
79
|
+
'use',
|
|
80
|
+
'symbol',
|
|
81
|
+
'marker',
|
|
82
|
+
'pattern',
|
|
83
|
+
'foreignObject',
|
|
84
|
+
'tspan',
|
|
85
|
+
'textPath',
|
|
86
|
+
'desc',
|
|
87
|
+
'filter',
|
|
88
|
+
'animate',
|
|
89
|
+
'animateMotion',
|
|
90
|
+
'animateTransform',
|
|
91
|
+
'set',
|
|
92
|
+
'view',
|
|
93
|
+
'switch',
|
|
94
|
+
'metadata',
|
|
95
|
+
'feBlend',
|
|
96
|
+
'feColorMatrix',
|
|
97
|
+
'feComponentTransfer',
|
|
98
|
+
'feComposite',
|
|
99
|
+
'feConvolveMatrix',
|
|
100
|
+
'feDiffuseLighting',
|
|
101
|
+
'feDisplacementMap',
|
|
102
|
+
'feDistantLight',
|
|
103
|
+
'feDropShadow',
|
|
104
|
+
'feFlood',
|
|
105
|
+
'feFuncA',
|
|
106
|
+
'feFuncB',
|
|
107
|
+
'feFuncG',
|
|
108
|
+
'feFuncR',
|
|
109
|
+
'feGaussianBlur',
|
|
110
|
+
'feImage',
|
|
111
|
+
'feMerge',
|
|
112
|
+
'feMergeNode',
|
|
113
|
+
'feMorphology',
|
|
114
|
+
'feOffset',
|
|
115
|
+
'fePointLight',
|
|
116
|
+
'feSpecularLighting',
|
|
117
|
+
'feSpotLight',
|
|
118
|
+
'feTile',
|
|
119
|
+
'feTurbulence',
|
|
120
|
+
]);
|
|
121
|
+
//# sourceMappingURL=jsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.js","sourceRoot":"","sources":["../../src/util/jsx.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IACvC,GAAG;IACH,SAAS;IACT,OAAO;IACP,GAAG;IACH,KAAK;IACL,KAAK;IACL,YAAY;IACZ,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,KAAK;IACL,KAAK;IACL,IAAI;IACJ,UAAU;IACV,QAAQ;IACR,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,GAAG;IACH,KAAK;IACL,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,IAAI;IACJ,MAAM;IACN,MAAM;IACN,KAAK;IACL,IAAI;IACJ,UAAU;IACV,QAAQ;IACR,GAAG;IACH,KAAK;IACL,GAAG;IACH,SAAS;IACT,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,KAAK;IACL,KAAK;IACL,UAAU;IACV,GAAG;IACH,IAAI;CACL,CAAC,CAAA;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IACnC,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACT,MAAM;IACN,MAAM;IACN,UAAU;IACV,SAAS;IACT,GAAG;IACH,MAAM;IACN,MAAM;IACN,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,MAAM;IACN,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,eAAe;IACf,OAAO;IACP,UAAU;IACV,MAAM;IACN,QAAQ;IACR,SAAS;IACT,eAAe;IACf,kBAAkB;IAClB,KAAK;IACL,MAAM;IACN,QAAQ;IACR,UAAU;IACV,SAAS;IACT,eAAe;IACf,qBAAqB;IACrB,aAAa;IACb,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,gBAAgB;IAChB,cAAc;IACd,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,SAAS;IACT,SAAS;IACT,aAAa;IACb,cAAc;IACd,UAAU;IACV,cAAc;IACd,oBAAoB;IACpB,aAAa;IACb,QAAQ;IACR,cAAc;CACf,CAAC,CAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Barrel specifier → deep-import path, keyed by the *imported* name. */
|
|
2
|
+
export declare const TOKEN_DEEP_PATHS: Record<string, string>;
|
|
3
|
+
/** px value → spacing token name. */
|
|
4
|
+
export declare const SPACING_TOKENS_BY_PX: Record<number, string>;
|
|
5
|
+
/** px value → micro-spacing token name (off-scale nudges). */
|
|
6
|
+
export declare const MICRO_SPACING_TOKENS_BY_PX: Record<number, string>;
|
|
7
|
+
/** px value → radius token name. */
|
|
8
|
+
export declare const RADII_TOKENS_BY_PX: Record<number, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Color value (lowercased) → semantic color token name. Built from the dark,
|
|
11
|
+
* light, and high-contrast palettes in that order, first entry wins — so a hex
|
|
12
|
+
* shared across tokens/themes suggests the token it most likely stands for
|
|
13
|
+
* (e.g. #6aaffc is both `accent` and `info` in the dark palette → `accent`).
|
|
14
|
+
* `contrastSurface` / `onContrastSurface` are another theme's colours, so they
|
|
15
|
+
* go last (CONTRAST_MIRROR_TOKENS): `#f5f5f5` stays `bgCard`.
|
|
16
|
+
*/
|
|
17
|
+
/** Colour tokens whose values mirror another theme's; listed after the rest. */
|
|
18
|
+
export declare const CONTRAST_MIRROR_TOKENS: string[];
|
|
19
|
+
export declare const COLOR_TOKENS: Record<string, string>;
|
|
20
|
+
/** px value → breakpoint token name (`breakpoints.md` is the '768px' const). */
|
|
21
|
+
export declare const BREAKPOINT_TOKENS_BY_PX: Record<number, string>;
|
|
22
|
+
/**
|
|
23
|
+
* rem value → font-size token. Built from typeScale.fontSize1..9 first, then
|
|
24
|
+
* typography.fontSize* on top — so a size both scales carry suggests the
|
|
25
|
+
* named `typography` token, and only the steps typography lacks (13px, 30px,
|
|
26
|
+
* 36px) fall back to the numbered typeScale one.
|
|
27
|
+
*/
|
|
28
|
+
export declare const FONT_SIZE_TOKENS_BY_REM: Record<number, {
|
|
29
|
+
group: string;
|
|
30
|
+
token: string;
|
|
31
|
+
}>;
|
|
32
|
+
/** numeric weight → typography token. */
|
|
33
|
+
export declare const FONT_WEIGHT_TOKENS: Record<number, string>;
|
|
34
|
+
/** Shadow value (base palette, whitespace-normalized) → shadows token. */
|
|
35
|
+
export declare const SHADOW_TOKENS: Record<string, string>;
|
|
36
|
+
/** ms value → duration token. */
|
|
37
|
+
export declare const DURATION_TOKENS_BY_MS: Record<number, string>;
|
|
38
|
+
/** Easing value (whitespace-normalized) → easing token. */
|
|
39
|
+
export declare const EASING_TOKENS: Record<string, string>;
|
|
40
|
+
/** Collapse whitespace so `rgba(0, 0, 0, .3)` and `rgba(0,0,0,.3)` compare equal. */
|
|
41
|
+
export declare function normalizeValue(value: string): string;
|
|
42
|
+
/** COLOR_TOKENS keyed by normalized value, so rgba() entries are reachable. */
|
|
43
|
+
export declare const COLOR_TOKENS_NORMALIZED: Record<string, string>;
|
|
44
|
+
/** Expand #abc / #abcd to the 6/8-digit form, lowercased. */
|
|
45
|
+
export declare function normalizeHex(hex: string): string;
|
|
46
|
+
/** Style properties whose numeric values map to the spacing scale. */
|
|
47
|
+
export declare const SPACING_PROPERTIES: Set<string>;
|
|
48
|
+
/** Style properties whose numeric values map to the radius scale. */
|
|
49
|
+
export declare const RADII_PROPERTIES: Set<string>;
|
|
50
|
+
/** Style properties whose lengths map to the sizes scale. */
|
|
51
|
+
export declare const SIZE_PROPERTIES: Set<string>;
|
|
52
|
+
/** Longhands holding a border width, an outline width or an outline offset. */
|
|
53
|
+
export declare const BORDER_WIDTH_PROPERTIES: Set<string>;
|
|
54
|
+
/** Shorthands whose string value carries a width (`1px solid red`). */
|
|
55
|
+
export declare const BORDER_SHORTHAND_PROPERTIES: Set<string>;
|
|
56
|
+
/**
|
|
57
|
+
* px value → every sizes token at that value, in key order. A list, because
|
|
58
|
+
* several tokens share a value (44, 28, 40, 18, 8, 36, 16, 24, 96, 160, 200,
|
|
59
|
+
* 240, 280, 320, 480).
|
|
60
|
+
*/
|
|
61
|
+
export declare const SIZE_TOKENS_BY_PX: Record<number, string[]>;
|
|
62
|
+
/** px value → every borders token at that value, in key order. */
|
|
63
|
+
export declare const BORDER_TOKENS_BY_PX: Record<number, string[]>;
|
|
64
|
+
/** Borders tokens a width longhand (or the width in a border shorthand) may use. */
|
|
65
|
+
export declare const BORDER_WIDTH_TOKENS: string[];
|
|
66
|
+
/** Borders tokens `outlineWidth` (or the width in `outline`) may use. */
|
|
67
|
+
export declare const OUTLINE_WIDTH_TOKENS: string[];
|
|
68
|
+
/** Borders tokens `outlineOffset` may use. */
|
|
69
|
+
export declare const OUTLINE_OFFSET_TOKENS: string[];
|
|
70
|
+
/** z-index value → layers token (unitless). */
|
|
71
|
+
export declare const LAYERS_BY_VALUE: Record<number, string>;
|
|
72
|
+
/** Effect value (whitespace-normalized) → effects token. */
|
|
73
|
+
export declare const EFFECTS_BY_VALUE: Record<string, string>;
|
|
74
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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