@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.
- package/CHANGELOG.md +22 -0
- package/README.md +56 -54
- package/dist/cjs/presets/all-flat.codegen.js +3 -1
- package/dist/cjs/presets/all.codegen.js +3 -1
- package/dist/cjs/presets/recommended-flat.codegen.js +3 -1
- package/dist/cjs/presets/recommended.codegen.js +3 -1
- package/dist/cjs/rules/index.codegen.js +5 -1
- package/dist/cjs/rules/no-html-anchor/node-types/styled-component/index.js +2 -2
- package/dist/cjs/rules/no-html-button/node-types/styled-component/index.js +2 -2
- package/dist/cjs/rules/no-html-image/index.js +40 -0
- package/dist/cjs/rules/no-html-image/node-types/index.js +19 -0
- package/dist/cjs/rules/no-html-image/node-types/jsx-element/index.js +115 -0
- package/dist/cjs/rules/no-html-image/node-types/styled-component/index.js +42 -0
- package/dist/cjs/rules/no-html-image/node-types/supported.js +72 -0
- package/dist/cjs/rules/no-html-range/index.js +34 -0
- package/dist/cjs/rules/no-html-range/node-types/index.js +12 -0
- package/dist/cjs/rules/no-html-range/node-types/jsx-element/index.js +27 -0
- package/dist/cjs/rules/no-html-range/node-types/supported.js +70 -0
- package/dist/cjs/rules/utils/get-styled-component-call.js +1 -1
- package/dist/es2019/presets/all-flat.codegen.js +3 -1
- package/dist/es2019/presets/all.codegen.js +3 -1
- package/dist/es2019/presets/recommended-flat.codegen.js +3 -1
- package/dist/es2019/presets/recommended.codegen.js +3 -1
- package/dist/es2019/rules/index.codegen.js +5 -1
- package/dist/es2019/rules/no-html-anchor/node-types/styled-component/index.js +2 -2
- package/dist/es2019/rules/no-html-button/node-types/styled-component/index.js +2 -2
- package/dist/es2019/rules/no-html-image/index.js +34 -0
- package/dist/es2019/rules/no-html-image/node-types/index.js +2 -0
- package/dist/es2019/rules/no-html-image/node-types/jsx-element/index.js +80 -0
- package/dist/es2019/rules/no-html-image/node-types/styled-component/index.js +37 -0
- package/dist/es2019/rules/no-html-image/node-types/supported.js +62 -0
- package/dist/es2019/rules/no-html-range/index.js +28 -0
- package/dist/es2019/rules/no-html-range/node-types/index.js +1 -0
- package/dist/es2019/rules/no-html-range/node-types/jsx-element/index.js +19 -0
- package/dist/es2019/rules/no-html-range/node-types/supported.js +60 -0
- package/dist/es2019/rules/utils/get-styled-component-call.js +1 -1
- package/dist/esm/presets/all-flat.codegen.js +3 -1
- package/dist/esm/presets/all.codegen.js +3 -1
- package/dist/esm/presets/recommended-flat.codegen.js +3 -1
- package/dist/esm/presets/recommended.codegen.js +3 -1
- package/dist/esm/rules/index.codegen.js +5 -1
- package/dist/esm/rules/no-html-anchor/node-types/styled-component/index.js +2 -2
- package/dist/esm/rules/no-html-button/node-types/styled-component/index.js +2 -2
- package/dist/esm/rules/no-html-image/index.js +34 -0
- package/dist/esm/rules/no-html-image/node-types/index.js +2 -0
- package/dist/esm/rules/no-html-image/node-types/jsx-element/index.js +106 -0
- package/dist/esm/rules/no-html-image/node-types/styled-component/index.js +36 -0
- package/dist/esm/rules/no-html-image/node-types/supported.js +63 -0
- package/dist/esm/rules/no-html-range/index.js +28 -0
- package/dist/esm/rules/no-html-range/node-types/index.js +1 -0
- package/dist/esm/rules/no-html-range/node-types/jsx-element/index.js +18 -0
- package/dist/esm/rules/no-html-range/node-types/supported.js +61 -0
- package/dist/esm/rules/utils/get-styled-component-call.js +1 -1
- package/dist/types/index.codegen.d.ts +18 -0
- package/dist/types/presets/all-flat.codegen.d.ts +2 -0
- package/dist/types/presets/all.codegen.d.ts +2 -0
- package/dist/types/presets/recommended-flat.codegen.d.ts +2 -0
- package/dist/types/presets/recommended.codegen.d.ts +2 -0
- package/dist/types/rules/index.codegen.d.ts +2 -0
- package/dist/types/rules/no-html-image/index.d.ts +3 -0
- package/dist/types/rules/no-html-image/node-types/index.d.ts +2 -0
- package/dist/types/rules/no-html-image/node-types/jsx-element/index.d.ts +8 -0
- package/dist/types/rules/no-html-image/node-types/styled-component/index.d.ts +8 -0
- package/dist/types/rules/no-html-image/node-types/supported.d.ts +7 -0
- package/dist/types/rules/no-html-range/index.d.ts +3 -0
- package/dist/types/rules/no-html-range/node-types/index.d.ts +1 -0
- package/dist/types/rules/no-html-range/node-types/jsx-element/index.d.ts +8 -0
- package/dist/types/rules/no-html-range/node-types/supported.d.ts +7 -0
- package/dist/types-ts4.5/index.codegen.d.ts +18 -0
- package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -0
- package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-html-image/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-html-image/node-types/index.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-html-image/node-types/jsx-element/index.d.ts +8 -0
- package/dist/types-ts4.5/rules/no-html-image/node-types/styled-component/index.d.ts +8 -0
- package/dist/types-ts4.5/rules/no-html-image/node-types/supported.d.ts +7 -0
- package/dist/types-ts4.5/rules/no-html-range/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-html-range/node-types/index.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-html-range/node-types/jsx-element/index.d.ts +8 -0
- package/dist/types-ts4.5/rules/no-html-range/node-types/supported.d.ts +7 -0
- package/package.json +1 -1
- package/dist/cjs/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +0 -47
- package/dist/cjs/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +0 -47
- package/dist/cjs/rules/no-html-button/utils/get-jsx-element-by-name.js +0 -53
- package/dist/es2019/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +0 -42
- package/dist/es2019/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +0 -42
- package/dist/es2019/rules/no-html-button/utils/get-jsx-element-by-name.js +0 -39
- package/dist/esm/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +0 -42
- package/dist/esm/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +0 -42
- package/dist/esm/rules/no-html-button/utils/get-jsx-element-by-name.js +0 -47
- package/dist/types/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.d.ts +0 -6
- package/dist/types/rules/no-html-anchor/utils/get-jsx-element-by-name.d.ts +0 -6
- package/dist/types/rules/no-html-button/node-types/styled-component/get-styled-component-call.d.ts +0 -6
- package/dist/types/rules/no-html-button/utils/get-jsx-element-by-name.d.ts +0 -6
- package/dist/types-ts4.5/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.d.ts +0 -6
- package/dist/types-ts4.5/rules/no-html-button/node-types/styled-component/get-styled-component-call.d.ts +0 -6
- /package/dist/cjs/rules/{no-html-anchor → no-html-image}/utils/get-jsx-element-by-name.js +0 -0
- /package/dist/es2019/rules/{no-html-anchor → no-html-image}/utils/get-jsx-element-by-name.js +0 -0
- /package/dist/esm/rules/{no-html-anchor → no-html-image}/utils/get-jsx-element-by-name.js +0 -0
- /package/dist/{types-ts4.5/rules/no-html-button → types/rules/no-html-image}/utils/get-jsx-element-by-name.d.ts +0 -0
- /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
|
-
};
|
package/dist/esm/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js
DELETED
|
@@ -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
|
-
};
|
package/dist/esm/rules/no-html-button/node-types/styled-component/get-styled-component-call.js
DELETED
|
@@ -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
|
-
};
|
package/dist/types/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.d.ts
DELETED
|
@@ -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;
|
package/dist/types/rules/no-html-button/node-types/styled-component/get-styled-component-call.d.ts
DELETED
|
@@ -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;
|
|
File without changes
|
/package/dist/es2019/rules/{no-html-anchor → no-html-image}/utils/get-jsx-element-by-name.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/types-ts4.5/rules/{no-html-anchor → no-html-image}/utils/get-jsx-element-by-name.d.ts
RENAMED
|
File without changes
|