@dnncommunity/dnn-elements 0.24.4-beta.16 → 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.
@@ -29,25 +29,16 @@ export const rule = createRule({
29
29
  node,
30
30
  messageId: "noLabelSlotInCheckbox",
31
31
  fix: fixer => {
32
- var _a;
33
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
- // 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");
50
- 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
+ ];
51
42
  }
52
43
  });
53
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;Y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AAU,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
+ {"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,oFA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e,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnncommunity/dnn-elements",
3
- "version": "0.24.4-beta.16",
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",