@dnncommunity/dnn-elements 0.24.4-beta.15 → 0.24.4-beta.17
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/eslint-plugin/dist/rules/no-label-slot-in-checkbox.js +7 -15
- package/eslint-plugin/dist/rules/no-label-slot-in-checkbox.js.map +1 -1
- package/eslint-plugin/dist/rules/no-label-slot-in-checkbox.test.js +6 -2
- package/eslint-plugin/dist/rules/no-label-slot-in-checkbox.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -29,24 +29,16 @@ export const rule = createRule({
|
|
|
29
29
|
node,
|
|
30
30
|
messageId: "noLabelSlotInCheckbox",
|
|
31
31
|
fix: fixer => {
|
|
32
|
-
|
|
33
|
-
const sourceCode = context.getSourceCode();
|
|
32
|
+
const sourceCode = context.sourceCode;
|
|
34
33
|
const checkboxText = sourceCode.getText(node.openingElement);
|
|
35
34
|
const selfClosing = checkboxText.replace(/>$/, " />");
|
|
36
35
|
const innerContent = node.children.map(child => sourceCode.getText(child)).join("").trim();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const replacement = [
|
|
44
|
-
`${indent}<label>`,
|
|
45
|
-
`${indent} ${selfClosing}`,
|
|
46
|
-
`${indent} ${innerContent}`,
|
|
47
|
-
`${indent}</label>`,
|
|
48
|
-
].join("\n");
|
|
49
|
-
return fixer.replaceText(node, replacement);
|
|
36
|
+
return [
|
|
37
|
+
fixer.insertTextBefore(node, `<label>\n`),
|
|
38
|
+
fixer.replaceText(node, ` ${selfClosing}\n`),
|
|
39
|
+
fixer.insertTextAfter(node, ` ${innerContent}\n`),
|
|
40
|
+
fixer.insertTextAfter(node, `</label>`),
|
|
41
|
+
];
|
|
50
42
|
}
|
|
51
43
|
});
|
|
52
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-label-slot-in-checkbox.js","sourceRoot":"","sources":["../../src/rules/no-label-slot-in-checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAAC;IAC3B,IAAI,EAAE,2BAA2B;IACjC,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACF,IAAI,EAAE;YACF,WAAW,EAAE,iCAAiC;YAC9C,WAAW,EAAE,IAAI;YACjB,GAAG,EAAE,mEAAmE;SAC3E;QACD,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE;YACN,qBAAqB,EAAE,oFAAoF;SAC9G;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE,EAAE,uFAAuF;KACtG;IACD,MAAM,CAAC,OAAO;QACV,OAAO;YACH,UAAU,CAAC,IAAI;gBACX,IACI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBACjD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,EAClD,CAAC;oBACC,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ;yBAC7B,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;yBAC/C,IAAI,CAAC,EAAE,CAAC;yBACR,IAAI,EAAE,CAAC;oBAEZ,IAAI,YAAY,EAAE,CAAC;wBACf,OAAO,CAAC,MAAM,CAAC;4BACX,IAAI;4BACJ,SAAS,EAAE,uBAAuB;4BAClC,GAAG,EAAE,KAAK,CAAC,EAAE
|
|
1
|
+
{"version":3,"file":"no-label-slot-in-checkbox.js","sourceRoot":"","sources":["../../src/rules/no-label-slot-in-checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAAC;IAC3B,IAAI,EAAE,2BAA2B;IACjC,cAAc,EA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gB,CAAC,IAAI,EAAE,WAAW,CAAC;oCACzC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,WAAW,IAAI,CAAC;oCAC7C,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,YAAY,IAAI,CAAC;oCAClD,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,UAAU,CAAC;iCAC1C,CAAC;4BACN,CAAC;yBACJ,CAAC,CAAC;oBACP,CAAC;gBACL,CAAC;YACL,CAAC;SACJ,CAAC;IACN,CAAC;CACJ,CAAC,CAAC","sourcesContent":["import { createRule } from \"../utils.js\";\r\n\r\nexport const rule = createRule({\r\n name: \"no-label-slot-in-checkbox\",\r\n defaultOptions: [],\r\n meta: {\r\n docs: {\r\n description: \"Disallow label slot in checkbox\",\r\n recommended: true,\r\n url: \"https://github.com/DNNCommunity/dnn-elements/releases/tag/v0.24.0\",\r\n },\r\n type: \"problem\",\r\n messages: {\r\n noLabelSlotInCheckbox: \"Label slot is not allowed in dnn-checkbox, wrap dnn-checkbox with a label instead.\"\r\n },\r\n fixable: \"code\",\r\n schema: [], // Ensure schema is defined as an empty array or with the appropriate schema definition\r\n },\r\n create(context) {\r\n return {\r\n JSXElement(node) {\r\n if (\r\n node.openingElement.name.type === \"JSXIdentifier\" &&\r\n node.openingElement.name.name === \"dnn-checkbox\"\r\n ) {\r\n const innerContent = node.children\r\n .map(child => context.sourceCode.getText(child))\r\n .join(\"\")\r\n .trim();\r\n \r\n if (innerContent) {\r\n context.report({\r\n node,\r\n messageId: \"noLabelSlotInCheckbox\",\r\n fix: fixer => {\r\n const sourceCode = context.sourceCode;\r\n const checkboxText = sourceCode.getText(node.openingElement);\r\n const selfClosing = checkboxText.replace(/>$/, \" />\");\r\n const innerContent = node.children.map(child => sourceCode.getText(child)).join(\"\").trim();\r\n\r\n return [\r\n fixer.insertTextBefore(node, `<label>\\n`),\r\n fixer.replaceText(node, ` ${selfClosing}\\n`),\r\n fixer.insertTextAfter(node, ` ${innerContent}\\n`),\r\n fixer.insertTextAfter(node, `</label>`),\r\n ];\r\n }\r\n });\r\n }\r\n }\r\n }\r\n };\r\n },\r\n});\r\n"]}
|
|
@@ -23,14 +23,18 @@ ruleTester.run("no-label-slot-in-checkbox", rule, {
|
|
|
23
23
|
],
|
|
24
24
|
invalid: [
|
|
25
25
|
{
|
|
26
|
-
code:
|
|
26
|
+
code: [
|
|
27
|
+
"<dnn-checkbox onClick={e => console.log(e)}>",
|
|
28
|
+
" Something",
|
|
29
|
+
"</dnn-checkbox>",
|
|
30
|
+
].join("\n"),
|
|
27
31
|
languageOptions: jsxParserOptions,
|
|
28
32
|
errors: [{ messageId: "noLabelSlotInCheckbox" }],
|
|
29
33
|
output: [
|
|
30
34
|
"<label>",
|
|
31
35
|
" <dnn-checkbox onClick={e => console.log(e)} />",
|
|
32
36
|
" Something",
|
|
33
|
-
"</label>"
|
|
37
|
+
"</label>",
|
|
34
38
|
].join("\n"),
|
|
35
39
|
},
|
|
36
40
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-label-slot-in-checkbox.test.js","sourceRoot":"","sources":["../../src/rules/no-label-slot-in-checkbox.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAEtD,UAAU,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AACtC,UAAU,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;AAC1B,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;AACnC,UAAU,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAEtC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;AAEpC,yDAAyD;AACzD,MAAM,gBAAgB,GAAG;IACrB,aAAa,EAA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AAS,EAAE,uBAAuB,EAAE,CAAC;YAChD,MAAM,EAAE;gBACJ,SAAS;gBACT,kDAAkD;gBAClD,aAAa;gBACb,UAAU;aACb,CAAC,IAAI,CAAC,IAAI,CAAC;SACf;KACJ;CACJ,CAAC,CAAC","sourcesContent":["import { RuleTester } from \"@typescript-eslint/rule-tester\";\r\nimport * as vitest from \"vitest\";\r\nimport { rule } from \"./no-label-slot-in-checkbox.js\";\r\n\r\nRuleTester.afterAll = vitest.afterAll;\r\nRuleTester.it = vitest.it;\r\nRuleTester.itOnly = vitest.it.only;\r\nRuleTester.describe = vitest.describe;\r\n\r\nconst ruleTester = new RuleTester();\r\n\r\n// Define a reusable configuration for JSX parser options\r\nconst jsxParserOptions = {\r\n parserOptions: {\r\n ecmaFeatures: {\r\n jsx: true,\r\n },\r\n },\r\n};\r\n\r\nruleTester.run(\"no-label-slot-in-checkbox\", rule, {\r\n valid: [\r\n {\r\n code: \"<dnn-checkbox></dnn-checkbox>\",\r\n languageOptions: jsxParserOptions,\r\n },\r\n ],\r\n invalid: [\r\n {\r\n code: [\r\n \"<dnn-checkbox onClick={e => console.log(e)}>\",\r\n \" Something\",\r\n \"</dnn-checkbox>\",\r\n ].join(\"\\n\"),\r\n languageOptions: jsxParserOptions,\r\n errors: [{ messageId: \"noLabelSlotInCheckbox\" }],\r\n output: [\r\n \"<label>\",\r\n \" <dnn-checkbox onClick={e => console.log(e)} />\",\r\n \" Something\",\r\n \"</label>\",\r\n ].join(\"\\n\"),\r\n },\r\n ],\r\n});"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnncommunity/dnn-elements",
|
|
3
|
-
"version": "0.24.4-beta.
|
|
3
|
+
"version": "0.24.4-beta.17",
|
|
4
4
|
"description": "Dnn themed custom elements.",
|
|
5
5
|
"repository": "https://github.com/dnncommunity/dnn-elements",
|
|
6
6
|
"homepage": "https://dnncommunity.github.io/dnn-elements",
|