@atlaskit/eslint-plugin-design-system 8.30.0 → 8.32.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 +12 -0
- package/README.md +1 -1
- package/configs/deprecated.json +0 -5
- package/constellation/consistent-css-prop-usage/usage.mdx +1 -1
- package/constellation/index/usage.mdx +1 -1
- package/constellation/no-css-tagged-template-expression/usage.mdx +1 -1
- package/constellation/no-empty-styled-expression/usage.mdx +1 -1
- package/constellation/no-exported-css/usage.mdx +2 -2
- package/constellation/no-exported-keyframes/usage.mdx +2 -2
- package/constellation/no-html-button-element/usage.mdx +26 -0
- package/constellation/no-keyframes-tagged-template-expression/usage.mdx +1 -3
- package/constellation/no-styled-tagged-template-expression/usage.mdx +2 -4
- package/dist/cjs/presets/all.codegen.js +2 -2
- package/dist/cjs/presets/recommended.codegen.js +1 -2
- package/dist/cjs/rules/index.codegen.js +3 -3
- package/dist/cjs/rules/no-html-button-element/index.js +107 -0
- package/dist/cjs/rules/no-html-button-element/utils.js +18 -0
- package/dist/cjs/rules/prefer-primitives/utils.js +1 -1
- package/dist/configs/deprecated.json +0 -5
- package/dist/es2019/presets/all.codegen.js +2 -2
- package/dist/es2019/presets/recommended.codegen.js +1 -2
- package/dist/es2019/rules/index.codegen.js +3 -3
- package/dist/es2019/rules/no-html-button-element/index.js +101 -0
- package/dist/es2019/rules/no-html-button-element/utils.js +12 -0
- package/dist/es2019/rules/prefer-primitives/utils.js +1 -1
- package/dist/esm/presets/all.codegen.js +2 -2
- package/dist/esm/presets/recommended.codegen.js +1 -2
- package/dist/esm/rules/index.codegen.js +3 -3
- package/dist/esm/rules/no-html-button-element/index.js +101 -0
- package/dist/esm/rules/no-html-button-element/utils.js +12 -0
- package/dist/esm/rules/prefer-primitives/utils.js +1 -1
- package/dist/types/index.codegen.d.ts +1 -2
- package/dist/types/presets/all.codegen.d.ts +2 -2
- package/dist/types/presets/recommended.codegen.d.ts +1 -2
- package/dist/types/rules/index.codegen.d.ts +1 -1
- package/dist/types/rules/{local-cx-xcss → no-html-button-element}/index.d.ts +1 -1
- package/dist/types/rules/no-html-button-element/utils.d.ts +2 -0
- package/dist/types-ts4.5/index.codegen.d.ts +1 -2
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -2
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -2
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -1
- package/dist/types-ts4.5/rules/{local-cx-xcss → no-html-button-element}/index.d.ts +1 -1
- package/dist/types-ts4.5/rules/no-html-button-element/utils.d.ts +2 -0
- package/package.json +1 -1
- package/constellation/local-cx-xcss/usage.mdx +0 -37
- package/dist/cjs/rules/local-cx-xcss/index.js +0 -51
- package/dist/es2019/rules/local-cx-xcss/index.js +0 -45
- package/dist/esm/rules/local-cx-xcss/index.js +0 -45
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
export const validPrimitiveElements = new Set(['div', 'span', 'article', 'aside', 'dialog', 'footer', 'header', 'li', 'main', 'nav', 'ol', 'section', 'ul']);
|
|
2
|
+
export const validPrimitiveElements = new Set(['div', 'span', 'article', 'aside', 'dialog', 'footer', 'header', 'li', 'main', 'nav', 'ol', 'section', 'ul', 'button']);
|
|
3
3
|
const getChildrenByType = (node, types) => {
|
|
4
4
|
return node.children.filter(child => {
|
|
5
5
|
return types.find(type => isNodeOfType(child, type));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::bcb633b9d5c2def00d43b11139433c5c>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -10,7 +10,6 @@ export default {
|
|
|
10
10
|
'@atlaskit/design-system/ensure-design-token-usage': 'error',
|
|
11
11
|
'@atlaskit/design-system/ensure-design-token-usage/preview': 'warn',
|
|
12
12
|
'@atlaskit/design-system/icon-label': 'warn',
|
|
13
|
-
'@atlaskit/design-system/local-cx-xcss': 'error',
|
|
14
13
|
'@atlaskit/design-system/no-banned-imports': 'error',
|
|
15
14
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'error',
|
|
16
15
|
'@atlaskit/design-system/no-deprecated-apis': 'error',
|
|
@@ -19,6 +18,7 @@ export default {
|
|
|
19
18
|
'@atlaskit/design-system/no-empty-styled-expression': 'warn',
|
|
20
19
|
'@atlaskit/design-system/no-exported-css': 'warn',
|
|
21
20
|
'@atlaskit/design-system/no-exported-keyframes': 'warn',
|
|
21
|
+
'@atlaskit/design-system/no-html-button-element': 'warn',
|
|
22
22
|
'@atlaskit/design-system/no-invalid-css-map': 'error',
|
|
23
23
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': 'error',
|
|
24
24
|
'@atlaskit/design-system/no-margin': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::aebc778f0b10032cbb2941b55189d766>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -9,7 +9,6 @@ export default {
|
|
|
9
9
|
'@atlaskit/design-system/consistent-css-prop-usage': 'error',
|
|
10
10
|
'@atlaskit/design-system/ensure-design-token-usage': 'error',
|
|
11
11
|
'@atlaskit/design-system/icon-label': 'warn',
|
|
12
|
-
'@atlaskit/design-system/local-cx-xcss': 'error',
|
|
13
12
|
'@atlaskit/design-system/no-banned-imports': 'error',
|
|
14
13
|
'@atlaskit/design-system/no-deprecated-apis': 'error',
|
|
15
14
|
'@atlaskit/design-system/no-deprecated-design-token-usage': 'warn',
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::23062a8759ba919facf30a402e5546bd>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import consistentCssPropUsage from './consistent-css-prop-usage';
|
|
7
7
|
import ensureDesignTokenUsage from './ensure-design-token-usage';
|
|
8
8
|
import ensureDesignTokenUsagePreview from './ensure-design-token-usage-preview';
|
|
9
9
|
import iconLabel from './icon-label';
|
|
10
|
-
import localCxXcss from './local-cx-xcss';
|
|
11
10
|
import noBannedImports from './no-banned-imports';
|
|
12
11
|
import noCssTaggedTemplateExpression from './no-css-tagged-template-expression';
|
|
13
12
|
import noDeprecatedApis from './no-deprecated-apis';
|
|
@@ -16,6 +15,7 @@ import noDeprecatedImports from './no-deprecated-imports';
|
|
|
16
15
|
import noEmptyStyledExpression from './no-empty-styled-expression';
|
|
17
16
|
import noExportedCss from './no-exported-css';
|
|
18
17
|
import noExportedKeyframes from './no-exported-keyframes';
|
|
18
|
+
import noHtmlButtonElement from './no-html-button-element';
|
|
19
19
|
import noInvalidCssMap from './no-invalid-css-map';
|
|
20
20
|
import noKeyframesTaggedTemplateExpression from './no-keyframes-tagged-template-expression';
|
|
21
21
|
import noMargin from './no-margin';
|
|
@@ -38,7 +38,6 @@ export default {
|
|
|
38
38
|
'ensure-design-token-usage': ensureDesignTokenUsage,
|
|
39
39
|
'ensure-design-token-usage/preview': ensureDesignTokenUsagePreview,
|
|
40
40
|
'icon-label': iconLabel,
|
|
41
|
-
'local-cx-xcss': localCxXcss,
|
|
42
41
|
'no-banned-imports': noBannedImports,
|
|
43
42
|
'no-css-tagged-template-expression': noCssTaggedTemplateExpression,
|
|
44
43
|
'no-deprecated-apis': noDeprecatedApis,
|
|
@@ -47,6 +46,7 @@ export default {
|
|
|
47
46
|
'no-empty-styled-expression': noEmptyStyledExpression,
|
|
48
47
|
'no-exported-css': noExportedCss,
|
|
49
48
|
'no-exported-keyframes': noExportedKeyframes,
|
|
49
|
+
'no-html-button-element': noHtmlButtonElement,
|
|
50
50
|
'no-invalid-css-map': noInvalidCssMap,
|
|
51
51
|
'no-keyframes-tagged-template-expression': noKeyframesTaggedTemplateExpression,
|
|
52
52
|
'no-margin': noMargin,
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
|
|
3
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { createLintRule } from '../utils/create-rule';
|
|
5
|
+
import { shouldSuggest } from './utils';
|
|
6
|
+
var buttonDocsUrl = 'https://atlassian.design/components/button';
|
|
7
|
+
var pressableDocsUrl = 'https://atlassian.design/components/primitives/pressable/';
|
|
8
|
+
var rule = createLintRule({
|
|
9
|
+
meta: {
|
|
10
|
+
name: 'no-html-button-element',
|
|
11
|
+
type: 'suggestion',
|
|
12
|
+
hasSuggestions: false,
|
|
13
|
+
docs: {
|
|
14
|
+
description: 'Prevent direct usage of HTML button elements and enforce usage of Button and Pressable.',
|
|
15
|
+
recommended: false,
|
|
16
|
+
severity: 'warn'
|
|
17
|
+
},
|
|
18
|
+
messages: {
|
|
19
|
+
noHtmlButtonElement: "This \"{{element}}\" should be replaced with a Button component. If beyond the capabilities of the Button component, use the Pressable primitive. See ".concat(buttonDocsUrl, " and ").concat(pressableDocsUrl, " for guidance.")
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
create: function create(context) {
|
|
23
|
+
return {
|
|
24
|
+
// Look for <button> HTML elements
|
|
25
|
+
// Look for styled calls/templates - styled.button(...)
|
|
26
|
+
JSXOpeningElement: function JSXOpeningElement(node) {
|
|
27
|
+
if (!isNodeOfType(node, 'JSXOpeningElement')) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!isNodeOfType(node.name, 'JSXIdentifier')) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
var suggest = shouldSuggest(node === null || node === void 0 ? void 0 : node.parent);
|
|
34
|
+
if (suggest) {
|
|
35
|
+
context.report({
|
|
36
|
+
node: node,
|
|
37
|
+
messageId: 'noHtmlButtonElement',
|
|
38
|
+
data: {
|
|
39
|
+
element: node.name.name
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
// styled.button`` | styled2.button`` | styled.button()
|
|
45
|
+
'MemberExpression[object.name="styled"],MemberExpression[object.name="styled2"]': function MemberExpressionObjectNameStyledMemberExpressionObjectNameStyled2(node) {
|
|
46
|
+
if (!isNodeOfType(node, 'MemberExpression')) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// styled.button``
|
|
51
|
+
if (isNodeOfType(node.property, 'Identifier')) {
|
|
52
|
+
if (node.property.name === 'button') {
|
|
53
|
+
var styledIdentifier = node.object.name;
|
|
54
|
+
var elementName = node.property.name;
|
|
55
|
+
|
|
56
|
+
// Including the `styled.` portion in the message to help makers understand it's not just the `button` element that should be replaced
|
|
57
|
+
var reportName = "".concat(styledIdentifier, ".").concat(elementName); // styled.button
|
|
58
|
+
|
|
59
|
+
context.report({
|
|
60
|
+
node: node,
|
|
61
|
+
messageId: 'noHtmlButtonElement',
|
|
62
|
+
data: {
|
|
63
|
+
element: reportName
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
// styled(X)``
|
|
70
|
+
'CallExpression[callee.name="styled"]': function CallExpressionCalleeNameStyled(node) {
|
|
71
|
+
if (!isNodeOfType(node, 'CallExpression')) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// styled('button')`` - We only care about 'button', ignore extending other components
|
|
76
|
+
if (isNodeOfType(node.arguments[0], 'Literal')) {
|
|
77
|
+
var argValue = node.arguments[0].raw;
|
|
78
|
+
if (typeof argValue === 'string') {
|
|
79
|
+
var suggest = argValue.replaceAll("'", '') === 'button';
|
|
80
|
+
if (suggest) {
|
|
81
|
+
var styledIdentifier = node.callee.name;
|
|
82
|
+
var elementName = argValue;
|
|
83
|
+
|
|
84
|
+
// Including the `styled()` portion in the message to help makers understand it's not just the `button` element that should be replaced
|
|
85
|
+
var reportName = "".concat(styledIdentifier, "(").concat(elementName, ")"); // styled('button')
|
|
86
|
+
|
|
87
|
+
context.report({
|
|
88
|
+
node: node,
|
|
89
|
+
messageId: 'noHtmlButtonElement',
|
|
90
|
+
data: {
|
|
91
|
+
element: reportName
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
export default rule;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var isButtonHtmlElement = function isButtonHtmlElement(node) {
|
|
2
|
+
return node.openingElement.name.name === 'button';
|
|
3
|
+
};
|
|
4
|
+
export var shouldSuggest = function shouldSuggest(node) {
|
|
5
|
+
if (!node) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (!isButtonHtmlElement(node)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
export var validPrimitiveElements = new Set(['div', 'span', 'article', 'aside', 'dialog', 'footer', 'header', 'li', 'main', 'nav', 'ol', 'section', 'ul']);
|
|
2
|
+
export var validPrimitiveElements = new Set(['div', 'span', 'article', 'aside', 'dialog', 'footer', 'header', 'li', 'main', 'nav', 'ol', 'section', 'ul', 'button']);
|
|
3
3
|
var getChildrenByType = function getChildrenByType(node, types) {
|
|
4
4
|
return node.children.filter(function (child) {
|
|
5
5
|
return types.find(function (type) {
|
|
@@ -7,7 +7,6 @@ export declare const configs: {
|
|
|
7
7
|
'@atlaskit/design-system/ensure-design-token-usage': string;
|
|
8
8
|
'@atlaskit/design-system/ensure-design-token-usage/preview': string;
|
|
9
9
|
'@atlaskit/design-system/icon-label': string;
|
|
10
|
-
'@atlaskit/design-system/local-cx-xcss': string;
|
|
11
10
|
'@atlaskit/design-system/no-banned-imports': string;
|
|
12
11
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
13
12
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
@@ -16,6 +15,7 @@ export declare const configs: {
|
|
|
16
15
|
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
17
16
|
'@atlaskit/design-system/no-exported-css': string;
|
|
18
17
|
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
18
|
+
'@atlaskit/design-system/no-html-button-element': string;
|
|
19
19
|
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
20
20
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
21
21
|
'@atlaskit/design-system/no-margin': string;
|
|
@@ -41,7 +41,6 @@ export declare const configs: {
|
|
|
41
41
|
'@atlaskit/design-system/consistent-css-prop-usage': string;
|
|
42
42
|
'@atlaskit/design-system/ensure-design-token-usage': string;
|
|
43
43
|
'@atlaskit/design-system/icon-label': string;
|
|
44
|
-
'@atlaskit/design-system/local-cx-xcss': string;
|
|
45
44
|
'@atlaskit/design-system/no-banned-imports': string;
|
|
46
45
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
47
46
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::bcb633b9d5c2def00d43b11139433c5c>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -10,7 +10,6 @@ declare const _default: {
|
|
|
10
10
|
'@atlaskit/design-system/ensure-design-token-usage': string;
|
|
11
11
|
'@atlaskit/design-system/ensure-design-token-usage/preview': string;
|
|
12
12
|
'@atlaskit/design-system/icon-label': string;
|
|
13
|
-
'@atlaskit/design-system/local-cx-xcss': string;
|
|
14
13
|
'@atlaskit/design-system/no-banned-imports': string;
|
|
15
14
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
16
15
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
@@ -19,6 +18,7 @@ declare const _default: {
|
|
|
19
18
|
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
20
19
|
'@atlaskit/design-system/no-exported-css': string;
|
|
21
20
|
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
21
|
+
'@atlaskit/design-system/no-html-button-element': string;
|
|
22
22
|
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
23
23
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
24
24
|
'@atlaskit/design-system/no-margin': string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::aebc778f0b10032cbb2941b55189d766>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -9,7 +9,6 @@ declare const _default: {
|
|
|
9
9
|
'@atlaskit/design-system/consistent-css-prop-usage': string;
|
|
10
10
|
'@atlaskit/design-system/ensure-design-token-usage': string;
|
|
11
11
|
'@atlaskit/design-system/icon-label': string;
|
|
12
|
-
'@atlaskit/design-system/local-cx-xcss': string;
|
|
13
12
|
'@atlaskit/design-system/no-banned-imports': string;
|
|
14
13
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
15
14
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
@@ -3,7 +3,6 @@ declare const _default: {
|
|
|
3
3
|
'ensure-design-token-usage': import("eslint").Rule.RuleModule;
|
|
4
4
|
'ensure-design-token-usage/preview': import("eslint").Rule.RuleModule;
|
|
5
5
|
'icon-label': import("eslint").Rule.RuleModule;
|
|
6
|
-
'local-cx-xcss': import("eslint").Rule.RuleModule;
|
|
7
6
|
'no-banned-imports': import("eslint").Rule.RuleModule;
|
|
8
7
|
'no-css-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
9
8
|
'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<string, [{
|
|
@@ -16,6 +15,7 @@ declare const _default: {
|
|
|
16
15
|
'no-empty-styled-expression': import("eslint").Rule.RuleModule;
|
|
17
16
|
'no-exported-css': import("eslint").Rule.RuleModule;
|
|
18
17
|
'no-exported-keyframes': import("eslint").Rule.RuleModule;
|
|
18
|
+
'no-html-button-element': import("eslint").Rule.RuleModule;
|
|
19
19
|
'no-invalid-css-map': import("eslint").Rule.RuleModule;
|
|
20
20
|
'no-keyframes-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
21
21
|
'no-margin': import("eslint").Rule.RuleModule;
|
|
@@ -7,7 +7,6 @@ export declare const configs: {
|
|
|
7
7
|
'@atlaskit/design-system/ensure-design-token-usage': string;
|
|
8
8
|
'@atlaskit/design-system/ensure-design-token-usage/preview': string;
|
|
9
9
|
'@atlaskit/design-system/icon-label': string;
|
|
10
|
-
'@atlaskit/design-system/local-cx-xcss': string;
|
|
11
10
|
'@atlaskit/design-system/no-banned-imports': string;
|
|
12
11
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
13
12
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
@@ -16,6 +15,7 @@ export declare const configs: {
|
|
|
16
15
|
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
17
16
|
'@atlaskit/design-system/no-exported-css': string;
|
|
18
17
|
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
18
|
+
'@atlaskit/design-system/no-html-button-element': string;
|
|
19
19
|
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
20
20
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
21
21
|
'@atlaskit/design-system/no-margin': string;
|
|
@@ -41,7 +41,6 @@ export declare const configs: {
|
|
|
41
41
|
'@atlaskit/design-system/consistent-css-prop-usage': string;
|
|
42
42
|
'@atlaskit/design-system/ensure-design-token-usage': string;
|
|
43
43
|
'@atlaskit/design-system/icon-label': string;
|
|
44
|
-
'@atlaskit/design-system/local-cx-xcss': string;
|
|
45
44
|
'@atlaskit/design-system/no-banned-imports': string;
|
|
46
45
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
47
46
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::bcb633b9d5c2def00d43b11139433c5c>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -10,7 +10,6 @@ declare const _default: {
|
|
|
10
10
|
'@atlaskit/design-system/ensure-design-token-usage': string;
|
|
11
11
|
'@atlaskit/design-system/ensure-design-token-usage/preview': string;
|
|
12
12
|
'@atlaskit/design-system/icon-label': string;
|
|
13
|
-
'@atlaskit/design-system/local-cx-xcss': string;
|
|
14
13
|
'@atlaskit/design-system/no-banned-imports': string;
|
|
15
14
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
16
15
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
@@ -19,6 +18,7 @@ declare const _default: {
|
|
|
19
18
|
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
20
19
|
'@atlaskit/design-system/no-exported-css': string;
|
|
21
20
|
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
21
|
+
'@atlaskit/design-system/no-html-button-element': string;
|
|
22
22
|
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
23
23
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
|
|
24
24
|
'@atlaskit/design-system/no-margin': string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::aebc778f0b10032cbb2941b55189d766>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -9,7 +9,6 @@ declare const _default: {
|
|
|
9
9
|
'@atlaskit/design-system/consistent-css-prop-usage': string;
|
|
10
10
|
'@atlaskit/design-system/ensure-design-token-usage': string;
|
|
11
11
|
'@atlaskit/design-system/icon-label': string;
|
|
12
|
-
'@atlaskit/design-system/local-cx-xcss': string;
|
|
13
12
|
'@atlaskit/design-system/no-banned-imports': string;
|
|
14
13
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
15
14
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
@@ -3,7 +3,6 @@ declare const _default: {
|
|
|
3
3
|
'ensure-design-token-usage': import("eslint").Rule.RuleModule;
|
|
4
4
|
'ensure-design-token-usage/preview': import("eslint").Rule.RuleModule;
|
|
5
5
|
'icon-label': import("eslint").Rule.RuleModule;
|
|
6
|
-
'local-cx-xcss': import("eslint").Rule.RuleModule;
|
|
7
6
|
'no-banned-imports': import("eslint").Rule.RuleModule;
|
|
8
7
|
'no-css-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
9
8
|
'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<string, [
|
|
@@ -20,6 +19,7 @@ declare const _default: {
|
|
|
20
19
|
'no-empty-styled-expression': import("eslint").Rule.RuleModule;
|
|
21
20
|
'no-exported-css': import("eslint").Rule.RuleModule;
|
|
22
21
|
'no-exported-keyframes': import("eslint").Rule.RuleModule;
|
|
22
|
+
'no-html-button-element': import("eslint").Rule.RuleModule;
|
|
23
23
|
'no-invalid-css-map': import("eslint").Rule.RuleModule;
|
|
24
24
|
'no-keyframes-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
25
25
|
'no-margin': import("eslint").Rule.RuleModule;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-design-system",
|
|
3
3
|
"description": "The essential plugin for use with the Atlassian Design System.",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.32.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# local-cx-xcss
|
|
2
|
-
|
|
3
|
-
This rule ensures the `cx()` function is only used within the `xcss` prop. This aids tracking what styles are applied to a jsx element.
|
|
4
|
-
|
|
5
|
-
The `cx` function is checked only if it is imported from `@compiled/react` or `@atlaskit/css`.
|
|
6
|
-
|
|
7
|
-
Passing arguments to the `cx()` function is how you compose styles (combine more than one set of styles together) with XCSS. This is a workaround for the more conventional array syntax (e.g. [in Emotion](https://emotion.sh/docs/composition)) `<div xcss={[style1, style2]} />` not giving robust enough type checking.
|
|
8
|
-
|
|
9
|
-
## Examples
|
|
10
|
-
|
|
11
|
-
### Incorrect
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
import { cx, cssMap } from '@compiled/react';
|
|
15
|
-
|
|
16
|
-
const styles = cssMap({
|
|
17
|
-
text: { color: 'red' },
|
|
18
|
-
bg: { background: 'blue' },
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const joinedStyles = cx(styles.text, styles.bg);
|
|
22
|
-
|
|
23
|
-
<Button xcss={joinedStyles} />;
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### Correct
|
|
27
|
-
|
|
28
|
-
```js
|
|
29
|
-
import { cx, cssMap } from '@compiled/react';
|
|
30
|
-
|
|
31
|
-
const styles = cssMap({
|
|
32
|
-
text: { color: 'red' },
|
|
33
|
-
bg: { background: 'blue' },
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
<Button xcss={cx(styles.text, styles.bg)} />;
|
|
37
|
-
```
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.rule = exports.default = void 0;
|
|
7
|
-
var _createRule = require("../utils/create-rule");
|
|
8
|
-
var _isSupportedImport = require("../utils/is-supported-import");
|
|
9
|
-
var IMPORT_SOURCES = [_isSupportedImport.CSS_IN_JS_IMPORTS.compiled, _isSupportedImport.CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
10
|
-
function getParentJSXAttribute(node) {
|
|
11
|
-
var parent = node.parent;
|
|
12
|
-
while (parent && parent.type !== 'JSXAttribute') {
|
|
13
|
-
parent = parent.parent;
|
|
14
|
-
}
|
|
15
|
-
if (parent && parent.type === 'JSXAttribute') {
|
|
16
|
-
return parent;
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
21
|
-
meta: {
|
|
22
|
-
name: 'local-cx-xcss',
|
|
23
|
-
docs: {
|
|
24
|
-
description: 'Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element.',
|
|
25
|
-
recommended: true,
|
|
26
|
-
severity: 'error'
|
|
27
|
-
},
|
|
28
|
-
messages: {
|
|
29
|
-
'local-cx-xcss': 'The cx function should only be declared inside the xcss prop to simplify tracking styles that are applied to a jsx element.'
|
|
30
|
-
},
|
|
31
|
-
type: 'problem'
|
|
32
|
-
},
|
|
33
|
-
create: function create(context) {
|
|
34
|
-
return {
|
|
35
|
-
'CallExpression[callee.name="cx"]': function CallExpressionCalleeNameCx(node) {
|
|
36
|
-
if (node.type === 'CallExpression' && (0, _isSupportedImport.isCxFunction)(node.callee, context.getScope().references, IMPORT_SOURCES)) {
|
|
37
|
-
var parentJSXAttribute = getParentJSXAttribute(node);
|
|
38
|
-
var propName = parentJSXAttribute === null || parentJSXAttribute === void 0 ? void 0 : parentJSXAttribute.name.name.toString();
|
|
39
|
-
if (propName && /[xX]css$/.test(propName)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
context.report({
|
|
43
|
-
node: node,
|
|
44
|
-
messageId: 'local-cx-xcss'
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
var _default = exports.default = rule;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { createLintRule } from '../utils/create-rule';
|
|
2
|
-
import { CSS_IN_JS_IMPORTS, isCxFunction } from '../utils/is-supported-import';
|
|
3
|
-
const IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
4
|
-
function getParentJSXAttribute(node) {
|
|
5
|
-
let parent = node.parent;
|
|
6
|
-
while (parent && parent.type !== 'JSXAttribute') {
|
|
7
|
-
parent = parent.parent;
|
|
8
|
-
}
|
|
9
|
-
if (parent && parent.type === 'JSXAttribute') {
|
|
10
|
-
return parent;
|
|
11
|
-
}
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
export const rule = createLintRule({
|
|
15
|
-
meta: {
|
|
16
|
-
name: 'local-cx-xcss',
|
|
17
|
-
docs: {
|
|
18
|
-
description: 'Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element.',
|
|
19
|
-
recommended: true,
|
|
20
|
-
severity: 'error'
|
|
21
|
-
},
|
|
22
|
-
messages: {
|
|
23
|
-
'local-cx-xcss': 'The cx function should only be declared inside the xcss prop to simplify tracking styles that are applied to a jsx element.'
|
|
24
|
-
},
|
|
25
|
-
type: 'problem'
|
|
26
|
-
},
|
|
27
|
-
create(context) {
|
|
28
|
-
return {
|
|
29
|
-
'CallExpression[callee.name="cx"]': node => {
|
|
30
|
-
if (node.type === 'CallExpression' && isCxFunction(node.callee, context.getScope().references, IMPORT_SOURCES)) {
|
|
31
|
-
const parentJSXAttribute = getParentJSXAttribute(node);
|
|
32
|
-
const propName = parentJSXAttribute === null || parentJSXAttribute === void 0 ? void 0 : parentJSXAttribute.name.name.toString();
|
|
33
|
-
if (propName && /[xX]css$/.test(propName)) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
context.report({
|
|
37
|
-
node,
|
|
38
|
-
messageId: 'local-cx-xcss'
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
export default rule;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { createLintRule } from '../utils/create-rule';
|
|
2
|
-
import { CSS_IN_JS_IMPORTS, isCxFunction } from '../utils/is-supported-import';
|
|
3
|
-
var IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
4
|
-
function getParentJSXAttribute(node) {
|
|
5
|
-
var parent = node.parent;
|
|
6
|
-
while (parent && parent.type !== 'JSXAttribute') {
|
|
7
|
-
parent = parent.parent;
|
|
8
|
-
}
|
|
9
|
-
if (parent && parent.type === 'JSXAttribute') {
|
|
10
|
-
return parent;
|
|
11
|
-
}
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
export var rule = createLintRule({
|
|
15
|
-
meta: {
|
|
16
|
-
name: 'local-cx-xcss',
|
|
17
|
-
docs: {
|
|
18
|
-
description: 'Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element.',
|
|
19
|
-
recommended: true,
|
|
20
|
-
severity: 'error'
|
|
21
|
-
},
|
|
22
|
-
messages: {
|
|
23
|
-
'local-cx-xcss': 'The cx function should only be declared inside the xcss prop to simplify tracking styles that are applied to a jsx element.'
|
|
24
|
-
},
|
|
25
|
-
type: 'problem'
|
|
26
|
-
},
|
|
27
|
-
create: function create(context) {
|
|
28
|
-
return {
|
|
29
|
-
'CallExpression[callee.name="cx"]': function CallExpressionCalleeNameCx(node) {
|
|
30
|
-
if (node.type === 'CallExpression' && isCxFunction(node.callee, context.getScope().references, IMPORT_SOURCES)) {
|
|
31
|
-
var parentJSXAttribute = getParentJSXAttribute(node);
|
|
32
|
-
var propName = parentJSXAttribute === null || parentJSXAttribute === void 0 ? void 0 : parentJSXAttribute.name.name.toString();
|
|
33
|
-
if (propName && /[xX]css$/.test(propName)) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
context.report({
|
|
37
|
-
node: node,
|
|
38
|
-
messageId: 'local-cx-xcss'
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
export default rule;
|