@dnncommunity/dnn-elements 0.24.4-beta.14 → 0.24.4-beta.16
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 +17 -2
- package/eslint-plugin/dist/rules/no-label-slot-in-checkbox.js.map +1 -1
- package/eslint-plugin/dist/rules/{no-label-slot-in-checkbox.tests.js → no-label-slot-in-checkbox.test.js} +17 -3
- package/eslint-plugin/dist/rules/no-label-slot-in-checkbox.test.js.map +1 -0
- package/package.json +6 -5
- package/eslint-plugin/dist/rules/no-label-slot-in-checkbox.tests.js.map +0 -1
- /package/eslint-plugin/dist/rules/{no-label-slot-in-checkbox.tests.d.ts → no-label-slot-in-checkbox.test.d.ts} +0 -0
|
@@ -29,9 +29,24 @@ export const rule = createRule({
|
|
|
29
29
|
node,
|
|
30
30
|
messageId: "noLabelSlotInCheckbox",
|
|
31
31
|
fix: fixer => {
|
|
32
|
-
|
|
32
|
+
var _a;
|
|
33
|
+
const sourceCode = context.sourceCode;
|
|
34
|
+
const checkboxText = sourceCode.getText(node.openingElement);
|
|
33
35
|
const selfClosing = checkboxText.replace(/>$/, " />");
|
|
34
|
-
const
|
|
36
|
+
const innerContent = node.children.map(child => sourceCode.getText(child)).join("").trim();
|
|
37
|
+
// Detect leading indentation of the node
|
|
38
|
+
const parent = node.parent;
|
|
39
|
+
const parentLine = parent ? context.sourceCode.getLocFromIndex(parent.range[0]).line : node.loc.start.line;
|
|
40
|
+
const baseLineText = context.sourceCode.lines[parentLine - 1];
|
|
41
|
+
const indentMatch = baseLineText.match(/^(\s*)/);
|
|
42
|
+
const indent = (_a = indentMatch === null || indentMatch === void 0 ? void 0 : indentMatch[1]) !== null && _a !== void 0 ? _a : "";
|
|
43
|
+
// Build replacement with proper indentation
|
|
44
|
+
const replacement = [
|
|
45
|
+
`${indent}<label>`,
|
|
46
|
+
`${indent} ${selfClosing}`,
|
|
47
|
+
`${indent} ${innerContent}`,
|
|
48
|
+
`${indent}</label>`,
|
|
49
|
+
].join("\n");
|
|
35
50
|
return fixer.replaceText(node, replacement);
|
|
36
51
|
}
|
|
37
52
|
});
|
|
@@ -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","s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AG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;gCAE3F,yCAAyC;gCACzC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;gCAC3B,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;gCAC3G,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;gCAC9D,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gCACjD,MAAM,MAAM,GAAG,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,CAAC,CAAC,mCAAI,EAAE,CAAC;gCAEtC,4CAA4C;gCAC5C,MAAM,WAAW,GAAG;oCAChB,GAAG,MAAM,SAAS;oCAClB,GAAG,MAAM,KAAK,WAAW,EAAE;oCAC3B,GAAG,MAAM,KAAK,YAAY,EAAE;oCAC5B,GAAG,MAAM,UAAU;iCACtB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gCAEb,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;4BAChD,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 // Detect leading indentation of the node\r\n const parent = node.parent;\r\n const parentLine = parent ? context.sourceCode.getLocFromIndex(parent.range[0]).line : node.loc.start.line;\r\n const baseLineText = context.sourceCode.lines[parentLine - 1];\r\n const indentMatch = baseLineText.match(/^(\\s*)/);\r\n const indent = indentMatch?.[1] ?? \"\";\r\n\r\n // Build replacement with proper indentation\r\n const replacement = [\r\n `${indent}<label>`,\r\n `${indent} ${selfClosing}`,\r\n `${indent} ${innerContent}`,\r\n `${indent}</label>`,\r\n ].join(\"\\n\");\r\n\r\n return fixer.replaceText(node, replacement);\r\n }\r\n });\r\n }\r\n }\r\n }\r\n };\r\n },\r\n});\r\n"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { RuleTester } from "@typescript-eslint/rule-tester";
|
|
2
|
+
import * as vitest from "vitest";
|
|
2
3
|
import { rule } from "./no-label-slot-in-checkbox.js";
|
|
4
|
+
RuleTester.afterAll = vitest.afterAll;
|
|
5
|
+
RuleTester.it = vitest.it;
|
|
6
|
+
RuleTester.itOnly = vitest.it.only;
|
|
7
|
+
RuleTester.describe = vitest.describe;
|
|
3
8
|
const ruleTester = new RuleTester();
|
|
4
9
|
// Define a reusable configuration for JSX parser options
|
|
5
10
|
const jsxParserOptions = {
|
|
@@ -18,11 +23,20 @@ ruleTester.run("no-label-slot-in-checkbox", rule, {
|
|
|
18
23
|
],
|
|
19
24
|
invalid: [
|
|
20
25
|
{
|
|
21
|
-
code:
|
|
26
|
+
code: [
|
|
27
|
+
"<dnn-checkbox onClick={e => console.log(e)}>",
|
|
28
|
+
" Something",
|
|
29
|
+
"</dnn-checkbox>",
|
|
30
|
+
].join("\n"),
|
|
22
31
|
languageOptions: jsxParserOptions,
|
|
23
32
|
errors: [{ messageId: "noLabelSlotInCheckbox" }],
|
|
24
|
-
output:
|
|
33
|
+
output: [
|
|
34
|
+
"<label>",
|
|
35
|
+
" <dnn-checkbox onClick={e => console.log(e)} />",
|
|
36
|
+
" Something",
|
|
37
|
+
"</label>",
|
|
38
|
+
].join("\n"),
|
|
25
39
|
},
|
|
26
40
|
],
|
|
27
41
|
});
|
|
28
|
-
//# sourceMappingURL=no-label-slot-in-checkbox.
|
|
42
|
+
//# sourceMappingURL=no-label-slot-in-checkbox.test.js.map
|
|
@@ -0,0 +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,EAAE;QACX,YAAY,EAAE;YACV,GAAG,EAAE,IAAI;SACZ;KACJ;CACJ,CAAC;AAEF,UAAU,CAAC,GAAG,CAAC,2BAA2B,EAAE,IAAI,EAAE;IAC9C,KAAK,EAAE;QACH;YACI,IAAI,EAAE,+BAA+B;YACrC,eAAe,EAAE,gBAAgB;SACpC;KACJ;IACD,OAAO,EAAE;QACL;YACI,IAAI,EAAE;gBACF,8CAA8C;gBAC9C,aAAa;gBACb,iBAAiB;aACpB,CAAC,IAAI,CAAC,IAAI,CAAC;YACZ,eAAe,EAAE,gBAAgB;YACjC,MAAM,EAAE,CAAC,EAAE,SAAS,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.16",
|
|
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",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"poststart": "license-checker-rseidelsohn --out licenses.json --json --direct --relativeLicensePath --relativeModulePath",
|
|
33
33
|
"test": "stencil test --spec --e2e",
|
|
34
34
|
"test.watch": "stencil test --spec --e2e --watchAll",
|
|
35
|
-
"test.eslint": "
|
|
36
|
-
"test.eslint.watch": "
|
|
35
|
+
"test.eslint": "vitest run --config ./eslint-plugin/vitest.config.ts",
|
|
36
|
+
"test.eslint.watch": "vitest --config ./eslint-plugin/vitest.config.ts --watch",
|
|
37
37
|
"generate": "stencil generate",
|
|
38
38
|
"eslint": "eslint",
|
|
39
39
|
"storybook": "storybook dev -p 6006",
|
|
@@ -80,8 +80,9 @@
|
|
|
80
80
|
"rollup-plugin-node-polyfills": "^0.2.1",
|
|
81
81
|
"storybook": "^8.3.2",
|
|
82
82
|
"ts-jest": "^29.3.2",
|
|
83
|
-
"typescript": "5.6.3",
|
|
84
|
-
"typescript-eslint": "^8.30.1"
|
|
83
|
+
"typescript": "^5.6.3",
|
|
84
|
+
"typescript-eslint": "^8.30.1",
|
|
85
|
+
"vitest": "^3.1.1"
|
|
85
86
|
},
|
|
86
87
|
"dependencies": {
|
|
87
88
|
"jodit": "^4.2.27"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-label-slot-in-checkbox.tests.js","sourceRoot":"","sources":["../../src/rules/no-label-slot-in-checkbox.tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAEtD,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;AAEpC,yDAAyD;AACzD,MAAM,gBAAgB,GAAG;IACrB,aAAa,EAAE;QACX,YAAY,EAAE;YACV,GAAG,EAAE,IAAI;SACZ;KACJ;CACJ,CAAC;AAEF,UAAU,CAAC,GAAG,CAAC,2BAA2B,EAAE,IAAI,EAAE;IAC9C,KAAK,EAAE;QACH;YACI,IAAI,EAAE,+BAA+B;YACrC,eAAe,EAAE,gBAAgB;SACpC;KACJ;IACD,OAAO,EAAE;QACL;YACI,IAAI,EAAE,sEAAsE;YAC5E,eAAe,EAAE,gBAAgB;YACjC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;YAChD,MAAM,EAAE,8EAA8E;SACzF;KACJ;CACJ,CAAC,CAAC","sourcesContent":["import { RuleTester } from \"@typescript-eslint/rule-tester\";\r\nimport { rule } from \"./no-label-slot-in-checkbox.js\";\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: \"<dnn-checkbox onClick={e => console.log(e)}>Something</dnn-checkbox>\",\r\n languageOptions: jsxParserOptions,\r\n errors: [{ messageId: \"noLabelSlotInCheckbox\" }],\r\n output: \"<label>\\n<dnn-checkbox onClick={e => console.log(e)} />\\nSomething\\n</label>\",\r\n },\r\n ],\r\n});"]}
|
|
File without changes
|