@atlaskit/eslint-plugin-design-system 11.10.0 → 12.1.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 +21 -0
- package/dist/cjs/ast-nodes/object-entry.js +1 -1
- package/dist/cjs/ast-nodes/root.js +1 -1
- package/dist/cjs/presets/all.codegen.js +1 -1
- package/dist/cjs/presets/recommended.codegen.js +1 -1
- package/dist/cjs/rules/consistent-css-prop-usage/index.js +1 -1
- package/dist/cjs/rules/ensure-design-token-usage/color.js +10 -10
- package/dist/cjs/rules/ensure-design-token-usage/index.js +12 -5
- package/dist/cjs/rules/ensure-design-token-usage/utils.js +3 -3
- package/dist/cjs/rules/no-deprecated-apis/index.js +1 -1
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js +1 -1
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js +1 -1
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.js +1 -1
- package/dist/cjs/rules/no-empty-styled-expression/index.js +1 -1
- package/dist/cjs/rules/no-html-anchor/node-types/jsx-element/index.js +1 -1
- package/dist/cjs/rules/no-html-anchor/node-types/styled-component/index.js +1 -1
- package/dist/cjs/rules/no-html-button/node-types/styled-component/index.js +1 -1
- package/dist/cjs/rules/no-invalid-css-map/index.js +1 -1
- package/dist/cjs/rules/no-invalid-css-map/utils.js +1 -1
- package/dist/cjs/rules/no-legacy-icons/helpers.js +40 -3
- package/dist/cjs/rules/no-margin/index.js +4 -4
- package/dist/cjs/rules/no-nested-styles/index.js +2 -2
- package/dist/cjs/rules/no-physical-properties/index.js +1 -1
- package/dist/cjs/rules/no-unsafe-design-token-usage/index.js +2 -2
- package/dist/cjs/rules/no-unsafe-style-overrides/index.js +1 -1
- package/dist/cjs/rules/use-heading/config/index.js +1 -1
- package/dist/cjs/rules/use-heading/index.js +13 -1
- package/dist/cjs/rules/use-heading-level-in-spotlight-card/index.js +1 -1
- package/dist/cjs/rules/use-href-in-link-item/index.js +1 -1
- package/dist/cjs/rules/use-latest-xcss-syntax/index.js +1 -1
- package/dist/cjs/rules/use-latest-xcss-syntax/transformers/style-property/index.js +1 -1
- package/dist/cjs/rules/use-latest-xcss-syntax-typography/config/index.js +3 -2
- package/dist/cjs/rules/use-latest-xcss-syntax-typography/index.js +24 -6
- package/dist/cjs/rules/use-primitives/config/index.js +41 -1
- package/dist/cjs/rules/use-primitives/index.js +14 -0
- package/dist/cjs/rules/use-primitives/transformers/compiled-styled/index.js +1 -1
- package/dist/cjs/rules/use-primitives/transformers/css-to-xcss.js +1 -1
- package/dist/cjs/rules/use-primitives/transformers/emotion-css/index.js +1 -1
- package/dist/cjs/rules/use-primitives/utils/get-variable-usage-count.js +1 -1
- package/dist/cjs/rules/use-primitives-text/config/index.js +11 -2
- package/dist/cjs/rules/use-primitives-text/index.js +27 -0
- package/dist/cjs/rules/use-primitives-text/transformers/emphasis-elements.js +1 -1
- package/dist/cjs/rules/use-primitives-text/transformers/paragraph-elements.js +1 -1
- package/dist/cjs/rules/use-primitives-text/transformers/span-elements.js +1 -1
- package/dist/cjs/rules/use-primitives-text/transformers/strong-elements.js +1 -1
- package/dist/cjs/rules/use-tokens-space/index.js +5 -5
- package/dist/cjs/rules/use-tokens-typography/config/index.js +1 -1
- package/dist/cjs/rules/use-tokens-typography/index.js +7 -6
- package/dist/cjs/rules/use-tokens-typography/transformers/font-family.js +3 -2
- package/dist/cjs/rules/use-tokens-typography/transformers/font-weight.js +3 -2
- package/dist/cjs/rules/use-tokens-typography/transformers/style-object.js +3 -9
- package/dist/cjs/rules/use-tokens-typography/transformers/untokenized-properties.js +2 -1
- package/dist/cjs/rules/use-visually-hidden/index.js +2 -2
- package/dist/cjs/rules/utils/create-no-exported-rule/check-if-supported-export.js +3 -3
- package/dist/cjs/rules/utils/create-no-exported-rule/main.js +1 -1
- package/dist/cjs/rules/utils/create-no-tagged-template-expression-rule/index.js +1 -1
- package/dist/cjs/rules/utils/get-first-supported-import.js +1 -1
- package/dist/cjs/rules/utils/get-is-exception.js +3 -3
- package/dist/cjs/rules/utils/is-node.js +16 -16
- package/dist/es2019/ast-nodes/object-entry.js +1 -1
- package/dist/es2019/ast-nodes/root.js +1 -1
- package/dist/es2019/presets/all.codegen.js +1 -1
- package/dist/es2019/presets/recommended.codegen.js +1 -1
- package/dist/es2019/rules/consistent-css-prop-usage/index.js +1 -1
- package/dist/es2019/rules/ensure-design-token-usage/color.js +10 -10
- package/dist/es2019/rules/ensure-design-token-usage/index.js +8 -1
- package/dist/es2019/rules/ensure-design-token-usage/utils.js +1 -1
- package/dist/es2019/rules/no-deprecated-apis/index.js +1 -1
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js +1 -1
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js +1 -1
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.js +1 -1
- package/dist/es2019/rules/no-empty-styled-expression/index.js +1 -1
- package/dist/es2019/rules/no-html-anchor/node-types/jsx-element/index.js +1 -1
- package/dist/es2019/rules/no-html-anchor/node-types/styled-component/index.js +1 -1
- package/dist/es2019/rules/no-html-button/node-types/styled-component/index.js +1 -1
- package/dist/es2019/rules/no-invalid-css-map/index.js +1 -1
- package/dist/es2019/rules/no-invalid-css-map/utils.js +1 -1
- package/dist/es2019/rules/no-legacy-icons/helpers.js +38 -3
- package/dist/es2019/rules/no-nested-styles/index.js +1 -1
- package/dist/es2019/rules/no-unsafe-style-overrides/index.js +1 -1
- package/dist/es2019/rules/use-heading/config/index.js +1 -1
- package/dist/es2019/rules/use-heading/index.js +12 -0
- package/dist/es2019/rules/use-heading-level-in-spotlight-card/index.js +1 -1
- package/dist/es2019/rules/use-href-in-link-item/index.js +1 -1
- package/dist/es2019/rules/use-latest-xcss-syntax/transformers/style-property/index.js +1 -1
- package/dist/es2019/rules/use-latest-xcss-syntax-typography/config/index.js +2 -1
- package/dist/es2019/rules/use-latest-xcss-syntax-typography/index.js +19 -1
- package/dist/es2019/rules/use-primitives/config/index.js +40 -0
- package/dist/es2019/rules/use-primitives/index.js +15 -1
- package/dist/es2019/rules/use-primitives/transformers/compiled-styled/index.js +1 -1
- package/dist/es2019/rules/use-primitives/transformers/css-to-xcss.js +1 -1
- package/dist/es2019/rules/use-primitives/transformers/emotion-css/index.js +1 -1
- package/dist/es2019/rules/use-primitives/utils/get-variable-usage-count.js +1 -1
- package/dist/es2019/rules/use-primitives-text/config/index.js +10 -1
- package/dist/es2019/rules/use-primitives-text/index.js +28 -1
- package/dist/es2019/rules/use-primitives-text/transformers/emphasis-elements.js +1 -1
- package/dist/es2019/rules/use-primitives-text/transformers/paragraph-elements.js +1 -1
- package/dist/es2019/rules/use-primitives-text/transformers/span-elements.js +1 -1
- package/dist/es2019/rules/use-primitives-text/transformers/strong-elements.js +1 -1
- package/dist/es2019/rules/use-tokens-typography/config/index.js +1 -1
- package/dist/es2019/rules/use-tokens-typography/index.js +2 -1
- package/dist/es2019/rules/use-tokens-typography/transformers/font-family.js +3 -2
- package/dist/es2019/rules/use-tokens-typography/transformers/font-weight.js +3 -2
- package/dist/es2019/rules/use-tokens-typography/transformers/style-object.js +3 -9
- package/dist/es2019/rules/use-tokens-typography/transformers/untokenized-properties.js +2 -1
- package/dist/es2019/rules/use-visually-hidden/index.js +2 -2
- package/dist/es2019/rules/utils/create-no-exported-rule/check-if-supported-export.js +1 -1
- package/dist/es2019/rules/utils/create-no-exported-rule/main.js +1 -1
- package/dist/es2019/rules/utils/create-no-tagged-template-expression-rule/index.js +1 -1
- package/dist/es2019/rules/utils/get-first-supported-import.js +1 -1
- package/dist/es2019/rules/utils/is-node.js +1 -1
- package/dist/esm/ast-nodes/object-entry.js +1 -1
- package/dist/esm/ast-nodes/root.js +1 -1
- package/dist/esm/presets/all.codegen.js +1 -1
- package/dist/esm/presets/recommended.codegen.js +1 -1
- package/dist/esm/rules/consistent-css-prop-usage/index.js +1 -1
- package/dist/esm/rules/ensure-design-token-usage/color.js +10 -10
- package/dist/esm/rules/ensure-design-token-usage/index.js +12 -5
- package/dist/esm/rules/ensure-design-token-usage/utils.js +4 -3
- package/dist/esm/rules/no-deprecated-apis/index.js +1 -1
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js +1 -1
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js +1 -1
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.js +1 -1
- package/dist/esm/rules/no-empty-styled-expression/index.js +1 -1
- package/dist/esm/rules/no-html-anchor/node-types/jsx-element/index.js +1 -1
- package/dist/esm/rules/no-html-anchor/node-types/styled-component/index.js +1 -1
- package/dist/esm/rules/no-html-button/node-types/styled-component/index.js +1 -1
- package/dist/esm/rules/no-invalid-css-map/index.js +1 -1
- package/dist/esm/rules/no-invalid-css-map/utils.js +1 -1
- package/dist/esm/rules/no-legacy-icons/helpers.js +40 -3
- package/dist/esm/rules/no-margin/index.js +4 -4
- package/dist/esm/rules/no-nested-styles/index.js +2 -2
- package/dist/esm/rules/no-physical-properties/index.js +1 -1
- package/dist/esm/rules/no-unsafe-design-token-usage/index.js +2 -2
- package/dist/esm/rules/no-unsafe-style-overrides/index.js +1 -1
- package/dist/esm/rules/use-heading/config/index.js +1 -1
- package/dist/esm/rules/use-heading/index.js +13 -1
- package/dist/esm/rules/use-heading-level-in-spotlight-card/index.js +1 -1
- package/dist/esm/rules/use-href-in-link-item/index.js +1 -1
- package/dist/esm/rules/use-latest-xcss-syntax/index.js +1 -1
- package/dist/esm/rules/use-latest-xcss-syntax/transformers/style-property/index.js +1 -1
- package/dist/esm/rules/use-latest-xcss-syntax-typography/config/index.js +2 -1
- package/dist/esm/rules/use-latest-xcss-syntax-typography/index.js +25 -7
- package/dist/esm/rules/use-primitives/config/index.js +40 -0
- package/dist/esm/rules/use-primitives/index.js +15 -1
- package/dist/esm/rules/use-primitives/transformers/compiled-styled/index.js +1 -1
- package/dist/esm/rules/use-primitives/transformers/css-to-xcss.js +1 -1
- package/dist/esm/rules/use-primitives/transformers/emotion-css/index.js +1 -1
- package/dist/esm/rules/use-primitives/utils/get-variable-usage-count.js +1 -1
- package/dist/esm/rules/use-primitives-text/config/index.js +10 -1
- package/dist/esm/rules/use-primitives-text/index.js +28 -1
- package/dist/esm/rules/use-primitives-text/transformers/emphasis-elements.js +1 -1
- package/dist/esm/rules/use-primitives-text/transformers/paragraph-elements.js +1 -1
- package/dist/esm/rules/use-primitives-text/transformers/span-elements.js +1 -1
- package/dist/esm/rules/use-primitives-text/transformers/strong-elements.js +1 -1
- package/dist/esm/rules/use-tokens-space/index.js +5 -5
- package/dist/esm/rules/use-tokens-typography/config/index.js +1 -1
- package/dist/esm/rules/use-tokens-typography/index.js +7 -6
- package/dist/esm/rules/use-tokens-typography/transformers/font-family.js +3 -2
- package/dist/esm/rules/use-tokens-typography/transformers/font-weight.js +3 -2
- package/dist/esm/rules/use-tokens-typography/transformers/style-object.js +3 -9
- package/dist/esm/rules/use-tokens-typography/transformers/untokenized-properties.js +2 -1
- package/dist/esm/rules/use-visually-hidden/index.js +2 -2
- package/dist/esm/rules/utils/create-no-exported-rule/check-if-supported-export.js +5 -4
- package/dist/esm/rules/utils/create-no-exported-rule/main.js +1 -1
- package/dist/esm/rules/utils/create-no-tagged-template-expression-rule/index.js +1 -1
- package/dist/esm/rules/utils/get-first-supported-import.js +1 -1
- package/dist/esm/rules/utils/get-is-exception.js +3 -3
- package/dist/esm/rules/utils/is-node.js +23 -16
- package/dist/types/rules/use-latest-xcss-syntax-typography/config/index.d.ts +2 -1
- package/dist/types/rules/use-primitives/config/index.d.ts +2 -1
- package/dist/types/rules/use-primitives-text/config/index.d.ts +2 -1
- package/dist/types-ts4.5/rules/use-latest-xcss-syntax-typography/config/index.d.ts +6 -1
- package/dist/types-ts4.5/rules/use-primitives/config/index.d.ts +2 -1
- package/dist/types-ts4.5/rules/use-primitives-text/config/index.d.ts +2 -1
- package/package.json +4 -4
- package/dist/cjs/rules/utils/context-compat.js +0 -35
- package/dist/es2019/rules/utils/context-compat.js +0 -29
- package/dist/esm/rules/utils/context-compat.js +0 -29
- package/dist/types/rules/utils/context-compat.d.ts +0 -19
- package/dist/types-ts4.5/rules/utils/context-compat.d.ts +0 -19
|
@@ -5,47 +5,47 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isPropertyKey = exports.isDecendantOfXcssBlock = exports.isDecendantOfType = exports.isDecendantOfSvgElement = exports.isDecendantOfStyleJsxAttribute = exports.isDecendantOfStyleBlock = exports.isDecendantOfPrimitive = exports.isDecendantOfGlobalToken = exports.isCssInJsTemplateNode = exports.isCssInJsObjectNode = exports.isCssInJsCallNode = exports.isChildOfType = void 0;
|
|
7
7
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
8
9
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
9
10
|
var _astNodes = require("../../ast-nodes");
|
|
10
|
-
var _contextCompat = require("./context-compat");
|
|
11
11
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _isDecendantOfGlobalToken = exports.isDecendantOfGlobalToken = function isDecendantOfGlobalToken(node) {
|
|
14
14
|
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression') && (0, _eslintCodemodUtils.isNodeOfType)(node.callee, 'Identifier') && (node.callee.name === 'token' || node.callee.name === 'getTokenValue')) {
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
17
|
if (node.parent) {
|
|
18
|
-
return
|
|
18
|
+
return _isDecendantOfGlobalToken(node.parent);
|
|
19
19
|
}
|
|
20
20
|
return false;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var _isDecendantOfType = exports.isDecendantOfType = function isDecendantOfType(node, type) {
|
|
23
23
|
var skipNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
24
24
|
if (!skipNode && node.type === type) {
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
if (node.parent) {
|
|
28
|
-
return
|
|
28
|
+
return _isDecendantOfType(node.parent, type, false);
|
|
29
29
|
}
|
|
30
30
|
return false;
|
|
31
31
|
};
|
|
32
32
|
var isPropertyKey = exports.isPropertyKey = function isPropertyKey(node) {
|
|
33
|
-
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'Identifier') &&
|
|
33
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'Identifier') && _isDecendantOfType(node, 'Property')) {
|
|
34
34
|
var parent = node.parent;
|
|
35
35
|
return node === parent.key || parent.shorthand;
|
|
36
36
|
}
|
|
37
37
|
return false;
|
|
38
38
|
};
|
|
39
|
-
var
|
|
39
|
+
var _isDecendantOfStyleJsxAttribute = exports.isDecendantOfStyleJsxAttribute = function isDecendantOfStyleJsxAttribute(node) {
|
|
40
40
|
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXAttribute')) {
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
43
|
if (node.parent) {
|
|
44
|
-
return
|
|
44
|
+
return _isDecendantOfStyleJsxAttribute(node.parent);
|
|
45
45
|
}
|
|
46
46
|
return false;
|
|
47
47
|
};
|
|
48
|
-
var
|
|
48
|
+
var _isDecendantOfSvgElement = exports.isDecendantOfSvgElement = function isDecendantOfSvgElement(node) {
|
|
49
49
|
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
|
|
50
50
|
// @ts-ignore
|
|
51
51
|
if (node.openingElement.name.name === 'svg') {
|
|
@@ -53,11 +53,11 @@ var isDecendantOfSvgElement = exports.isDecendantOfSvgElement = function isDecen
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
if (node.parent) {
|
|
56
|
-
return
|
|
56
|
+
return _isDecendantOfSvgElement(node.parent);
|
|
57
57
|
}
|
|
58
58
|
return false;
|
|
59
59
|
};
|
|
60
|
-
var
|
|
60
|
+
var _isDecendantOfPrimitive = exports.isDecendantOfPrimitive = function isDecendantOfPrimitive(node, context) {
|
|
61
61
|
var primitivesToCheck = ['Box', 'Text'];
|
|
62
62
|
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
|
|
63
63
|
// @ts-ignore
|
|
@@ -69,7 +69,7 @@ var isDecendantOfPrimitive = exports.isDecendantOfPrimitive = function isDecenda
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
if (node.parent) {
|
|
72
|
-
return
|
|
72
|
+
return _isDecendantOfPrimitive(node.parent, context);
|
|
73
73
|
}
|
|
74
74
|
return false;
|
|
75
75
|
};
|
|
@@ -83,17 +83,17 @@ var isCssInJsCallNode = exports.isCssInJsCallNode = function isCssInJsCallNode(n
|
|
|
83
83
|
var isCssInJsObjectNode = exports.isCssInJsObjectNode = function isCssInJsObjectNode(node) {
|
|
84
84
|
return (node === null || node === void 0 ? void 0 : node.type) === 'CallExpression' && node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && cssInJsCallees.includes(node.callee.object.name);
|
|
85
85
|
};
|
|
86
|
-
var
|
|
86
|
+
var _isDecendantOfXcssBlock = exports.isDecendantOfXcssBlock = function isDecendantOfXcssBlock(node, referencesInScope, importSources) {
|
|
87
87
|
// xcss contains types for all properties that accept tokens, so ignore xcss for linting as it will report false positives
|
|
88
88
|
if (node.type === 'CallExpression' && (0, _isSupportedImport.isXcss)(node.callee, referencesInScope, importSources)) {
|
|
89
89
|
return true;
|
|
90
90
|
}
|
|
91
91
|
if (node.parent) {
|
|
92
|
-
return
|
|
92
|
+
return _isDecendantOfXcssBlock(node.parent, referencesInScope, importSources);
|
|
93
93
|
}
|
|
94
94
|
return false;
|
|
95
95
|
};
|
|
96
|
-
var
|
|
96
|
+
var _isDecendantOfStyleBlock = exports.isDecendantOfStyleBlock = function isDecendantOfStyleBlock(node) {
|
|
97
97
|
if (node.type === 'VariableDeclarator') {
|
|
98
98
|
if (node.id.type !== 'Identifier') {
|
|
99
99
|
return false;
|
|
@@ -128,7 +128,7 @@ var isDecendantOfStyleBlock = exports.isDecendantOfStyleBlock = function isDecen
|
|
|
128
128
|
return true;
|
|
129
129
|
}
|
|
130
130
|
if (node.parent) {
|
|
131
|
-
return
|
|
131
|
+
return _isDecendantOfStyleBlock(node.parent);
|
|
132
132
|
}
|
|
133
133
|
return false;
|
|
134
134
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getSourceCode } from '
|
|
4
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
export const ObjectEntry = {
|
|
6
6
|
getProperty(node) {
|
|
7
7
|
if (isNodeOfType(node.key, 'Identifier')) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
2
|
|
|
3
3
|
import { hasImportDeclaration, insertImportDeclaration, isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getSourceCode } from '
|
|
4
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { Import } from './import';
|
|
6
6
|
// Little bit unreadable, but better than duplicating the type
|
|
7
7
|
|
|
@@ -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::75357860fd00d6fc5060362c75d5db5e>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -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::1f8c75cb592edbc7ccb124c7e831e475>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { getIdentifierInParentScope, insertAtStartOfFile, insertImportDeclaration, isNodeOfType } from 'eslint-codemod-utils';
|
|
4
4
|
import estraverse from 'estraverse';
|
|
5
5
|
import assign from 'lodash/assign';
|
|
6
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
6
7
|
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
7
8
|
import { CSS_IN_JS_IMPORTS } from '@atlaskit/eslint-utils/is-supported-import';
|
|
8
9
|
import { Import } from '../../ast-nodes';
|
|
9
|
-
import { getScope, getSourceCode } from '../utils/context-compat';
|
|
10
10
|
import { createLintRule } from '../utils/create-rule';
|
|
11
11
|
import { getFirstSupportedImport } from '../utils/get-first-supported-import';
|
|
12
12
|
import { getModuleOfIdentifier } from '../utils/get-import-node-by-source';
|
|
@@ -129,25 +129,25 @@ export const lintJSXLiteralForColor = (node, context, config) => {
|
|
|
129
129
|
if (node.type !== 'Literal') {
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (!isNodeOfType(
|
|
132
|
+
|
|
133
|
+
// Changed this condition to properly handle both direct literals and expression containers
|
|
134
|
+
const parent = isNodeOfType(node.parent, 'JSXExpressionContainer') ? node.parent.parent : node.parent;
|
|
135
|
+
if (!isNodeOfType(parent, 'JSXAttribute')) {
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
|
-
if (isDecendantOfSvgElement(
|
|
138
|
+
if (isDecendantOfSvgElement(parent)) {
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
// Box backgroundColor prop accepts token names directly - don't lint against this
|
|
143
|
-
if (isDecendantOfPrimitive(
|
|
143
|
+
if (isDecendantOfPrimitive(parent, context)) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
if (['alt', 'src', 'label', 'key', 'appearance'].includes(
|
|
146
|
+
if (['alt', 'src', 'label', 'key', 'appearance'].includes(typeof parent.name.name === 'string' ? parent.name.name : parent.name.name.name)) {
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
const isException = getIsException(config.exceptions);
|
|
150
|
-
if (isException(
|
|
150
|
+
if (isException(parent)) {
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -214,11 +214,11 @@ css({
|
|
|
214
214
|
export const getTokenSuggestion = (node, reference, config) => [{
|
|
215
215
|
shouldReturnSuggestion: !isDecendantOfGlobalToken(node) && config.shouldEnforceFallbacks === false,
|
|
216
216
|
desc: `Convert to token`,
|
|
217
|
-
fix: fixer => fixer.replaceText(node, `token('')`)
|
|
217
|
+
fix: fixer => fixer.replaceText(isNodeOfType(node.parent, 'MemberExpression') ? node.parent : node, `token('')`)
|
|
218
218
|
}, {
|
|
219
219
|
shouldReturnSuggestion: !isDecendantOfGlobalToken(node) && config.shouldEnforceFallbacks === true,
|
|
220
220
|
desc: `Convert to token with fallback`,
|
|
221
|
-
fix: fixer => fixer.replaceText(node, isNodeOfType(node.parent, 'JSXAttribute') ? `{token('', ${reference})}` : `token('', ${reference})`)
|
|
221
|
+
fix: fixer => fixer.replaceText(isNodeOfType(node.parent, 'MemberExpression') ? node.parent : node, isNodeOfType(node.parent, 'JSXAttribute') ? `{token('', ${reference})}` : `token('', ${reference})`)
|
|
222
222
|
}].filter(filterSuggestion);
|
|
223
223
|
const filterSuggestion = ({
|
|
224
224
|
shouldReturnSuggestion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
4
5
|
import { getImportSources } from '@atlaskit/eslint-utils/is-supported-import';
|
|
5
|
-
import { getScope, getSourceCode } from '../utils/context-compat';
|
|
6
6
|
import { createLintRule } from '../utils/create-rule';
|
|
7
7
|
import { errorBoundary } from '../utils/error-boundary';
|
|
8
8
|
import { includesHardCodedColor } from '../utils/is-color';
|
|
@@ -252,6 +252,13 @@ const createWithConfig = initialConfig => context => {
|
|
|
252
252
|
}
|
|
253
253
|
return;
|
|
254
254
|
},
|
|
255
|
+
// Add handling for JSXExpressionContainer with string literals
|
|
256
|
+
'JSXAttribute > JSXExpressionContainer > Literal': node => {
|
|
257
|
+
if (config.domains.includes('color')) {
|
|
258
|
+
return lintJSXLiteralForColor(node, context, config);
|
|
259
|
+
}
|
|
260
|
+
return;
|
|
261
|
+
},
|
|
255
262
|
// For inline JSX styles - members (e.g. <Test color={color.red}/>) - color only
|
|
256
263
|
'JSXExpressionContainer > MemberExpression': node => {
|
|
257
264
|
if (config.domains.includes('color')) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { callExpression, identifier, insertAtStartOfFile, insertImportDeclaration, isNodeOfType, literal } from 'eslint-codemod-utils';
|
|
4
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
4
5
|
import { spacing as spacingScale } from '@atlaskit/tokens/tokens-raw';
|
|
5
|
-
import { getScope, getSourceCode } from '../utils/context-compat';
|
|
6
6
|
import { findIdentifierInParentScope } from '../utils/find-in-parent';
|
|
7
7
|
import { isColorCssPropertyName, isCurrentSurfaceCustomPropertyName } from '../utils/is-color';
|
|
8
8
|
import { borderWidthValueToToken, isBorderRadius, isBorderSizeProperty, isShapeProperty, radiusValueToToken } from './shape';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
import { getSourceCode } from '
|
|
2
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
3
3
|
import { createLintRule } from '../utils/create-rule';
|
|
4
4
|
import { getConfig } from '../utils/get-deprecated-config';
|
|
5
5
|
import { isDeprecatedJSXAttributeConfig } from '../utils/types';
|
package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getSourceCode } from '
|
|
4
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { getModuleOfIdentifier } from '../../utils/get-import-node-by-source';
|
|
6
6
|
import { isBlockedEventBinding } from '../shared/is-blocked-event-binding';
|
|
7
7
|
export function isBlockedBindAll(context, node) {
|
package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getSourceCode } from '
|
|
4
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { getModuleOfIdentifier } from '../../utils/get-import-node-by-source';
|
|
6
6
|
import { isBlockedEventBinding } from '../shared/is-blocked-event-binding';
|
|
7
7
|
export function isBlockedBind(context, node) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getSourceCode } from '
|
|
4
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { getModuleOfIdentifier } from '../../utils/get-import-node-by-source';
|
|
6
6
|
import { blockedJSXAttributeLookup } from '../shared/blocked';
|
|
7
7
|
function getJSXElementNameFromAttribute(attribute) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
1
2
|
import { getImportSources, isStyled } from '@atlaskit/eslint-utils/is-supported-import';
|
|
2
|
-
import { getScope } from '../utils/context-compat';
|
|
3
3
|
import { createLintRule } from '../utils/create-rule';
|
|
4
4
|
const isEmptyStyledExpression = node => {
|
|
5
5
|
const [firstArg] = node.arguments;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
2
|
|
|
3
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
3
4
|
import * as ast from '../../../../ast-nodes';
|
|
4
|
-
import { getSourceCode } from '../../../utils/context-compat';
|
|
5
5
|
import { isSupportedForLint } from '../supported';
|
|
6
6
|
function isImportDeclaration(node) {
|
|
7
7
|
return node.type === 'ImportDeclaration';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getScope } from '
|
|
4
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { getJsxElementByName } from '../../utils/get-jsx-element-by-name';
|
|
6
6
|
import { isSupportedForLint } from '../supported';
|
|
7
7
|
import { getStyledComponentCall } from './get-styled-component-call';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getScope } from '
|
|
4
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { getJsxElementByName } from '../../utils/get-jsx-element-by-name';
|
|
6
6
|
import { isSupportedForLint } from '../supported';
|
|
7
7
|
import { getStyledComponentCall } from './get-styled-component-call';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
1
2
|
import { CSS_IN_JS_IMPORTS, isCssMap } from '@atlaskit/eslint-utils/is-supported-import';
|
|
2
|
-
import { getScope, getSourceCode } from '../utils/context-compat';
|
|
3
3
|
import { checkIfSupportedExport } from '../utils/create-no-exported-rule/check-if-supported-export';
|
|
4
4
|
import { createLintRule } from '../utils/create-rule';
|
|
5
5
|
import { CssMapObjectChecker, getCssMapObject } from './utils';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
2
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
2
3
|
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
3
|
-
import { getSourceCode } from '../utils/context-compat';
|
|
4
4
|
export const getCssMapObject = node => {
|
|
5
5
|
// We assume the argument `node` is already a cssMap() call.
|
|
6
6
|
|
|
@@ -453,10 +453,25 @@ const createImportFix = ({
|
|
|
453
453
|
const importPath = migrationImportNode ? importSource.replace('/migration', '').split('--')[0] : getNewIconNameAndImportPath(importSource, shouldUseMigrationPath).importPath;
|
|
454
454
|
const useMigrationPath = legacyImportNode && importPath;
|
|
455
455
|
const useFinalPath = migrationImportNode && !shouldUseMigrationPath && importPath;
|
|
456
|
+
const programNode = legacyImportNode && findProgramNode(legacyImportNode);
|
|
456
457
|
if (useMigrationPath) {
|
|
457
|
-
|
|
458
|
+
if (newIconName) {
|
|
459
|
+
const isExisting = programNode ? alreadyHasImportedLocalName(programNode, newIconName, importPath) : false;
|
|
460
|
+
if (!isExisting) {
|
|
461
|
+
fixes.push(fixer.insertTextBefore(legacyImportNode, `import ${newIconName} from '${importPath}';\n`));
|
|
462
|
+
}
|
|
463
|
+
} else {
|
|
464
|
+
fixes.push(fixer.replaceText(legacyImportNode.source, `'${literal(importPath)}'`));
|
|
465
|
+
}
|
|
458
466
|
} else if (useFinalPath) {
|
|
459
|
-
|
|
467
|
+
if (newIconName) {
|
|
468
|
+
const isExisting = programNode ? alreadyHasImportedLocalName(programNode, newIconName, importPath) : false;
|
|
469
|
+
if (!isExisting) {
|
|
470
|
+
fixes.push(fixer.insertTextBefore(migrationImportNode, `import ${newIconName} from '${importPath}';\n`));
|
|
471
|
+
}
|
|
472
|
+
} else {
|
|
473
|
+
fixes.push(fixer.replaceText(migrationImportNode.source, `'${literal(importPath)}'`));
|
|
474
|
+
}
|
|
460
475
|
}
|
|
461
476
|
return fixes;
|
|
462
477
|
};
|
|
@@ -728,4 +743,24 @@ export const throwAutoErrors = ({
|
|
|
728
743
|
context.report(error);
|
|
729
744
|
});
|
|
730
745
|
}
|
|
731
|
-
};
|
|
746
|
+
};
|
|
747
|
+
function findProgramNode(node) {
|
|
748
|
+
while (node && node.parent) {
|
|
749
|
+
if (node.parent.type === 'Program') {
|
|
750
|
+
return node.parent;
|
|
751
|
+
}
|
|
752
|
+
node = node.parent;
|
|
753
|
+
}
|
|
754
|
+
return null;
|
|
755
|
+
}
|
|
756
|
+
function alreadyHasImportedLocalName(programNode, localName, importPath) {
|
|
757
|
+
if (!(programNode !== null && programNode !== void 0 && programNode.body)) {
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
return programNode.body.some(stmt => {
|
|
761
|
+
if (stmt.type === 'ImportDeclaration' && stmt.source.value === importPath) {
|
|
762
|
+
return stmt.specifiers.some(s => s.local.name === localName);
|
|
763
|
+
}
|
|
764
|
+
return false;
|
|
765
|
+
});
|
|
766
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getScope } from '
|
|
4
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { createLintRule } from '../utils/create-rule';
|
|
6
6
|
import { findIdentifierInParentScope } from '../utils/find-in-parent';
|
|
7
7
|
const allowedPrefix = [':', '&:'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
import { getSourceCode } from '
|
|
2
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
3
3
|
import { createLintRule } from '../utils/create-rule';
|
|
4
4
|
import { getModuleOfIdentifier } from '../utils/get-import-node-by-source';
|
|
5
5
|
import { getJSXElementName } from '../utils/jsx';
|
|
@@ -9,6 +9,18 @@ const rule = createLintRule({
|
|
|
9
9
|
type: 'suggestion',
|
|
10
10
|
fixable: 'code',
|
|
11
11
|
hasSuggestions: true,
|
|
12
|
+
schema: [{
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
enableUnsafeReport: {
|
|
16
|
+
type: 'boolean'
|
|
17
|
+
},
|
|
18
|
+
enableUnsafeAutofix: {
|
|
19
|
+
type: 'boolean'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
additionalProperties: false
|
|
23
|
+
}],
|
|
12
24
|
docs: {
|
|
13
25
|
description: 'Encourage the usage of heading components.',
|
|
14
26
|
recommended: false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getScope } from '
|
|
4
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { createLintRule } from '../utils/create-rule';
|
|
6
6
|
import { getImportName } from '../utils/get-import-name';
|
|
7
7
|
export const headingLevelRequiredSuggestionText = 'Add a `headingLevel` that is of a contextually relevant level.';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getScope } from '
|
|
4
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { createLintRule } from '../utils/create-rule';
|
|
6
6
|
import { getImportName } from '../utils/get-import-name';
|
|
7
7
|
import { getUniqueButtonItemName, hasImportOfName, hrefHasInvalidValue, insertButtonItemDefaultImport, insertButtonItemImport } from './utils';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
4
5
|
import * as ast from '../../../../ast-nodes';
|
|
5
|
-
import { getSourceCode } from '../../../utils/context-compat';
|
|
6
6
|
import { styleMap } from './style-map';
|
|
7
7
|
import supported from './supported';
|
|
8
8
|
const messageId = 'noRawSpacingValues';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export const PATTERNS = ['restricted-property', 'wrapped-token-value', 'restricted-capitalisation'];
|
|
1
2
|
const defaults = {
|
|
2
3
|
failSilently: false,
|
|
3
|
-
patterns: [
|
|
4
|
+
patterns: [...PATTERNS]
|
|
4
5
|
};
|
|
5
6
|
export const getConfig = overrides => {
|
|
6
7
|
return Object.assign({}, defaults, overrides);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
2
|
import { errorBoundary } from '../utils/error-boundary';
|
|
3
|
-
import { getConfig } from './config';
|
|
3
|
+
import { getConfig, PATTERNS } from './config';
|
|
4
4
|
import { RestrictedCapitalisation, RestrictedProperty, WrappedTokenValue } from './linters';
|
|
5
5
|
const typescriptErrorMessage = 'There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.';
|
|
6
6
|
const rule = createLintRule({
|
|
@@ -9,6 +9,24 @@ const rule = createLintRule({
|
|
|
9
9
|
type: 'problem',
|
|
10
10
|
fixable: 'code',
|
|
11
11
|
hasSuggestions: false,
|
|
12
|
+
schema: [{
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
failSilently: {
|
|
16
|
+
type: 'boolean'
|
|
17
|
+
},
|
|
18
|
+
patterns: {
|
|
19
|
+
maxLength: PATTERNS.length,
|
|
20
|
+
type: 'array',
|
|
21
|
+
items: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
enum: PATTERNS
|
|
24
|
+
},
|
|
25
|
+
uniqueItems: true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
additionalProperties: false
|
|
29
|
+
}],
|
|
12
30
|
docs: {
|
|
13
31
|
description: 'Prohibits use of unsafe styling properties in xcss. Please use Text/Heading primitives instead.',
|
|
14
32
|
recommended: true,
|
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
export const VALID_PATTERNS = [
|
|
2
|
+
// this enables the rule to look for a pattern like:
|
|
3
|
+
// const myStyles = css({...})
|
|
4
|
+
'compiled-css-function',
|
|
5
|
+
// this enables the rule to look for a pattern like:
|
|
6
|
+
// const MyComponent = styled.div({...})
|
|
7
|
+
'compiled-styled-object',
|
|
8
|
+
// this enables the rule to look for a pattern like:
|
|
9
|
+
// css({ padding: `I AM A TEMPLATE LITERAL` })
|
|
10
|
+
// or styled.div({ padding: `I AM A TEMPLATE LITERAL` })
|
|
11
|
+
'css-template-literal',
|
|
12
|
+
// this enables the rule to look for a pattern like:
|
|
13
|
+
// css({ padding: token(...) })
|
|
14
|
+
// or styled.div({ padding: token(...) })
|
|
15
|
+
'css-property-with-tokens',
|
|
16
|
+
// this enables the rule to look for a pattern like:
|
|
17
|
+
// css({ padding: '8px 16px' })
|
|
18
|
+
// or styled.div({ padding: css({ padding: '8px 16px' }) })
|
|
19
|
+
// ... and they could be tokenised
|
|
20
|
+
// ... and they could be using template literals
|
|
21
|
+
'css-property-multiple-values',
|
|
22
|
+
// This enables the rule to look for a pattern like:
|
|
23
|
+
// ```
|
|
24
|
+
// const styles = css({ // or `styled.div({`
|
|
25
|
+
// padding: '8px',
|
|
26
|
+
// margin: '8px',
|
|
27
|
+
// })
|
|
28
|
+
'multiple-properties',
|
|
29
|
+
// This enables the rule to look for supported dimension properties set as 100% like:
|
|
30
|
+
// ```
|
|
31
|
+
// const styles = css({ // or `styled.div({`
|
|
32
|
+
// padding: '8px',
|
|
33
|
+
// margin: '8px',
|
|
34
|
+
// width: '100%',
|
|
35
|
+
// })
|
|
36
|
+
'dimension-properties',
|
|
37
|
+
// This enables the rule to look for JSX elements that are defined before the styles
|
|
38
|
+
'jsx-order-fix',
|
|
39
|
+
// This enables a fix for string style properties being incorrectly transformed
|
|
40
|
+
'string-style-property-fix'];
|
|
1
41
|
const defaults = {
|
|
2
42
|
patterns: ['compiled-css-function']
|
|
3
43
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
|
-
import { getConfig } from './config';
|
|
2
|
+
import { getConfig, VALID_PATTERNS } from './config';
|
|
3
3
|
import { CompiledStyled, EmotionCSS } from './transformers';
|
|
4
4
|
const boxDocsUrl = 'https://atlassian.design/components/primitives/box';
|
|
5
5
|
const rule = createLintRule({
|
|
@@ -13,6 +13,20 @@ const rule = createLintRule({
|
|
|
13
13
|
recommended: false,
|
|
14
14
|
severity: 'warn'
|
|
15
15
|
},
|
|
16
|
+
schema: [{
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
patterns: {
|
|
20
|
+
type: 'array',
|
|
21
|
+
maxLength: VALID_PATTERNS.length,
|
|
22
|
+
items: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
enum: VALID_PATTERNS
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
additionalProperties: false
|
|
29
|
+
}],
|
|
16
30
|
messages: {
|
|
17
31
|
preferPrimitivesBox: `This element can be replaced with a "Box" primitive. See ${boxDocsUrl} for additional guidance.`
|
|
18
32
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
4
5
|
import * as ast from '../../../../ast-nodes';
|
|
5
|
-
import { getScope, getSourceCode } from '../../../utils/context-compat';
|
|
6
6
|
import { isValidCssPropertiesToTransform } from '../../utils';
|
|
7
7
|
import { validateStyles } from '../../utils/validate-styles';
|
|
8
8
|
import { convertJsxCallSite } from './convert-jsx-call-site';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getIdentifierInParentScope, identifier, isNodeOfType, literal } from 'eslint-codemod-utils';
|
|
2
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
2
3
|
import { allSpaceMap, positiveSpaceMap } from '../../../common/token-maps.partial';
|
|
3
|
-
import { getScope } from '../../utils/context-compat';
|
|
4
4
|
import { getAttributeValueIdentifier, getFunctionArgumentAtPos, getJSXAttributeByName, getVariableDefinitionValue } from '../utils';
|
|
5
5
|
export const cssToXcssTransformer = (node, context, fixer) => {
|
|
6
6
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
2
|
|
|
3
3
|
import { getIdentifierInParentScope, isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
4
5
|
import * as ast from '../../../../ast-nodes';
|
|
5
|
-
import { getScope, getSourceCode } from '../../../utils/context-compat';
|
|
6
6
|
import { getVariableDefinitionValue, getVariableUsagesCount, isValidCssPropertiesToTransform } from '../../utils';
|
|
7
7
|
import { validateStyles } from '../../utils/validate-styles';
|
|
8
8
|
import { cssToXcssTransformer } from '../css-to-xcss';
|