@atlaskit/eslint-plugin-design-system 13.6.0 → 13.8.0

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 (104) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +56 -54
  3. package/dist/cjs/presets/all-flat.codegen.js +3 -1
  4. package/dist/cjs/presets/all.codegen.js +3 -1
  5. package/dist/cjs/presets/recommended-flat.codegen.js +3 -1
  6. package/dist/cjs/presets/recommended.codegen.js +3 -1
  7. package/dist/cjs/rules/index.codegen.js +5 -1
  8. package/dist/cjs/rules/no-html-anchor/node-types/styled-component/index.js +2 -2
  9. package/dist/cjs/rules/no-html-button/node-types/styled-component/index.js +2 -2
  10. package/dist/cjs/rules/no-html-image/index.js +40 -0
  11. package/dist/cjs/rules/no-html-image/node-types/index.js +19 -0
  12. package/dist/cjs/rules/no-html-image/node-types/jsx-element/index.js +115 -0
  13. package/dist/cjs/rules/no-html-image/node-types/styled-component/index.js +42 -0
  14. package/dist/cjs/rules/no-html-image/node-types/supported.js +72 -0
  15. package/dist/cjs/rules/no-html-range/index.js +34 -0
  16. package/dist/cjs/rules/no-html-range/node-types/index.js +12 -0
  17. package/dist/cjs/rules/no-html-range/node-types/jsx-element/index.js +27 -0
  18. package/dist/cjs/rules/no-html-range/node-types/supported.js +70 -0
  19. package/dist/cjs/rules/utils/get-styled-component-call.js +1 -1
  20. package/dist/es2019/presets/all-flat.codegen.js +3 -1
  21. package/dist/es2019/presets/all.codegen.js +3 -1
  22. package/dist/es2019/presets/recommended-flat.codegen.js +3 -1
  23. package/dist/es2019/presets/recommended.codegen.js +3 -1
  24. package/dist/es2019/rules/index.codegen.js +5 -1
  25. package/dist/es2019/rules/no-html-anchor/node-types/styled-component/index.js +2 -2
  26. package/dist/es2019/rules/no-html-button/node-types/styled-component/index.js +2 -2
  27. package/dist/es2019/rules/no-html-image/index.js +34 -0
  28. package/dist/es2019/rules/no-html-image/node-types/index.js +2 -0
  29. package/dist/es2019/rules/no-html-image/node-types/jsx-element/index.js +80 -0
  30. package/dist/es2019/rules/no-html-image/node-types/styled-component/index.js +37 -0
  31. package/dist/es2019/rules/no-html-image/node-types/supported.js +62 -0
  32. package/dist/es2019/rules/no-html-range/index.js +28 -0
  33. package/dist/es2019/rules/no-html-range/node-types/index.js +1 -0
  34. package/dist/es2019/rules/no-html-range/node-types/jsx-element/index.js +19 -0
  35. package/dist/es2019/rules/no-html-range/node-types/supported.js +60 -0
  36. package/dist/es2019/rules/utils/get-styled-component-call.js +1 -1
  37. package/dist/esm/presets/all-flat.codegen.js +3 -1
  38. package/dist/esm/presets/all.codegen.js +3 -1
  39. package/dist/esm/presets/recommended-flat.codegen.js +3 -1
  40. package/dist/esm/presets/recommended.codegen.js +3 -1
  41. package/dist/esm/rules/index.codegen.js +5 -1
  42. package/dist/esm/rules/no-html-anchor/node-types/styled-component/index.js +2 -2
  43. package/dist/esm/rules/no-html-button/node-types/styled-component/index.js +2 -2
  44. package/dist/esm/rules/no-html-image/index.js +34 -0
  45. package/dist/esm/rules/no-html-image/node-types/index.js +2 -0
  46. package/dist/esm/rules/no-html-image/node-types/jsx-element/index.js +106 -0
  47. package/dist/esm/rules/no-html-image/node-types/styled-component/index.js +36 -0
  48. package/dist/esm/rules/no-html-image/node-types/supported.js +63 -0
  49. package/dist/esm/rules/no-html-range/index.js +28 -0
  50. package/dist/esm/rules/no-html-range/node-types/index.js +1 -0
  51. package/dist/esm/rules/no-html-range/node-types/jsx-element/index.js +18 -0
  52. package/dist/esm/rules/no-html-range/node-types/supported.js +61 -0
  53. package/dist/esm/rules/utils/get-styled-component-call.js +1 -1
  54. package/dist/types/index.codegen.d.ts +18 -0
  55. package/dist/types/presets/all-flat.codegen.d.ts +2 -0
  56. package/dist/types/presets/all.codegen.d.ts +2 -0
  57. package/dist/types/presets/recommended-flat.codegen.d.ts +2 -0
  58. package/dist/types/presets/recommended.codegen.d.ts +2 -0
  59. package/dist/types/rules/index.codegen.d.ts +2 -0
  60. package/dist/types/rules/no-html-image/index.d.ts +3 -0
  61. package/dist/types/rules/no-html-image/node-types/index.d.ts +2 -0
  62. package/dist/types/rules/no-html-image/node-types/jsx-element/index.d.ts +8 -0
  63. package/dist/types/rules/no-html-image/node-types/styled-component/index.d.ts +8 -0
  64. package/dist/types/rules/no-html-image/node-types/supported.d.ts +7 -0
  65. package/dist/types/rules/no-html-range/index.d.ts +3 -0
  66. package/dist/types/rules/no-html-range/node-types/index.d.ts +1 -0
  67. package/dist/types/rules/no-html-range/node-types/jsx-element/index.d.ts +8 -0
  68. package/dist/types/rules/no-html-range/node-types/supported.d.ts +7 -0
  69. package/dist/types-ts4.5/index.codegen.d.ts +18 -0
  70. package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +2 -0
  71. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -0
  72. package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +2 -0
  73. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -0
  74. package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -0
  75. package/dist/types-ts4.5/rules/no-html-image/index.d.ts +3 -0
  76. package/dist/types-ts4.5/rules/no-html-image/node-types/index.d.ts +2 -0
  77. package/dist/types-ts4.5/rules/no-html-image/node-types/jsx-element/index.d.ts +8 -0
  78. package/dist/types-ts4.5/rules/no-html-image/node-types/styled-component/index.d.ts +8 -0
  79. package/dist/types-ts4.5/rules/no-html-image/node-types/supported.d.ts +7 -0
  80. package/dist/types-ts4.5/rules/no-html-range/index.d.ts +3 -0
  81. package/dist/types-ts4.5/rules/no-html-range/node-types/index.d.ts +1 -0
  82. package/dist/types-ts4.5/rules/no-html-range/node-types/jsx-element/index.d.ts +8 -0
  83. package/dist/types-ts4.5/rules/no-html-range/node-types/supported.d.ts +7 -0
  84. package/package.json +1 -1
  85. package/dist/cjs/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +0 -47
  86. package/dist/cjs/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +0 -47
  87. package/dist/cjs/rules/no-html-button/utils/get-jsx-element-by-name.js +0 -53
  88. package/dist/es2019/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +0 -42
  89. package/dist/es2019/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +0 -42
  90. package/dist/es2019/rules/no-html-button/utils/get-jsx-element-by-name.js +0 -39
  91. package/dist/esm/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +0 -42
  92. package/dist/esm/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +0 -42
  93. package/dist/esm/rules/no-html-button/utils/get-jsx-element-by-name.js +0 -47
  94. package/dist/types/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.d.ts +0 -6
  95. package/dist/types/rules/no-html-anchor/utils/get-jsx-element-by-name.d.ts +0 -6
  96. package/dist/types/rules/no-html-button/node-types/styled-component/get-styled-component-call.d.ts +0 -6
  97. package/dist/types/rules/no-html-button/utils/get-jsx-element-by-name.d.ts +0 -6
  98. package/dist/types-ts4.5/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.d.ts +0 -6
  99. package/dist/types-ts4.5/rules/no-html-button/node-types/styled-component/get-styled-component-call.d.ts +0 -6
  100. /package/dist/cjs/rules/{no-html-anchor → no-html-image}/utils/get-jsx-element-by-name.js +0 -0
  101. /package/dist/es2019/rules/{no-html-anchor → no-html-image}/utils/get-jsx-element-by-name.js +0 -0
  102. /package/dist/esm/rules/{no-html-anchor → no-html-image}/utils/get-jsx-element-by-name.js +0 -0
  103. /package/dist/{types-ts4.5/rules/no-html-button → types/rules/no-html-image}/utils/get-jsx-element-by-name.d.ts +0 -0
  104. /package/dist/types-ts4.5/rules/{no-html-anchor → no-html-image}/utils/get-jsx-element-by-name.d.ts +0 -0
@@ -1,39 +0,0 @@
1
- import { isNodeOfType } from 'eslint-codemod-utils';
2
-
3
- /**
4
- * Given a component name finds its JSX usage
5
- */
6
- export const getJsxElementByName = (componentName, scope) => {
7
- var _variableDeclaration$;
8
- const variableDeclaration = scope.variables.find(v => v.name === componentName);
9
- if (!variableDeclaration) {
10
- return;
11
- }
12
-
13
- // length here should be exactly 2 to indicate only two references:
14
- // one being the variable declaration itself
15
- // second being the JSX call site
16
- // we might consider handling multiple local JSX call sites in the future
17
- // but "this is good enough for now"™️
18
- if (variableDeclaration.references.length !== 2) {
19
- return;
20
- }
21
- let jsxUsage = (_variableDeclaration$ = variableDeclaration.references[1]) === null || _variableDeclaration$ === void 0 ? void 0 : _variableDeclaration$.identifier;
22
- const [firstIdentifier, secondIdentifier] = variableDeclaration.references.map(ref => ref === null || ref === void 0 ? void 0 : ref.identifier);
23
- // Check if the first reference is a JSXOpeningElement and the second is not or vice versa
24
- if (isNodeOfType(firstIdentifier, 'JSXIdentifier') && !isNodeOfType(secondIdentifier, 'JSXIdentifier')) {
25
- jsxUsage = firstIdentifier;
26
- } else if (isNodeOfType(secondIdentifier, 'JSXIdentifier') && !isNodeOfType(firstIdentifier, 'JSXIdentifier')) {
27
- jsxUsage = secondIdentifier;
28
- } else {
29
- return;
30
- }
31
- if (!isNodeOfType(jsxUsage, 'JSXIdentifier')) {
32
- return;
33
- }
34
- const jsxOpeningElement = jsxUsage.parent;
35
- if (!isNodeOfType(jsxOpeningElement, 'JSXOpeningElement')) {
36
- return;
37
- }
38
- return jsxOpeningElement;
39
- };
@@ -1,42 +0,0 @@
1
- import { closestOfType, isNodeOfType } from 'eslint-codemod-utils';
2
-
3
- /**
4
- * Returns a styled component
5
- */
6
-
7
- export var getStyledComponentCall = function getStyledComponentCall(node) {
8
- // halts unless we are dealing with a styled component
9
- if (!isStyledCallExpression(node)) {
10
- return;
11
- }
12
- // halts if the component is being exported directly
13
- if (closestOfType(node, 'ExportNamedDeclaration')) {
14
- return;
15
- }
16
- var styledComponentVariableRef = node.parent;
17
- // halts if the styled component is not assigned to a variable immediately
18
- if (!isNodeOfType(styledComponentVariableRef, 'VariableDeclarator')) {
19
- return;
20
- }
21
- return styledComponentVariableRef;
22
- };
23
-
24
- /**
25
- * Some verbose precondition checks but all it does is check
26
- * a call expression is of form `styled.a` or `styled2.a`
27
- */
28
- var isStyledCallExpression = function isStyledCallExpression(call) {
29
- if (!isNodeOfType(call, 'CallExpression')) {
30
- return false;
31
- }
32
- if (!isNodeOfType(call.callee, 'MemberExpression')) {
33
- return false;
34
- }
35
- if (!isNodeOfType(call.callee.object, 'Identifier') || !isNodeOfType(call.callee.property, 'Identifier')) {
36
- return false;
37
- }
38
- if (/^styled2?$/.test(call.callee.object.name)) {
39
- return true;
40
- }
41
- return false;
42
- };
@@ -1,42 +0,0 @@
1
- import { closestOfType, isNodeOfType } from 'eslint-codemod-utils';
2
-
3
- /**
4
- * Returns a styled component
5
- */
6
-
7
- export var getStyledComponentCall = function getStyledComponentCall(node) {
8
- // halts unless we are dealing with a styled component
9
- if (!isStyledCallExpression(node)) {
10
- return;
11
- }
12
- // halts if the component is being exported directly
13
- if (closestOfType(node, 'ExportNamedDeclaration')) {
14
- return;
15
- }
16
- var styledComponentVariableRef = node.parent;
17
- // halts if the styled component is not assigned to a variable immediately
18
- if (!isNodeOfType(styledComponentVariableRef, 'VariableDeclarator')) {
19
- return;
20
- }
21
- return styledComponentVariableRef;
22
- };
23
-
24
- /**
25
- * Some verbose precondition checks but all it does is check
26
- * a call expression is of form `styled.button` or `styled2.button`
27
- */
28
- var isStyledCallExpression = function isStyledCallExpression(call) {
29
- if (!isNodeOfType(call, 'CallExpression')) {
30
- return false;
31
- }
32
- if (!isNodeOfType(call.callee, 'MemberExpression')) {
33
- return false;
34
- }
35
- if (!isNodeOfType(call.callee.object, 'Identifier') || !isNodeOfType(call.callee.property, 'Identifier')) {
36
- return false;
37
- }
38
- if (/^styled2?$/.test(call.callee.object.name)) {
39
- return true;
40
- }
41
- return false;
42
- };
@@ -1,47 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { isNodeOfType } from 'eslint-codemod-utils';
3
-
4
- /**
5
- * Given a component name finds its JSX usage
6
- */
7
- export var getJsxElementByName = function getJsxElementByName(componentName, scope) {
8
- var _variableDeclaration$;
9
- var variableDeclaration = scope.variables.find(function (v) {
10
- return v.name === componentName;
11
- });
12
- if (!variableDeclaration) {
13
- return;
14
- }
15
-
16
- // length here should be exactly 2 to indicate only two references:
17
- // one being the variable declaration itself
18
- // second being the JSX call site
19
- // we might consider handling multiple local JSX call sites in the future
20
- // but "this is good enough for now"™️
21
- if (variableDeclaration.references.length !== 2) {
22
- return;
23
- }
24
- var jsxUsage = (_variableDeclaration$ = variableDeclaration.references[1]) === null || _variableDeclaration$ === void 0 ? void 0 : _variableDeclaration$.identifier;
25
- var _variableDeclaration$2 = variableDeclaration.references.map(function (ref) {
26
- return ref === null || ref === void 0 ? void 0 : ref.identifier;
27
- }),
28
- _variableDeclaration$3 = _slicedToArray(_variableDeclaration$2, 2),
29
- firstIdentifier = _variableDeclaration$3[0],
30
- secondIdentifier = _variableDeclaration$3[1];
31
- // Check if the first reference is a JSXOpeningElement and the second is not or vice versa
32
- if (isNodeOfType(firstIdentifier, 'JSXIdentifier') && !isNodeOfType(secondIdentifier, 'JSXIdentifier')) {
33
- jsxUsage = firstIdentifier;
34
- } else if (isNodeOfType(secondIdentifier, 'JSXIdentifier') && !isNodeOfType(firstIdentifier, 'JSXIdentifier')) {
35
- jsxUsage = secondIdentifier;
36
- } else {
37
- return;
38
- }
39
- if (!isNodeOfType(jsxUsage, 'JSXIdentifier')) {
40
- return;
41
- }
42
- var jsxOpeningElement = jsxUsage.parent;
43
- if (!isNodeOfType(jsxOpeningElement, 'JSXOpeningElement')) {
44
- return;
45
- }
46
- return jsxOpeningElement;
47
- };
@@ -1,6 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- import { type VariableDeclarator } from 'eslint-codemod-utils';
3
- /**
4
- * Returns a styled component
5
- */
6
- export declare const getStyledComponentCall: (node: Rule.Node) => (VariableDeclarator & Rule.NodeParentExtension) | undefined;
@@ -1,6 +0,0 @@
1
- import type { Rule, Scope } from 'eslint';
2
- import { type JSXOpeningElement } from 'eslint-codemod-utils';
3
- /**
4
- * Given a component name finds its JSX usage
5
- */
6
- export declare const getJsxElementByName: (componentName: string, scope: Scope.Scope) => (JSXOpeningElement & Rule.NodeParentExtension) | undefined;
@@ -1,6 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- import { type VariableDeclarator } from 'eslint-codemod-utils';
3
- /**
4
- * Returns a styled component
5
- */
6
- export declare const getStyledComponentCall: (node: Rule.Node) => (VariableDeclarator & Rule.NodeParentExtension) | undefined;
@@ -1,6 +0,0 @@
1
- import type { Rule, Scope } from 'eslint';
2
- import { type JSXOpeningElement } from 'eslint-codemod-utils';
3
- /**
4
- * Given a component name finds its JSX usage
5
- */
6
- export declare const getJsxElementByName: (componentName: string, scope: Scope.Scope) => (JSXOpeningElement & Rule.NodeParentExtension) | undefined;
@@ -1,6 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- import { type VariableDeclarator } from 'eslint-codemod-utils';
3
- /**
4
- * Returns a styled component
5
- */
6
- export declare const getStyledComponentCall: (node: Rule.Node) => (VariableDeclarator & Rule.NodeParentExtension) | undefined;
@@ -1,6 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- import { type VariableDeclarator } from 'eslint-codemod-utils';
3
- /**
4
- * Returns a styled component
5
- */
6
- export declare const getStyledComponentCall: (node: Rule.Node) => (VariableDeclarator & Rule.NodeParentExtension) | undefined;