@db-ux/core-eslint-plugin 0.0.0 → 4.4.2-eslint-plugin-28ea614

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/README.md +754 -0
  3. package/build/index.d.ts +99 -0
  4. package/build/index.js +79 -0
  5. package/build/rules/accordion/no-nested-accordion.d.ts +5 -0
  6. package/build/rules/accordion/no-nested-accordion.js +37 -0
  7. package/build/rules/badge/badge-corner-placement-rules.d.ts +5 -0
  8. package/build/rules/badge/badge-corner-placement-rules.js +76 -0
  9. package/build/rules/badge/badge-no-inline-in-interactive.d.ts +5 -0
  10. package/build/rules/badge/badge-no-inline-in-interactive.js +67 -0
  11. package/build/rules/button/button-no-text-requires-tooltip.d.ts +5 -0
  12. package/build/rules/button/button-no-text-requires-tooltip.js +59 -0
  13. package/build/rules/button/button-single-icon-attribute.d.ts +5 -0
  14. package/build/rules/button/button-single-icon-attribute.js +35 -0
  15. package/build/rules/button/button-type-required.d.ts +5 -0
  16. package/build/rules/button/button-type-required.js +45 -0
  17. package/build/rules/close-button/close-button-text-required.d.ts +5 -0
  18. package/build/rules/close-button/close-button-text-required.js +40 -0
  19. package/build/rules/content/text-or-children-required.d.ts +5 -0
  20. package/build/rules/content/text-or-children-required.js +49 -0
  21. package/build/rules/form/form-label-required.d.ts +5 -0
  22. package/build/rules/form/form-label-required.js +47 -0
  23. package/build/rules/form/form-validation-message-required.d.ts +5 -0
  24. package/build/rules/form/form-validation-message-required.js +93 -0
  25. package/build/rules/header/header-burger-menu-label-required.d.ts +5 -0
  26. package/build/rules/header/header-burger-menu-label-required.js +32 -0
  27. package/build/rules/icon/prefer-icon-attribute.d.ts +5 -0
  28. package/build/rules/icon/prefer-icon-attribute.js +67 -0
  29. package/build/rules/input/input-file-type-validation.d.ts +5 -0
  30. package/build/rules/input/input-file-type-validation.js +52 -0
  31. package/build/rules/input/input-type-required.d.ts +5 -0
  32. package/build/rules/input/input-type-required.js +40 -0
  33. package/build/rules/link/link-external-security.d.ts +5 -0
  34. package/build/rules/link/link-external-security.js +50 -0
  35. package/build/rules/navigation/navigation-item-back-button-text-required.d.ts +5 -0
  36. package/build/rules/navigation/navigation-item-back-button-text-required.js +32 -0
  37. package/build/rules/select/custom-select-tags-remove-text-required.d.ts +5 -0
  38. package/build/rules/select/custom-select-tags-remove-text-required.js +35 -0
  39. package/build/rules/select/select-requires-options.d.ts +5 -0
  40. package/build/rules/select/select-requires-options.js +44 -0
  41. package/build/rules/tag/tag-removable-remove-button-required.d.ts +5 -0
  42. package/build/rules/tag/tag-removable-remove-button-required.js +35 -0
  43. package/build/rules/tooltip/no-interactive-tooltip-content.d.ts +5 -0
  44. package/build/rules/tooltip/no-interactive-tooltip-content.js +47 -0
  45. package/build/rules/tooltip/tooltip-requires-interactive-parent.d.ts +5 -0
  46. package/build/rules/tooltip/tooltip-requires-interactive-parent.js +47 -0
  47. package/build/shared/utils.d.ts +5 -0
  48. package/build/shared/utils.js +61 -0
  49. package/package.json +32 -1
@@ -0,0 +1,47 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ import { INTERACTIVE_ELEMENTS, isDBComponent } from '../../shared/utils.js';
3
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/db-ux-design-system/core-web/blob/main/packages/eslint-plugin/README.md#${name}`);
4
+ function hasInteractiveChild(node) {
5
+ return node.children.some((child) => {
6
+ if (child.type === 'JSXElement') {
7
+ const name = child.openingElement.name;
8
+ if (name.type === 'JSXIdentifier') {
9
+ const tagName = name.name;
10
+ if (INTERACTIVE_ELEMENTS.some((el) => tagName === el ||
11
+ tagName === el.toLowerCase().replace('db', 'db-'))) {
12
+ return true;
13
+ }
14
+ }
15
+ return hasInteractiveChild(child);
16
+ }
17
+ return false;
18
+ });
19
+ }
20
+ export default createRule({
21
+ name: 'no-interactive-tooltip-content',
22
+ meta: {
23
+ type: 'problem',
24
+ docs: {
25
+ description: 'Prevent interactive elements inside DBTooltip'
26
+ },
27
+ messages: {
28
+ noInteractive: 'DBTooltip must not contain interactive elements. Use DBPopover for interactive content'
29
+ },
30
+ schema: []
31
+ },
32
+ defaultOptions: [],
33
+ create(context) {
34
+ return {
35
+ JSXElement(node) {
36
+ if (!isDBComponent(node.openingElement, 'DBTooltip'))
37
+ return;
38
+ if (hasInteractiveChild(node)) {
39
+ context.report({
40
+ node: node.openingElement,
41
+ messageId: 'noInteractive'
42
+ });
43
+ }
44
+ }
45
+ };
46
+ }
47
+ });
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ declare const _default: ESLintUtils.RuleModule<"requiresInteractive", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
5
+ export default _default;
@@ -0,0 +1,47 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ import { INTERACTIVE_ELEMENTS, isDBComponent } from '../../shared/utils.js';
3
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/db-ux-design-system/core-web/blob/main/packages/eslint-plugin/README.md#${name}`);
4
+ function isInteractiveElement(node) {
5
+ const name = node.openingElement.name;
6
+ if (name.type === 'JSXIdentifier') {
7
+ const tagName = name.name;
8
+ return INTERACTIVE_ELEMENTS.some((el) => tagName === el ||
9
+ tagName === el.toLowerCase().replace('db', 'db-'));
10
+ }
11
+ return false;
12
+ }
13
+ export default createRule({
14
+ name: 'tooltip-requires-interactive-parent',
15
+ meta: {
16
+ type: 'problem',
17
+ docs: {
18
+ description: 'Ensure DBTooltip is child of interactive element for accessibility'
19
+ },
20
+ messages: {
21
+ requiresInteractive: 'DBTooltip must be a child of an interactive element (button, link, etc.) for accessibility'
22
+ },
23
+ schema: []
24
+ },
25
+ defaultOptions: [],
26
+ create(context) {
27
+ return {
28
+ JSXElement(node) {
29
+ if (!isDBComponent(node.openingElement, 'DBTooltip'))
30
+ return;
31
+ let parent = node.parent;
32
+ while (parent) {
33
+ if (parent.type === 'JSXElement') {
34
+ if (isInteractiveElement(parent)) {
35
+ return;
36
+ }
37
+ }
38
+ parent = parent.parent;
39
+ }
40
+ context.report({
41
+ node: node.openingElement,
42
+ messageId: 'requiresInteractive'
43
+ });
44
+ }
45
+ };
46
+ }
47
+ });
@@ -0,0 +1,5 @@
1
+ import type { TSESTree } from '@typescript-eslint/utils';
2
+ export declare function getAttributeValue(node: TSESTree.JSXOpeningElement, attrName: string): string | boolean | null;
3
+ export declare function hasChildOfType(node: TSESTree.JSXElement, componentName: string): boolean;
4
+ export declare function isDBComponent(node: TSESTree.JSXOpeningElement, componentName: string): boolean;
5
+ export declare const INTERACTIVE_ELEMENTS: string[];
@@ -0,0 +1,61 @@
1
+ export function getAttributeValue(node, attrName) {
2
+ // Try: noText (React), [noText] (Angular), :noText (Vue)
3
+ const variants = [attrName, `[${attrName}]`, `:${attrName}`];
4
+ const attr = node.attributes.find((a) => a.type === 'JSXAttribute' &&
5
+ variants.includes(a.name.name));
6
+ if (!attr)
7
+ return null;
8
+ if (!attr.value)
9
+ return true;
10
+ if (attr.value.type === 'Literal')
11
+ return attr.value.value;
12
+ if (attr.value.type === 'JSXExpressionContainer')
13
+ return true;
14
+ return null;
15
+ }
16
+ export function hasChildOfType(node, componentName) {
17
+ const kebabName = componentName
18
+ .replace(/([A-Z])/g, '-$1')
19
+ .toLowerCase()
20
+ .replace(/^-/, '');
21
+ return node.children.some((child) => {
22
+ if (child.type === 'JSXElement') {
23
+ const openingElement = child.openingElement;
24
+ if (openingElement.name.type === 'JSXIdentifier') {
25
+ const name = openingElement.name.name;
26
+ return name === componentName || name === kebabName;
27
+ }
28
+ }
29
+ return false;
30
+ });
31
+ }
32
+ export function isDBComponent(node, componentName) {
33
+ if (node.name.type !== 'JSXIdentifier')
34
+ return false;
35
+ const name = node.name.name;
36
+ const kebabName = componentName
37
+ .replace(/([A-Z])/g, '-$1')
38
+ .toLowerCase()
39
+ .replace(/^-/, '');
40
+ return name === componentName || name === kebabName;
41
+ }
42
+ export const INTERACTIVE_ELEMENTS = [
43
+ 'a',
44
+ 'button',
45
+ 'input',
46
+ 'select',
47
+ 'textarea',
48
+ 'details',
49
+ 'summary',
50
+ 'DBButton',
51
+ 'DBLink',
52
+ 'DBInput',
53
+ 'DBSelect',
54
+ 'DBTextarea',
55
+ 'DBCheckbox',
56
+ 'DBRadio',
57
+ 'DBSwitch',
58
+ 'DBNavigationItem',
59
+ 'DBTabItem',
60
+ 'DBTag'
61
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@db-ux/core-eslint-plugin",
3
- "version": "0.0.0",
3
+ "version": "4.4.2-eslint-plugin-28ea614",
4
4
  "type": "module",
5
5
  "description": "ESLint plugin for DB UX Design System components",
6
6
  "repository": {
@@ -8,11 +8,42 @@
8
8
  "url": "git+https://github.com/db-ux-design-system/core-web.git"
9
9
  },
10
10
  "license": "Apache-2.0",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./build/index.d.ts",
14
+ "default": "./build/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "CHANGELOG.md",
19
+ "build"
20
+ ],
11
21
  "keywords": [
12
22
  "eslint",
13
23
  "eslint-plugin",
14
24
  "db-ux"
15
25
  ],
26
+ "scripts": {
27
+ "build": "tsc",
28
+ "copy-output": "npm-run-all copy:*",
29
+ "copy:changelog": "cpr CHANGELOG.md ../../build-outputs/eslint-plugin/CHANGELOG.md --overwrite",
30
+ "copy:outputs": "cpr build ../../build-outputs/eslint-plugin/build -o",
31
+ "copy:package.json": "cpr package.json ../../build-outputs/eslint-plugin/package.json -o",
32
+ "copy:readme": "cpr README.md ../../build-outputs/eslint-plugin/README.md -o",
33
+ "test": "vitest run --config vitest.config.ts"
34
+ },
35
+ "peerDependencies": {
36
+ "eslint": "^9.0.0 || ^10.0.0"
37
+ },
38
+ "dependencies": {
39
+ "@typescript-eslint/utils": "8.54.0"
40
+ },
41
+ "devDependencies": {
42
+ "@typescript-eslint/parser": "8.54.0",
43
+ "@typescript-eslint/rule-tester": "8.54.0",
44
+ "typescript": "5.9.3",
45
+ "vitest": "3.2.4"
46
+ },
16
47
  "publishConfig": {
17
48
  "registry": "https://registry.npmjs.org/",
18
49
  "access": "public"