@atlaskit/eslint-plugin-design-system 8.17.0 → 8.18.1
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 -0
- package/constellation/index/usage.mdx +22 -0
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/use-heading-level-in-spotlight-card/index.js +63 -0
- package/dist/cjs/rules/use-href-in-link-item/index.js +2 -1
- package/dist/cjs/rules/use-href-in-link-item/utils.js +1 -25
- package/dist/cjs/rules/use-primitives/index.js +40 -35
- package/dist/cjs/rules/use-primitives/transformers/css-to-xcss.js +10 -3
- package/dist/cjs/rules/use-primitives/transformers/index.js +8 -1
- package/dist/cjs/rules/use-primitives/transformers/styled-component-to-primitive.js +68 -0
- package/dist/cjs/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.js +16 -0
- package/dist/cjs/rules/use-primitives/utils/find-valid-jsx-usage-to-transform.js +39 -0
- package/dist/cjs/rules/use-primitives/utils/find-valid-styled-component-call.js +52 -0
- package/dist/cjs/rules/use-primitives/utils/index.js +21 -0
- package/dist/cjs/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +38 -0
- package/dist/cjs/rules/use-primitives/utils/is-valid-tag-name.js +2 -2
- package/dist/cjs/rules/use-primitives/utils/update-jsx-element-name.js +1 -1
- package/dist/cjs/rules/utils/get-import-name.js +30 -0
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/use-heading-level-in-spotlight-card/index.js +49 -0
- package/dist/es2019/rules/use-href-in-link-item/index.js +3 -2
- package/dist/es2019/rules/use-href-in-link-item/utils.js +0 -24
- package/dist/es2019/rules/use-primitives/index.js +41 -37
- package/dist/es2019/rules/use-primitives/transformers/css-to-xcss.js +9 -6
- package/dist/es2019/rules/use-primitives/transformers/index.js +2 -1
- package/dist/es2019/rules/use-primitives/transformers/styled-component-to-primitive.js +59 -0
- package/dist/es2019/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.js +14 -0
- package/dist/es2019/rules/use-primitives/utils/find-valid-jsx-usage-to-transform.js +32 -0
- package/dist/es2019/rules/use-primitives/utils/find-valid-styled-component-call.js +47 -0
- package/dist/es2019/rules/use-primitives/utils/index.js +3 -0
- package/dist/es2019/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +32 -0
- package/dist/es2019/rules/use-primitives/utils/is-valid-tag-name.js +1 -1
- package/dist/es2019/rules/use-primitives/utils/update-jsx-element-name.js +1 -1
- package/dist/es2019/rules/utils/get-import-name.js +24 -0
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/use-heading-level-in-spotlight-card/index.js +57 -0
- package/dist/esm/rules/use-href-in-link-item/index.js +3 -2
- package/dist/esm/rules/use-href-in-link-item/utils.js +0 -24
- package/dist/esm/rules/use-primitives/index.js +41 -37
- package/dist/esm/rules/use-primitives/transformers/css-to-xcss.js +9 -2
- package/dist/esm/rules/use-primitives/transformers/index.js +2 -1
- package/dist/esm/rules/use-primitives/transformers/styled-component-to-primitive.js +61 -0
- package/dist/esm/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.js +16 -0
- package/dist/esm/rules/use-primitives/utils/find-valid-jsx-usage-to-transform.js +34 -0
- package/dist/esm/rules/use-primitives/utils/find-valid-styled-component-call.js +47 -0
- package/dist/esm/rules/use-primitives/utils/index.js +3 -0
- package/dist/esm/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +32 -0
- package/dist/esm/rules/use-primitives/utils/is-valid-tag-name.js +1 -1
- package/dist/esm/rules/use-primitives/utils/update-jsx-element-name.js +1 -1
- package/dist/esm/rules/utils/get-import-name.js +24 -0
- package/dist/types/index.codegen.d.ts +2 -0
- package/dist/types/presets/all.codegen.d.ts +2 -1
- package/dist/types/presets/recommended.codegen.d.ts +2 -1
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/use-heading-level-in-spotlight-card/index.d.ts +4 -0
- package/dist/types/rules/use-href-in-link-item/utils.d.ts +0 -1
- package/dist/types/rules/use-primitives/transformers/css-to-xcss.d.ts +2 -1
- package/dist/types/rules/use-primitives/transformers/index.d.ts +1 -0
- package/dist/types/rules/use-primitives/transformers/styled-component-to-primitive.d.ts +13 -0
- package/dist/types/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.d.ts +1 -1
- package/dist/types/rules/use-primitives/utils/find-valid-jsx-usage-to-transform.d.ts +7 -0
- package/dist/types/rules/use-primitives/utils/find-valid-styled-component-call.d.ts +7 -0
- package/dist/types/rules/use-primitives/utils/index.d.ts +3 -0
- package/dist/types/rules/use-primitives/utils/is-valid-css-properties-to-transform.d.ts +3 -0
- package/dist/types/rules/use-primitives/utils/is-valid-tag-name.d.ts +1 -0
- package/dist/types/rules/use-primitives/utils/update-jsx-element-name.d.ts +1 -1
- package/dist/types/rules/utils/get-import-name.d.ts +2 -0
- package/dist/types-ts4.5/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-heading-level-in-spotlight-card/index.d.ts +4 -0
- package/dist/types-ts4.5/rules/use-href-in-link-item/utils.d.ts +0 -1
- package/dist/types-ts4.5/rules/use-primitives/transformers/css-to-xcss.d.ts +2 -1
- package/dist/types-ts4.5/rules/use-primitives/transformers/index.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/styled-component-to-primitive.d.ts +13 -0
- package/dist/types-ts4.5/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-primitives/utils/find-valid-jsx-usage-to-transform.d.ts +7 -0
- package/dist/types-ts4.5/rules/use-primitives/utils/find-valid-styled-component-call.d.ts +7 -0
- package/dist/types-ts4.5/rules/use-primitives/utils/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/use-primitives/utils/is-valid-css-properties-to-transform.d.ts +3 -0
- package/dist/types-ts4.5/rules/use-primitives/utils/is-valid-tag-name.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-primitives/utils/update-jsx-element-name.d.ts +1 -1
- package/dist/types-ts4.5/rules/utils/get-import-name.d.ts +2 -0
- package/package.json +1 -1
|
@@ -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::37a857efd0971ab26170d5f1f526279b>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -22,6 +22,7 @@ export default {
|
|
|
22
22
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
23
23
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
24
24
|
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
25
|
+
'@atlaskit/design-system/use-heading-level-in-spotlight-card': 'warn',
|
|
25
26
|
'@atlaskit/design-system/use-href-in-link-item': 'warn',
|
|
26
27
|
'@atlaskit/design-system/use-primitives': 'warn',
|
|
27
28
|
'@atlaskit/design-system/use-visually-hidden': 'error'
|
|
@@ -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::b3bce8efb2db1fed84370af608ca0d4c>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -17,6 +17,7 @@ export default {
|
|
|
17
17
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
18
18
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
19
19
|
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
20
|
+
'@atlaskit/design-system/use-heading-level-in-spotlight-card': 'warn',
|
|
20
21
|
'@atlaskit/design-system/use-href-in-link-item': 'warn',
|
|
21
22
|
'@atlaskit/design-system/use-visually-hidden': 'error'
|
|
22
23
|
}
|
|
@@ -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::e2cc357c90120dbbd89b2928dba968c0>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import consistentCssPropUsage from './consistent-css-prop-usage';
|
|
@@ -19,6 +19,7 @@ import noUnsafeDesignTokenUsage from './no-unsafe-design-token-usage';
|
|
|
19
19
|
import noUnsupportedDragAndDropLibraries from './no-unsupported-drag-and-drop-libraries';
|
|
20
20
|
import preferPrimitives from './prefer-primitives';
|
|
21
21
|
import useDrawerLabel from './use-drawer-label';
|
|
22
|
+
import useHeadingLevelInSpotlightCard from './use-heading-level-in-spotlight-card';
|
|
22
23
|
import useHrefInLinkItem from './use-href-in-link-item';
|
|
23
24
|
import usePrimitives from './use-primitives';
|
|
24
25
|
import useVisuallyHidden from './use-visually-hidden';
|
|
@@ -39,6 +40,7 @@ export default {
|
|
|
39
40
|
'no-unsupported-drag-and-drop-libraries': noUnsupportedDragAndDropLibraries,
|
|
40
41
|
'prefer-primitives': preferPrimitives,
|
|
41
42
|
'use-drawer-label': useDrawerLabel,
|
|
43
|
+
'use-heading-level-in-spotlight-card': useHeadingLevelInSpotlightCard,
|
|
42
44
|
'use-href-in-link-item': useHrefInLinkItem,
|
|
43
45
|
'use-primitives': usePrimitives,
|
|
44
46
|
'use-visually-hidden': useVisuallyHidden
|
|
@@ -0,0 +1,57 @@
|
|
|
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 { getImportName } from '../utils/get-import-name';
|
|
6
|
+
export var headingLevelRequiredSuggestionText = 'Add a `headingLevel` that is of a contextually relevant level.';
|
|
7
|
+
var rule = createLintRule({
|
|
8
|
+
meta: {
|
|
9
|
+
name: 'use-heading-level-in-spotlight-card',
|
|
10
|
+
type: 'suggestion',
|
|
11
|
+
fixable: 'code',
|
|
12
|
+
docs: {
|
|
13
|
+
description: 'Inform developers of eventual requirement of `headingLevel` prop in `SpotlightCard` component. The heading level should be the appropriate level according to the surrounding context.',
|
|
14
|
+
recommended: true,
|
|
15
|
+
severity: 'warn'
|
|
16
|
+
},
|
|
17
|
+
messages: {
|
|
18
|
+
headingLevelRequired: headingLevelRequiredSuggestionText
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
create: function create(context) {
|
|
22
|
+
return {
|
|
23
|
+
JSXElement: function JSXElement(node) {
|
|
24
|
+
if (!isNodeOfType(node, 'JSXElement')) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Get the name of the SpotlightCard import
|
|
32
|
+
var spotlightCardImportName = getImportName(context.getScope(), '@atlaskit/onboarding', 'SpotlightCard');
|
|
33
|
+
if (node.openingElement.name.name === spotlightCardImportName) {
|
|
34
|
+
// and if `heading` exists and `headingLevel` prop does not exist
|
|
35
|
+
var spotlightCardProps = node.openingElement.attributes.filter(function (attr) {
|
|
36
|
+
return isNodeOfType(attr, 'JSXAttribute');
|
|
37
|
+
}).filter(function (attr) {
|
|
38
|
+
return attr.name.type === 'JSXIdentifier';
|
|
39
|
+
});
|
|
40
|
+
var heading = spotlightCardProps.find(function (attr) {
|
|
41
|
+
return attr.name.name === 'heading';
|
|
42
|
+
});
|
|
43
|
+
var headingLevel = spotlightCardProps.find(function (attr) {
|
|
44
|
+
return attr.name.name === 'headingLevel';
|
|
45
|
+
});
|
|
46
|
+
if (heading && !headingLevel) {
|
|
47
|
+
context.report({
|
|
48
|
+
node: node,
|
|
49
|
+
messageId: 'headingLevelRequired'
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
export default rule;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
4
|
import { createLintRule } from '../utils/create-rule';
|
|
5
|
-
import {
|
|
5
|
+
import { getImportName } from '../utils/get-import-name';
|
|
6
|
+
import { getUniqueButtonItemName, hasImportOfName, hrefHasInvalidValue, insertButtonItemDefaultImport, insertButtonItemImport } from './utils';
|
|
6
7
|
export var hrefRequiredSuggestionText = 'Convert LinkItem to ButtonItem';
|
|
7
8
|
var rule = createLintRule({
|
|
8
9
|
meta: {
|
|
@@ -46,7 +47,7 @@ var rule = createLintRule({
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
// Get the name of the LinkItem import
|
|
49
|
-
var linkItemImportName = customDefaultLinkItemSpecifier ||
|
|
50
|
+
var linkItemImportName = customDefaultLinkItemSpecifier || getImportName(context.getScope(), '@atlaskit/menu', 'LinkItem');
|
|
50
51
|
if (node.openingElement.name.name === linkItemImportName) {
|
|
51
52
|
// and if href prop does not exist
|
|
52
53
|
var linkProps = node.openingElement.attributes.filter(function (attr) {
|
|
@@ -2,30 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
4
|
import { findIdentifierInParentScope } from '../utils/find-in-parent';
|
|
5
|
-
export var getLinkItemImportName = function getLinkItemImportName(scope) {
|
|
6
|
-
var traversingScope = scope;
|
|
7
|
-
var matchedVariable;
|
|
8
|
-
while (traversingScope && traversingScope.type !== 'global') {
|
|
9
|
-
matchedVariable = traversingScope.variables.find(function (variable) {
|
|
10
|
-
var _variable$defs;
|
|
11
|
-
var def = (_variable$defs = variable.defs) === null || _variable$defs === void 0 ? void 0 : _variable$defs[0];
|
|
12
|
-
if (!def || !(def !== null && def !== void 0 && def.node) || !isNodeOfType(def.node, 'ImportSpecifier') || !def.parent || !isNodeOfType(def.parent, 'ImportDeclaration')) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
return def.parent.source.value === '@atlaskit/menu' && def.node.imported.name === 'LinkItem';
|
|
16
|
-
});
|
|
17
|
-
if (matchedVariable) {
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
traversingScope = traversingScope.upper;
|
|
21
|
-
}
|
|
22
|
-
if (!matchedVariable) {
|
|
23
|
-
return null;
|
|
24
|
-
} else {
|
|
25
|
-
var _matchedVariable$defs;
|
|
26
|
-
return (_matchedVariable$defs = matchedVariable.defs) === null || _matchedVariable$defs === void 0 ? void 0 : _matchedVariable$defs[0].node.local.name;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
5
|
var invalidHrefValues = ['', '#', null, undefined];
|
|
30
6
|
export var hrefHasInvalidValue = function hrefHasInvalidValue(scope, href) {
|
|
31
7
|
// If doesn't exist,
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { getIdentifierInParentScope, isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import assign from 'lodash/assign';
|
|
2
3
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
-
import { jsxElementToBoxTransformer,
|
|
4
|
-
import { containsOnlySupportedAttrs,
|
|
4
|
+
import { jsxElementToBoxTransformer, styledComponentToPrimitive } from './transformers';
|
|
5
|
+
import { containsOnlySupportedAttrs, findValidJsxUsageToTransform, findValidStyledComponentCall, getAttributeValueIdentifier, getJSXAttributeByName, getVariableDefinitionValue, getVariableUsagesCount, isFunctionNamed, isValidCssPropertiesToTransform, isValidTagName } from './utils';
|
|
5
6
|
var boxDocsUrl = 'https://atlassian.design/components/primitives/box';
|
|
7
|
+
var defaultConfig = {
|
|
8
|
+
preview: false
|
|
9
|
+
};
|
|
6
10
|
var rule = createLintRule({
|
|
7
11
|
meta: {
|
|
8
12
|
name: 'use-primitives',
|
|
@@ -15,11 +19,43 @@ var rule = createLintRule({
|
|
|
15
19
|
severity: 'warn'
|
|
16
20
|
},
|
|
17
21
|
messages: {
|
|
18
|
-
preferPrimitivesBox: "This
|
|
22
|
+
preferPrimitivesBox: "This element can be replaced with a \"Box\" primitive. See ".concat(boxDocsUrl, " for additional guidance.")
|
|
19
23
|
}
|
|
20
24
|
},
|
|
21
25
|
create: function create(context) {
|
|
26
|
+
var mergedConfig = assign({}, defaultConfig, context.options[0]);
|
|
22
27
|
return {
|
|
28
|
+
// transforms styled.<html>(...) usages
|
|
29
|
+
CallExpression: function CallExpression(node) {
|
|
30
|
+
if (!mergedConfig.preview) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!isNodeOfType(node, 'CallExpression')) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
var styledComponentVariableRef = findValidStyledComponentCall(node);
|
|
37
|
+
if (!styledComponentVariableRef || !isNodeOfType(styledComponentVariableRef.id, 'Identifier') || !isValidCssPropertiesToTransform(node)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var styledComponentJsxRef = findValidJsxUsageToTransform(styledComponentVariableRef.id.name, context.getScope());
|
|
41
|
+
if (!styledComponentJsxRef) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// if we have both references at this point then we can offer a fix \o/
|
|
46
|
+
context.report({
|
|
47
|
+
node: styledComponentVariableRef,
|
|
48
|
+
messageId: 'preferPrimitivesBox',
|
|
49
|
+
suggest: [{
|
|
50
|
+
desc: "Convert ".concat(styledComponentVariableRef.id.name, " to Box"),
|
|
51
|
+
fix: styledComponentToPrimitive({
|
|
52
|
+
stylesRef: styledComponentVariableRef,
|
|
53
|
+
jsxRef: styledComponentJsxRef
|
|
54
|
+
}, context)
|
|
55
|
+
}]
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
// transforms <div css={...}> usages
|
|
23
59
|
JSXOpeningElement: function JSXOpeningElement(node) {
|
|
24
60
|
if (!isNodeOfType(node, 'JSXOpeningElement')) {
|
|
25
61
|
return;
|
|
@@ -91,42 +127,10 @@ var shouldSuggestBox = function shouldSuggestBox(node, context
|
|
|
91
127
|
// Find where `cssVariableName` is defined. We're looking for `const myStyles = css({...})`
|
|
92
128
|
var cssVariableDefinition = getIdentifierInParentScope(context.getScope(), cssVariableName);
|
|
93
129
|
var cssVariableValue = getVariableDefinitionValue(cssVariableDefinition);
|
|
94
|
-
|
|
95
130
|
// Check if `cssVariableValue` is a function called `css()`
|
|
96
|
-
if (!isFunctionNamed(cssVariableValue, 'css')) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// get the `{}` in `css({})`
|
|
101
|
-
// Zero indexed
|
|
102
|
-
var cssObjectExpression = getFunctionArgumentAtPos(cssVariableValue, 0);
|
|
103
|
-
|
|
104
|
-
// Bail on empty `css()` calls
|
|
105
|
-
if (!cssObjectExpression) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
var cssObject = convertASTObjectExpressionToJSObject(cssObjectExpression);
|
|
109
|
-
|
|
110
|
-
// Bail if there are less or more than 1 styles defined
|
|
111
|
-
if (Object.keys(cssObject).length !== 1) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// NOTE: Our approach with this lint rule is to strictly whitelist css properties we can map.
|
|
116
|
-
// It means we have to provide mappings for everything (e.g. `display: block`).
|
|
117
|
-
// However, from a maker's experience, it's much better that the rule doesn't report (if we miss a mapping)
|
|
118
|
-
// than the rule reporting on things that can't be mapped.
|
|
119
|
-
var containsOnlyValidStyles = Object.keys(cssObject).every(function (styleProperty) {
|
|
120
|
-
var styleValue = cssObject[styleProperty];
|
|
121
|
-
return supportedStylesMap[styleProperty] &&
|
|
122
|
-
// Is the key something we can map
|
|
123
|
-
supportedStylesMap[styleProperty][styleValue] // Is the value something we can map
|
|
124
|
-
;
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
if (!containsOnlyValidStyles) {
|
|
131
|
+
if (!cssVariableValue || !isFunctionNamed(cssVariableValue, 'css')) {
|
|
128
132
|
return false;
|
|
129
133
|
}
|
|
130
|
-
return
|
|
134
|
+
return isValidCssPropertiesToTransform(cssVariableValue.node.init);
|
|
131
135
|
};
|
|
132
136
|
export default rule;
|
|
@@ -29,7 +29,14 @@ export var cssToXcssTransformer = function cssToXcssTransformer(node, context, f
|
|
|
29
29
|
var cssObjectExpression = getFunctionArgumentAtPos(cssVariableValue, 0);
|
|
30
30
|
return [
|
|
31
31
|
// Update `css` function name to `xcss`.
|
|
32
|
-
fixer.replaceText(cssVariableValue.node.init.callee, identifier('xcss').toString())].concat(_toConsumableArray(cssObjectExpression
|
|
32
|
+
fixer.replaceText(cssVariableValue.node.init.callee, identifier('xcss').toString())].concat(_toConsumableArray(styledObjectToXcssTokens(cssObjectExpression, fixer)));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Update css object values to xcss values. e.g. `'8px'` -> `'space.100'`
|
|
36
|
+
// Note: `properties` in this context is a group of AST nodes that make up a key/value pair in an object.
|
|
37
|
+
// e.g. `padding: '8px'`. For clarity, it's renamed to `entry` inside the `.map()`.
|
|
38
|
+
export var styledObjectToXcssTokens = function styledObjectToXcssTokens(styles, fixer) {
|
|
39
|
+
return styles.properties.map(function (entry) {
|
|
33
40
|
if (!isNodeOfType(entry, 'Property')) {
|
|
34
41
|
return;
|
|
35
42
|
}
|
|
@@ -44,7 +51,7 @@ export var cssToXcssTransformer = function cssToXcssTransformer(node, context, f
|
|
|
44
51
|
return;
|
|
45
52
|
}
|
|
46
53
|
return fixer.replaceText(entry.value, literal("'".concat(supportedStylesMap[entry.key.name][value], "'")).toString());
|
|
47
|
-
})
|
|
54
|
+
});
|
|
48
55
|
};
|
|
49
56
|
export var spaceTokenMap = {
|
|
50
57
|
'0px': 'space.0',
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { cssToXcssTransformer, supportedStylesMap, spaceTokenMap } from './css-to-xcss';
|
|
2
|
-
export { jsxElementToBoxTransformer } from './jsx-element-to-box';
|
|
2
|
+
export { jsxElementToBoxTransformer } from './jsx-element-to-box';
|
|
3
|
+
export { styledComponentToPrimitive } from './styled-component-to-primitive';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
3
|
+
import { updateJSXElementName, upsertImportDeclaration } from '../utils';
|
|
4
|
+
import { styledObjectToXcssTokens } from './css-to-xcss';
|
|
5
|
+
/**
|
|
6
|
+
* All required validation steps have been taken care of before this
|
|
7
|
+
* transformer is called, so it just goes ahead providing all necessary fixes
|
|
8
|
+
*/
|
|
9
|
+
export var styledComponentToPrimitive = function styledComponentToPrimitive(_ref, context) {
|
|
10
|
+
var stylesRef = _ref.stylesRef,
|
|
11
|
+
jsxRef = _ref.jsxRef;
|
|
12
|
+
return function (fixer) {
|
|
13
|
+
// generates the new variable name: MyComponent -> myComponentStyles
|
|
14
|
+
var calculatedStylesVariableName = isNodeOfType(stylesRef.id, 'Identifier') && "".concat(stylesRef.id.name.replace(stylesRef.id.name[0], stylesRef.id.name[0].toLowerCase()), "Styles");
|
|
15
|
+
if (!calculatedStylesVariableName) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
var importFixes = upsertImportDeclaration({
|
|
19
|
+
packageName: '@atlaskit/primitives',
|
|
20
|
+
specifiers: ['Box', 'xcss']
|
|
21
|
+
}, context, fixer);
|
|
22
|
+
var stylesFixes = convertStyledComponentToXcss(stylesRef, calculatedStylesVariableName, fixer);
|
|
23
|
+
var jsxFixes = convertJsxCallSite(jsxRef, calculatedStylesVariableName, fixer);
|
|
24
|
+
return [importFixes].concat(stylesFixes, jsxFixes).filter(function (fix) {
|
|
25
|
+
return Boolean(fix);
|
|
26
|
+
}); // Some of the transformers can return arrays with undefined, so filter them out
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var convertStyledComponentToXcss = function convertStyledComponentToXcss(stylesRef, newStylesVariableName, fixer) {
|
|
31
|
+
var fixes = [];
|
|
32
|
+
|
|
33
|
+
// renames the variable from MyComponent to myComponentStyles
|
|
34
|
+
fixes.push(fixer.replaceText(stylesRef.id, newStylesVariableName));
|
|
35
|
+
|
|
36
|
+
// renames the function call from styled.<tag> to xcss
|
|
37
|
+
if (stylesRef.init && isNodeOfType(stylesRef.init, 'CallExpression')) {
|
|
38
|
+
fixes.push(fixer.replaceText(stylesRef.init.callee, 'xcss'));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// converts CSS values to XCSS-compatible tokens
|
|
42
|
+
if (stylesRef.init && isNodeOfType(stylesRef.init, 'CallExpression')) {
|
|
43
|
+
var objectExpression = stylesRef.init.arguments[0];
|
|
44
|
+
if (isNodeOfType(objectExpression, 'ObjectExpression')) {
|
|
45
|
+
fixes.push.apply(fixes, _toConsumableArray(styledObjectToXcssTokens(objectExpression, fixer)));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return fixes;
|
|
49
|
+
};
|
|
50
|
+
var convertJsxCallSite = function convertJsxCallSite(jsxRef, newStylesVariableName, fixer) {
|
|
51
|
+
var fixes = [];
|
|
52
|
+
|
|
53
|
+
// renames the JSX call site
|
|
54
|
+
if (isNodeOfType(jsxRef.parent, 'JSXElement')) {
|
|
55
|
+
fixes.push.apply(fixes, _toConsumableArray(updateJSXElementName(jsxRef.parent, 'Box', fixer)));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// adds xcss prop
|
|
59
|
+
fixes.push(fixer.insertTextAfter(jsxRef.name, " xcss={".concat(newStylesVariableName, "}")));
|
|
60
|
+
return fixes;
|
|
61
|
+
};
|
|
@@ -7,6 +7,22 @@ import { isNodeOfType } from 'eslint-codemod-utils';
|
|
|
7
7
|
*/
|
|
8
8
|
export var convertASTObjectExpressionToJSObject = function convertASTObjectExpressionToJSObject(styles) {
|
|
9
9
|
var styleObj = {};
|
|
10
|
+
|
|
11
|
+
// if we see any spread props we stop and return false to indicate this is unsupported
|
|
12
|
+
if (!styles.properties.every(function (prop) {
|
|
13
|
+
return isNodeOfType(prop, 'Property');
|
|
14
|
+
})) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// TODO: We need to harden this logic.
|
|
19
|
+
// It currently generates a false positive for:
|
|
20
|
+
// styled.div({
|
|
21
|
+
// marginTop: "0px",
|
|
22
|
+
// marginBottom: token("space.100", "8px"),
|
|
23
|
+
// })
|
|
24
|
+
// as the value for `marginBottom` is not a string, so it is just skipped
|
|
25
|
+
// from the resulting map and this causes the rule to trigger when it shouldn't
|
|
10
26
|
styles.properties.forEach(function (prop) {
|
|
11
27
|
if (!isNodeOfType(prop, 'Property')) {
|
|
12
28
|
return;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Given a component name finds its JSX usages and performs some
|
|
5
|
+
* additional validations to ensure transformation can be done correctly
|
|
6
|
+
*/
|
|
7
|
+
export var findValidJsxUsageToTransform = function findValidJsxUsageToTransform(componentName, scope) {
|
|
8
|
+
var variableDeclaration = scope.variables.find(function (v) {
|
|
9
|
+
return v.name === componentName;
|
|
10
|
+
});
|
|
11
|
+
if (!variableDeclaration) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// length here should be exactly 2 to indicate only two references:
|
|
16
|
+
// one being the variable declaration itself
|
|
17
|
+
// second being the JSX call site
|
|
18
|
+
// we might consider handling multiple local JSX call sites in the future
|
|
19
|
+
// but "this is good enough for now"™️
|
|
20
|
+
if (variableDeclaration.references.length !== 2) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
var jsxUsage = variableDeclaration.references[1].identifier;
|
|
24
|
+
if (!isNodeOfType(jsxUsage, 'JSXIdentifier')) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
var jsxOpeningElement = jsxUsage.parent;
|
|
28
|
+
// we could relatively easily support some safe attributes like
|
|
29
|
+
// "id" or "testId" but support will be expanded as we go
|
|
30
|
+
if (!isNodeOfType(jsxOpeningElement, 'JSXOpeningElement') || jsxOpeningElement.attributes.length > 0) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
return jsxOpeningElement;
|
|
34
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { closestOfType, isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import { validPrimitiveElements } from './is-valid-tag-name';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* returns a variable reference if preconditions are favourable for
|
|
6
|
+
* the transformation to proceed, undefined otherwise.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export var findValidStyledComponentCall = function findValidStyledComponentCall(node) {
|
|
10
|
+
// halts unless we are dealing with a styled component
|
|
11
|
+
if (!isStyledCallExpression(node)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// halts if the component is being exported directly
|
|
15
|
+
if (closestOfType(node, 'ExportNamedDeclaration')) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
var styledComponentVariableRef = node.parent;
|
|
19
|
+
// halts if the styled component is not assigned to a variable immediately
|
|
20
|
+
if (!isNodeOfType(styledComponentVariableRef, 'VariableDeclarator')) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return styledComponentVariableRef;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Some verbose precondition checks but all it does is check
|
|
28
|
+
* a call expression is of form `styled.div` or `styled2.div`
|
|
29
|
+
*
|
|
30
|
+
* In the future it could be enhanced to double check `styled` and `styled2`
|
|
31
|
+
* are Compiled imports but as is should work for the majority of use cases
|
|
32
|
+
*/
|
|
33
|
+
var isStyledCallExpression = function isStyledCallExpression(call) {
|
|
34
|
+
if (!isNodeOfType(call, 'CallExpression')) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (!isNodeOfType(call.callee, 'MemberExpression')) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (!isNodeOfType(call.callee.object, 'Identifier') || !isNodeOfType(call.callee.property, 'Identifier')) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (/^styled2?$/.test(call.callee.object.name) && validPrimitiveElements.has(call.callee.property.name)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export { containsOnlySupportedAttrs } from './contains-only-supported-attrs';
|
|
2
2
|
export { convertASTObjectExpressionToJSObject } from './convert-ast-object-expression-to-js-object';
|
|
3
|
+
export { findValidJsxUsageToTransform } from './find-valid-jsx-usage-to-transform';
|
|
4
|
+
export { findValidStyledComponentCall } from './find-valid-styled-component-call';
|
|
3
5
|
export { getAttributeValueIdentifier } from './get-attribute-value-identifier';
|
|
4
6
|
export { getFunctionArgumentAtPos } from './get-function-argument-at-pos';
|
|
5
7
|
export { getJSXAttributeByName } from './get-jsx-attribute-by-name';
|
|
6
8
|
export { getVariableDefinitionValue } from './get-variable-definition-value';
|
|
7
9
|
export { getVariableUsagesCount } from './get-variable-usage-count';
|
|
8
10
|
export { isFunctionNamed } from './is-function-named';
|
|
11
|
+
export { isValidCssPropertiesToTransform } from './is-valid-css-properties-to-transform';
|
|
9
12
|
export { isValidTagName } from './is-valid-tag-name';
|
|
10
13
|
export { updateJSXAttributeByName } from './update-jsx-attribute-by-name';
|
|
11
14
|
export { updateJSXElementName } from './update-jsx-element-name';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import { supportedStylesMap } from '../transformers/css-to-xcss';
|
|
3
|
+
import { convertASTObjectExpressionToJSObject } from './convert-ast-object-expression-to-js-object';
|
|
4
|
+
export var isValidCssPropertiesToTransform = function isValidCssPropertiesToTransform(node) {
|
|
5
|
+
var cssObjectExpression = node.arguments[0];
|
|
6
|
+
// Bail on empty object calls
|
|
7
|
+
if (!cssObjectExpression || !isNodeOfType(cssObjectExpression, 'ObjectExpression')) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
var cssObject = convertASTObjectExpressionToJSObject(cssObjectExpression);
|
|
11
|
+
// Bail if there are less or more than 1 styles defined
|
|
12
|
+
if (!cssObject || Object.keys(cssObject).length !== 1) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// NOTE: Our approach with this lint rule is to strictly whitelist css properties we can map.
|
|
17
|
+
// It means we have to provide mappings for everything (e.g. `display: block`).
|
|
18
|
+
// However, from a maker's experience, it's much better that the rule doesn't report (if we miss a mapping)
|
|
19
|
+
// than the rule reporting on things that can't be mapped.
|
|
20
|
+
var containsOnlyValidStyles = Object.keys(cssObject).every(function (styleProperty) {
|
|
21
|
+
var styleValue = cssObject[styleProperty];
|
|
22
|
+
return supportedStylesMap[styleProperty] &&
|
|
23
|
+
// Is the key something we can map
|
|
24
|
+
supportedStylesMap[styleProperty][styleValue] // Is the value something we can map
|
|
25
|
+
;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (!containsOnlyValidStyles) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
@@ -6,5 +6,5 @@ export var updateJSXElementName = function updateJSXElementName(node, newName, f
|
|
|
6
6
|
var newClosingElement = closingElement &&
|
|
7
7
|
// Self closing tags, like `<div />` don't need to have the closing tag updated
|
|
8
8
|
fixer.replaceText(closingElement.name, jsxIdentifier(newName).toString());
|
|
9
|
-
return [newOpeningElement, newClosingElement];
|
|
9
|
+
return [newOpeningElement, newClosingElement || undefined];
|
|
10
10
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
export var getImportName = function getImportName(scope, packageName, componentName) {
|
|
3
|
+
var traversingScope = scope;
|
|
4
|
+
var matchedVariable;
|
|
5
|
+
while (traversingScope && traversingScope.type !== 'global') {
|
|
6
|
+
matchedVariable = traversingScope.variables.find(function (variable) {
|
|
7
|
+
var _variable$defs;
|
|
8
|
+
var def = (_variable$defs = variable.defs) === null || _variable$defs === void 0 ? void 0 : _variable$defs[0];
|
|
9
|
+
if (!def || !def.node || !isNodeOfType(def.node, 'ImportSpecifier') || !def.parent || !isNodeOfType(def.parent, 'ImportDeclaration')) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return def.parent.source.value === packageName && def.node.imported.name === componentName;
|
|
13
|
+
});
|
|
14
|
+
if (matchedVariable) {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
traversingScope = traversingScope.upper;
|
|
18
|
+
}
|
|
19
|
+
if (!matchedVariable) {
|
|
20
|
+
return null;
|
|
21
|
+
} else {
|
|
22
|
+
return matchedVariable.defs[0].node.local.name;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -19,6 +19,7 @@ export declare const configs: {
|
|
|
19
19
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': string;
|
|
20
20
|
'@atlaskit/design-system/prefer-primitives': string;
|
|
21
21
|
'@atlaskit/design-system/use-drawer-label': string;
|
|
22
|
+
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
22
23
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
23
24
|
'@atlaskit/design-system/use-primitives': string;
|
|
24
25
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
@@ -38,6 +39,7 @@ export declare const configs: {
|
|
|
38
39
|
'@atlaskit/design-system/no-unsafe-design-token-usage': string;
|
|
39
40
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': string;
|
|
40
41
|
'@atlaskit/design-system/use-drawer-label': string;
|
|
42
|
+
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
41
43
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
42
44
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
43
45
|
};
|
|
@@ -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::37a857efd0971ab26170d5f1f526279b>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -22,6 +22,7 @@ declare const _default: {
|
|
|
22
22
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': string;
|
|
23
23
|
'@atlaskit/design-system/prefer-primitives': string;
|
|
24
24
|
'@atlaskit/design-system/use-drawer-label': string;
|
|
25
|
+
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
25
26
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
26
27
|
'@atlaskit/design-system/use-primitives': string;
|
|
27
28
|
'@atlaskit/design-system/use-visually-hidden': 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::b3bce8efb2db1fed84370af608ca0d4c>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -17,6 +17,7 @@ declare const _default: {
|
|
|
17
17
|
'@atlaskit/design-system/no-unsafe-design-token-usage': string;
|
|
18
18
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': string;
|
|
19
19
|
'@atlaskit/design-system/use-drawer-label': string;
|
|
20
|
+
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
20
21
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
21
22
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
22
23
|
};
|
|
@@ -19,6 +19,7 @@ declare const _default: {
|
|
|
19
19
|
'no-unsupported-drag-and-drop-libraries': import("eslint").Rule.RuleModule;
|
|
20
20
|
'prefer-primitives': import("eslint").Rule.RuleModule;
|
|
21
21
|
'use-drawer-label': import("eslint").Rule.RuleModule;
|
|
22
|
+
'use-heading-level-in-spotlight-card': import("eslint").Rule.RuleModule;
|
|
22
23
|
'use-href-in-link-item': import("eslint").Rule.RuleModule;
|
|
23
24
|
'use-primitives': import("eslint").Rule.RuleModule;
|
|
24
25
|
'use-visually-hidden': import("eslint").Rule.RuleModule;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Rule, Scope } from 'eslint';
|
|
2
2
|
import { ImportDeclaration, JSXAttribute } from 'eslint-codemod-utils';
|
|
3
|
-
export declare const getLinkItemImportName: (scope: Scope.Scope) => string | null;
|
|
4
3
|
export declare const hrefHasInvalidValue: (scope: Scope.Scope, href: JSXAttribute | undefined) => boolean;
|
|
5
4
|
export declare const hasImportOfName: (node: ImportDeclaration, name: string) => boolean;
|
|
6
5
|
export declare const insertButtonItemDefaultImport: (fixer: Rule.RuleFixer, node: ImportDeclaration) => Rule.Fix;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
|
-
import { JSXElement } from 'eslint-codemod-utils';
|
|
2
|
+
import { JSXElement, ObjectExpression } from 'eslint-codemod-utils';
|
|
3
3
|
export declare const cssToXcssTransformer: (node: JSXElement, context: Rule.RuleContext, fixer: Rule.RuleFixer) => (Rule.Fix | undefined)[];
|
|
4
|
+
export declare const styledObjectToXcssTokens: (styles: ObjectExpression & Partial<Rule.NodeParentExtension>, fixer: Rule.RuleFixer) => (Rule.Fix | undefined)[];
|
|
4
5
|
export declare const spaceTokenMap: {
|
|
5
6
|
[key: string]: string;
|
|
6
7
|
};
|