@duro-app/eslint-plugin 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-ds-form-components.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-ds-form-components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAW,MAAM,0BAA0B,CAAA;AAEhE,KAAK,UAAU,GAAG,YAAY,CAAA;AAC9B,KAAK,OAAO,GAAG;IACb;QACE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;KACvB,CAAC;CACH,CAAA;
|
|
1
|
+
{"version":3,"file":"prefer-ds-form-components.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-ds-form-components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAW,MAAM,0BAA0B,CAAA;AAEhE,KAAK,UAAU,GAAG,YAAY,CAAA;AAC9B,KAAK,OAAO,GAAG;IACb;QACE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;KACvB,CAAC;CACH,CAAA;AA2BD,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAuE3E,CAAA"}
|
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
* react-strict-dom spelling — the problem is the altitude, not the element.
|
|
10
10
|
* The design system's own component sources allow these primitives by
|
|
11
11
|
* disabling the rule for that tree; consumers get it from the react preset.
|
|
12
|
+
*
|
|
13
|
+
* Two shapes are exempt because they take no user input, so there is no
|
|
14
|
+
* theme or a11y for the form kit to carry:
|
|
15
|
+
* - `html.input type="hidden"` — the router-form intent idiom
|
|
16
|
+
* (`<fetcher.Form>` carrying intent/id fields).
|
|
17
|
+
* - a `readOnly` input/textarea — a display affordance (e.g. a select-all
|
|
18
|
+
* copy fallback), not a field.
|
|
12
19
|
*/
|
|
13
20
|
const FORM_KIT = {
|
|
14
21
|
input: 'Field.Root + Field.Label + Input (or Checkbox for checkables)',
|
|
@@ -40,6 +47,11 @@ export const preferDsFormComponents = {
|
|
|
40
47
|
const options = context.options[0] ?? {};
|
|
41
48
|
const allow = new Set(options.allow ?? []);
|
|
42
49
|
const htmlObjects = new Set(options.htmlObjects ?? ['html']);
|
|
50
|
+
function attribute(node, attrName) {
|
|
51
|
+
return node.attributes.find((attr) => attr.type === 'JSXAttribute' &&
|
|
52
|
+
attr.name.type === 'JSXIdentifier' &&
|
|
53
|
+
attr.name.name === attrName);
|
|
54
|
+
}
|
|
43
55
|
return {
|
|
44
56
|
JSXOpeningElement(node) {
|
|
45
57
|
const name = node.name;
|
|
@@ -53,6 +65,25 @@ export const preferDsFormComponents = {
|
|
|
53
65
|
const replacement = FORM_KIT[tag];
|
|
54
66
|
if (!replacement)
|
|
55
67
|
return;
|
|
68
|
+
// Hidden inputs carry router-form intent, not user input.
|
|
69
|
+
const type = attribute(node, 'type');
|
|
70
|
+
if (type?.value?.type === 'Literal' &&
|
|
71
|
+
typeof type.value.value === 'string' &&
|
|
72
|
+
type.value.value.toLowerCase() === 'hidden') {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// A readOnly field is a display affordance, not a field. Bare
|
|
76
|
+
// `readOnly` and any non-false value count; only an explicit
|
|
77
|
+
// literal false keeps the report.
|
|
78
|
+
const readOnly = attribute(node, 'readOnly');
|
|
79
|
+
if (readOnly) {
|
|
80
|
+
const v = readOnly.value;
|
|
81
|
+
const literalFalse = v?.type === 'JSXExpressionContainer' &&
|
|
82
|
+
v.expression.type === 'Literal' &&
|
|
83
|
+
v.expression.value === false;
|
|
84
|
+
if (!literalFalse)
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
56
87
|
context.report({ node: name, messageId: 'useFormKit', data: { tag, replacement } });
|
|
57
88
|
},
|
|
58
89
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-ds-form-components.js","sourceRoot":"","sources":["../../src/rules/prefer-ds-form-components.ts"],"names":[],"mappings":"AAUA
|
|
1
|
+
{"version":3,"file":"prefer-ds-form-components.js","sourceRoot":"","sources":["../../src/rules/prefer-ds-form-components.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,QAAQ,GAA2B;IACvC,KAAK,EAAE,+DAA+D;IACtE,MAAM,EAAE,sDAAsD;IAC9D,QAAQ,EAAE,UAAU;CACrB,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAA6C;IAC9E,cAAc,EAAE,CAAC,EAAE,CAAC;IACpB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,+GAA+G;SAClH;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,KAAK,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,WAAW,EAAE,IAAI,EAAC;oBAClE,WAAW,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,WAAW,EAAE,IAAI,EAAC;iBACzE;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE;YACR,UAAU,EACR,mMAAmM;SACtM;KACF;IACD,MAAM,CAAC,OAAO;QACZ,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QACxC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;QAC1C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,CAAC,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AQ,EAAE,CAAC;oBACb,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAA;oBACxB,MAAM,YAAY,GAChB,CAAC,EAAE,IAAI,KAAK,wBAAwB;wBACpC,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS;wBAC/B,CAAC,CAAC,UAAU,CAAC,KAAK,KAAK,KAAK,CAAA;oBAC9B,IAAI,CAAC,YAAY;wBAAE,OAAM;gBAC3B,CAAC;gBACD,OAAO,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,EAAC,GAAG,EAAE,WAAW,EAAC,EAAC,CAAC,CAAA;YACjF,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duro-app/eslint-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "ESLint rules enforcing the Duro design system conventions: react-strict-dom html.* elements, deep token imports, token values over raw px/hex, and no deprecated Table parts.",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@typescript-eslint/utils": "^8.0.0",
|
|
49
49
|
"eslint": "^9.20.0",
|
|
50
50
|
"typescript": "^5.7.0",
|
|
51
|
-
"@duro-app/tokens": "^1.1.
|
|
51
|
+
"@duro-app/tokens": "^1.1.2"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "tsc -p tsconfig.build.json",
|