@atlaskit/eslint-plugin-design-system 8.23.1 → 8.23.3
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 +13 -0
- package/dist/cjs/ast-nodes/function-call.js +48 -0
- package/dist/cjs/ast-nodes/import.js +49 -0
- package/dist/cjs/ast-nodes/index.js +40 -0
- package/dist/cjs/ast-nodes/jsx-attribute.js +64 -0
- package/dist/cjs/ast-nodes/jsx-element.js +55 -0
- package/dist/cjs/ast-nodes/root.js +34 -0
- package/dist/cjs/rules/consistent-css-prop-usage/index.js +25 -5
- package/dist/cjs/rules/use-primitives/index.js +8 -104
- package/dist/cjs/rules/use-primitives/transformers/compiled-styled/convert-jsx-call-site.js +39 -0
- package/dist/cjs/rules/use-primitives/transformers/compiled-styled/convert-styled-component-call-to-jsx.js +44 -0
- package/dist/cjs/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-styled-component-call.js +5 -2
- package/dist/cjs/rules/use-primitives/transformers/compiled-styled/index.js +117 -0
- package/dist/cjs/rules/use-primitives/transformers/compiled-styled/supported.js +10 -0
- package/dist/cjs/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.js +37 -0
- package/dist/cjs/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js +27 -0
- package/dist/cjs/rules/use-primitives/transformers/emotion-css/index.js +125 -0
- package/dist/cjs/rules/use-primitives/transformers/emotion-css/supported.js +10 -0
- package/dist/cjs/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.js +37 -0
- package/dist/cjs/rules/use-primitives/transformers/index.js +10 -10
- package/dist/cjs/rules/use-primitives/utils/index.js +1 -43
- package/dist/cjs/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +3 -0
- package/dist/es2019/ast-nodes/function-call.js +42 -0
- package/dist/es2019/ast-nodes/import.js +42 -0
- package/dist/es2019/ast-nodes/index.js +5 -0
- package/dist/es2019/ast-nodes/jsx-attribute.js +59 -0
- package/dist/es2019/ast-nodes/jsx-element.js +50 -0
- package/dist/es2019/ast-nodes/root.js +28 -0
- package/dist/es2019/rules/consistent-css-prop-usage/index.js +23 -5
- package/dist/es2019/rules/use-primitives/index.js +9 -105
- package/dist/es2019/rules/use-primitives/transformers/compiled-styled/convert-jsx-call-site.js +29 -0
- package/dist/es2019/rules/use-primitives/transformers/compiled-styled/convert-styled-component-call-to-jsx.js +37 -0
- package/dist/es2019/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-styled-component-call.js +2 -2
- package/dist/es2019/rules/use-primitives/transformers/compiled-styled/index.js +107 -0
- package/dist/es2019/rules/use-primitives/transformers/compiled-styled/supported.js +4 -0
- package/dist/es2019/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.js +30 -0
- package/dist/es2019/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js +19 -0
- package/dist/es2019/rules/use-primitives/transformers/emotion-css/index.js +115 -0
- package/dist/es2019/rules/use-primitives/transformers/emotion-css/supported.js +4 -0
- package/dist/es2019/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.js +30 -0
- package/dist/es2019/rules/use-primitives/transformers/index.js +2 -2
- package/dist/es2019/rules/use-primitives/utils/index.js +1 -7
- package/dist/es2019/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +3 -0
- package/dist/esm/ast-nodes/function-call.js +42 -0
- package/dist/esm/ast-nodes/import.js +43 -0
- package/dist/esm/ast-nodes/index.js +5 -0
- package/dist/esm/ast-nodes/jsx-attribute.js +59 -0
- package/dist/esm/ast-nodes/jsx-element.js +50 -0
- package/dist/esm/ast-nodes/root.js +28 -0
- package/dist/esm/rules/consistent-css-prop-usage/index.js +25 -5
- package/dist/esm/rules/use-primitives/index.js +9 -105
- package/dist/esm/rules/use-primitives/transformers/compiled-styled/convert-jsx-call-site.js +30 -0
- package/dist/esm/rules/use-primitives/transformers/compiled-styled/convert-styled-component-call-to-jsx.js +38 -0
- package/dist/esm/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-styled-component-call.js +2 -2
- package/dist/esm/rules/use-primitives/transformers/compiled-styled/index.js +107 -0
- package/dist/esm/rules/use-primitives/transformers/compiled-styled/supported.js +4 -0
- package/dist/esm/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.js +29 -0
- package/dist/esm/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js +19 -0
- package/dist/esm/rules/use-primitives/transformers/emotion-css/index.js +115 -0
- package/dist/esm/rules/use-primitives/transformers/emotion-css/supported.js +4 -0
- package/dist/esm/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.js +29 -0
- package/dist/esm/rules/use-primitives/transformers/index.js +2 -2
- package/dist/esm/rules/use-primitives/utils/index.js +1 -7
- package/dist/esm/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +3 -0
- package/dist/types/ast-nodes/function-call.d.ts +21 -0
- package/dist/types/ast-nodes/import.d.ts +16 -0
- package/dist/types/ast-nodes/index.d.ts +5 -0
- package/dist/types/ast-nodes/jsx-attribute.d.ts +26 -0
- package/dist/types/ast-nodes/jsx-element.d.ts +21 -0
- package/dist/types/ast-nodes/root.d.ts +19 -0
- package/dist/types/rules/use-primitives/transformers/compiled-styled/convert-jsx-call-site.d.ts +17 -0
- package/dist/types/rules/use-primitives/transformers/compiled-styled/convert-styled-component-call-to-jsx.d.ts +17 -0
- package/dist/types/rules/use-primitives/transformers/compiled-styled/index.d.ts +25 -0
- package/dist/types/rules/use-primitives/transformers/compiled-styled/supported.d.ts +2 -0
- package/dist/types/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.d.ts +14 -0
- package/dist/types/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.d.ts +7 -0
- package/dist/types/rules/use-primitives/transformers/emotion-css/index.d.ts +16 -0
- package/dist/types/rules/use-primitives/transformers/emotion-css/supported.d.ts +2 -0
- package/dist/types/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.d.ts +14 -0
- package/dist/types/rules/use-primitives/transformers/index.d.ts +2 -2
- package/dist/types/rules/use-primitives/utils/index.d.ts +0 -6
- package/dist/types-ts4.5/ast-nodes/function-call.d.ts +21 -0
- package/dist/types-ts4.5/ast-nodes/import.d.ts +16 -0
- package/dist/types-ts4.5/ast-nodes/index.d.ts +5 -0
- package/dist/types-ts4.5/ast-nodes/jsx-attribute.d.ts +26 -0
- package/dist/types-ts4.5/ast-nodes/jsx-element.d.ts +21 -0
- package/dist/types-ts4.5/ast-nodes/root.d.ts +19 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/convert-jsx-call-site.d.ts +17 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/convert-styled-component-call-to-jsx.d.ts +17 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/index.d.ts +25 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/supported.d.ts +2 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.d.ts +14 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.d.ts +7 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/index.d.ts +16 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/supported.d.ts +2 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.d.ts +14 -0
- package/dist/types-ts4.5/rules/use-primitives/transformers/index.d.ts +2 -2
- package/dist/types-ts4.5/rules/use-primitives/utils/index.d.ts +0 -6
- package/package.json +1 -1
- package/dist/cjs/rules/use-primitives/transformers/jsx-element-to-box.js +0 -26
- package/dist/cjs/rules/use-primitives/transformers/styled-component-to-primitive.js +0 -68
- package/dist/cjs/rules/use-primitives/utils/contains-only-supported-attrs.js +0 -19
- package/dist/cjs/rules/use-primitives/utils/is-valid-tag-name.js +0 -13
- package/dist/cjs/rules/use-primitives/utils/update-jsx-element-name.js +0 -16
- package/dist/cjs/rules/use-primitives/utils/upsert-import-declaration.js +0 -80
- package/dist/es2019/rules/use-primitives/transformers/jsx-element-to-box.js +0 -16
- package/dist/es2019/rules/use-primitives/transformers/styled-component-to-primitive.js +0 -59
- package/dist/es2019/rules/use-primitives/utils/contains-only-supported-attrs.js +0 -13
- package/dist/es2019/rules/use-primitives/utils/is-valid-tag-name.js +0 -7
- package/dist/es2019/rules/use-primitives/utils/update-jsx-element-name.js +0 -12
- package/dist/es2019/rules/use-primitives/utils/upsert-import-declaration.js +0 -76
- package/dist/esm/rules/use-primitives/transformers/jsx-element-to-box.js +0 -19
- package/dist/esm/rules/use-primitives/transformers/styled-component-to-primitive.js +0 -61
- package/dist/esm/rules/use-primitives/utils/contains-only-supported-attrs.js +0 -13
- package/dist/esm/rules/use-primitives/utils/is-valid-tag-name.js +0 -7
- package/dist/esm/rules/use-primitives/utils/update-jsx-element-name.js +0 -10
- package/dist/esm/rules/use-primitives/utils/upsert-import-declaration.js +0 -75
- package/dist/types/rules/use-primitives/transformers/jsx-element-to-box.d.ts +0 -3
- package/dist/types/rules/use-primitives/transformers/styled-component-to-primitive.d.ts +0 -13
- package/dist/types/rules/use-primitives/utils/contains-only-supported-attrs.d.ts +0 -2
- package/dist/types/rules/use-primitives/utils/is-valid-tag-name.d.ts +0 -3
- package/dist/types/rules/use-primitives/utils/update-jsx-element-name.d.ts +0 -3
- package/dist/types/rules/use-primitives/utils/upsert-import-declaration.d.ts +0 -11
- package/dist/types-ts4.5/rules/use-primitives/transformers/jsx-element-to-box.d.ts +0 -3
- package/dist/types-ts4.5/rules/use-primitives/transformers/styled-component-to-primitive.d.ts +0 -13
- package/dist/types-ts4.5/rules/use-primitives/utils/contains-only-supported-attrs.d.ts +0 -2
- package/dist/types-ts4.5/rules/use-primitives/utils/is-valid-tag-name.d.ts +0 -3
- package/dist/types-ts4.5/rules/use-primitives/utils/update-jsx-element-name.d.ts +0 -3
- package/dist/types-ts4.5/rules/use-primitives/utils/upsert-import-declaration.d.ts +0 -11
- /package/dist/cjs/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-jsx-usage-to-transform.js +0 -0
- /package/dist/es2019/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-jsx-usage-to-transform.js +0 -0
- /package/dist/esm/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-jsx-usage-to-transform.js +0 -0
- /package/dist/types/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-jsx-usage-to-transform.d.ts +0 -0
- /package/dist/types/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-styled-component-call.d.ts +0 -0
- /package/dist/types-ts4.5/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-jsx-usage-to-transform.d.ts +0 -0
- /package/dist/types-ts4.5/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-styled-component-call.d.ts +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { type ImportDeclaration } from 'eslint-codemod-utils';
|
|
3
|
+
export declare const Import: {
|
|
4
|
+
/**
|
|
5
|
+
* Note: fixes can't overlap, which means this will fail:
|
|
6
|
+
* ```
|
|
7
|
+
* const importNode = Root.findImportByModule('@atlaskit/primitives')
|
|
8
|
+
* Import.insertNamedSpecifier(importNode, 'Box')
|
|
9
|
+
* Import.insertNamedSpecifier(importNode, 'xcss')
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* For this reason `insertNamedSpecifiers` accepts a `specifiers` array, so you can group all inserts together.
|
|
13
|
+
*/
|
|
14
|
+
insertNamedSpecifiers(node: ImportDeclaration, specifiers: string[], fixer: Rule.RuleFixer): Rule.Fix | undefined;
|
|
15
|
+
containsNamedSpecifier(node: ImportDeclaration, name: string): boolean;
|
|
16
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXAttribute } from 'eslint-codemod-utils';
|
|
3
|
+
declare const HelperJSXAttribute: {
|
|
4
|
+
getName(node: JSXAttribute): string;
|
|
5
|
+
updateName(node: JSXAttribute, name: string, fixer: Rule.RuleFixer): Rule.Fix;
|
|
6
|
+
/**
|
|
7
|
+
* A JSXAttribute value can be many things:
|
|
8
|
+
* - css='myStyles'
|
|
9
|
+
* - css={myStyles}
|
|
10
|
+
* - css={[styles1, styles2]}
|
|
11
|
+
* - header={<></>}
|
|
12
|
+
* - css={styleMap.header}
|
|
13
|
+
* - css={...styles}
|
|
14
|
+
*
|
|
15
|
+
* Currently, `getValue` has only implemented strategies for when the value is a string, or an ExpressionStatement
|
|
16
|
+
* If you need additional functionality add it, and set the correct `type` on the returned object
|
|
17
|
+
*/
|
|
18
|
+
getValue(node: JSXAttribute): {
|
|
19
|
+
type: 'ExpressionStatement';
|
|
20
|
+
value: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'Literal';
|
|
23
|
+
value: string;
|
|
24
|
+
} | undefined;
|
|
25
|
+
};
|
|
26
|
+
export { HelperJSXAttribute as JSXAttribute };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXAttribute, JSXElement, JSXSpreadAttribute } from 'eslint-codemod-utils';
|
|
3
|
+
export declare const JSXElementHelper: {
|
|
4
|
+
/**
|
|
5
|
+
* Names of JSXElements can be any of:
|
|
6
|
+
* `<Component></Component>` - (JSXIdentifier)
|
|
7
|
+
* `<MyComponents.Component></MyComponents.Component>` - `MyComponents` is a namespace (JSXNamespacedName)
|
|
8
|
+
* `<MyComponents.Component></MyComponents.Component>` - `MyComponents` is an object (JSXMemberExpression)
|
|
9
|
+
*
|
|
10
|
+
* Getting the name of a JSXMemberExpression is difficult, because object can contain objects, which is recursively defined in the AST.
|
|
11
|
+
* e.g. getting the name of `<MyComponents.PresentationLayer.LeftSideBar.Header />` would require `getName` to recursively resolve all parts of the name.
|
|
12
|
+
* `getName` does not currently have this functionality. Add it if you need it.
|
|
13
|
+
*/
|
|
14
|
+
getName(node: JSXElement): string;
|
|
15
|
+
updateName(node: JSXElement, newName: string, fixer: Rule.RuleFixer): Rule.Fix[];
|
|
16
|
+
isSelfClosing(node: JSXElement): boolean;
|
|
17
|
+
getAttributes(node: JSXElement): (JSXAttribute | JSXSpreadAttribute)[];
|
|
18
|
+
getAttributeByName(node: JSXElement, name: string): JSXAttribute | undefined;
|
|
19
|
+
containsSpreadAttributes(node: JSXElement): boolean;
|
|
20
|
+
};
|
|
21
|
+
export { JSXElementHelper as JSXElement };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Rule } from 'eslint';
|
|
3
|
+
import { Directive, ImportDeclaration, insertImportDeclaration, ModuleDeclaration, Statement } from 'eslint-codemod-utils';
|
|
4
|
+
type ImportData = Parameters<typeof insertImportDeclaration>[1];
|
|
5
|
+
export declare const Root: {
|
|
6
|
+
/**
|
|
7
|
+
* Note: This can return multiple ImportDeclarations for cases like:
|
|
8
|
+
* ```
|
|
9
|
+
* import { Stack } from '@atlaskit/primitives'
|
|
10
|
+
* import type { StackProps } from '@atlaskit/primitives'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
findImportsByModule(root: (Directive | Statement | ModuleDeclaration)[], name: string): ImportDeclaration[];
|
|
14
|
+
insertImport(root: (Directive | Statement | ModuleDeclaration)[], data: {
|
|
15
|
+
module: string;
|
|
16
|
+
specifiers: ImportData;
|
|
17
|
+
}, fixer: Rule.RuleFixer): Rule.Fix;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a JSXElement from:
|
|
5
|
+
* ```
|
|
6
|
+
* <div>
|
|
7
|
+
* // ...
|
|
8
|
+
* </div>
|
|
9
|
+
* ```
|
|
10
|
+
* to
|
|
11
|
+
* ```
|
|
12
|
+
* <Box xcss={myStyles}>
|
|
13
|
+
* // ...
|
|
14
|
+
* </Box>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const convertJsxCallSite: (jsxElement: JSXElement, newStylesVariableName: string, fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { VariableDeclarator } from 'eslint-codemod-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a variable like:
|
|
5
|
+
* ```
|
|
6
|
+
* const MyComponent = styled.div({
|
|
7
|
+
* padding: '8px',
|
|
8
|
+
* })
|
|
9
|
+
* ```
|
|
10
|
+
* to
|
|
11
|
+
* ```
|
|
12
|
+
* const myComponentStyles = xcss({
|
|
13
|
+
* padding: 'space.100',
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const convertStyledComponentToXcss: (styles: VariableDeclarator, newStylesVariableName: string, fixer: Rule.RuleFixer) => (Rule.Fix | undefined)[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement, VariableDeclarator } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../../config';
|
|
4
|
+
interface MetaData {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
}
|
|
8
|
+
interface Refs {
|
|
9
|
+
styles: VariableDeclarator;
|
|
10
|
+
jsxElement: JSXElement;
|
|
11
|
+
}
|
|
12
|
+
type Check = {
|
|
13
|
+
success: boolean;
|
|
14
|
+
refs?: Refs;
|
|
15
|
+
};
|
|
16
|
+
export declare const CompiledStyled: {
|
|
17
|
+
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
18
|
+
_check(node: Rule.Node, { context, config }: MetaData): Check;
|
|
19
|
+
/**
|
|
20
|
+
* All required validation steps have been taken care of before this
|
|
21
|
+
* transformer is called, so it just goes ahead providing all necessary fixes
|
|
22
|
+
*/
|
|
23
|
+
_fix(refs: Refs, context: Rule.RuleContext): (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* Currently this is defined here because it's not very general purpose.
|
|
4
|
+
* If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
|
|
5
|
+
* and the other half would be in `Import`.
|
|
6
|
+
*
|
|
7
|
+
* TODO: Refactor and move to `ast-nodes`
|
|
8
|
+
*
|
|
9
|
+
* Note: It does not handle default imports, namespace imports, or aliased imports.
|
|
10
|
+
*/
|
|
11
|
+
export declare const upsertImportDeclaration: ({ module, specifiers, }: {
|
|
12
|
+
module: string;
|
|
13
|
+
specifiers: string[];
|
|
14
|
+
}, context: Rule.RuleContext, fixer: Rule.RuleFixer) => Rule.Fix | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Check that every attribute in the JSXElement is something we support.
|
|
4
|
+
* We do this via a whitelist in `this.attributes`. The result is we exclude
|
|
5
|
+
* dangerous attrs like `id` and `style`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const containsOnlySupportedAttrs: (node: JSXElement) => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../../config';
|
|
4
|
+
interface MetaData {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
}
|
|
8
|
+
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
9
|
+
export declare const EmotionCSS: {
|
|
10
|
+
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
|
+
_check(node: Rule.Node, { context, config }: MetaData): boolean;
|
|
12
|
+
_fix(node: JSXElement, { context }: {
|
|
13
|
+
context: Rule.RuleContext;
|
|
14
|
+
}): FixFunction;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* Currently this is defined here because it's not very general purpose.
|
|
4
|
+
* If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
|
|
5
|
+
* and the other half would be in `Import`.
|
|
6
|
+
*
|
|
7
|
+
* TODO: Refactor and move to `ast-nodes`
|
|
8
|
+
*
|
|
9
|
+
* Note: It does not handle default imports, namespace imports, or aliased imports.
|
|
10
|
+
*/
|
|
11
|
+
export declare const upsertImportDeclaration: ({ module, specifiers, }: {
|
|
12
|
+
module: string;
|
|
13
|
+
specifiers: string[];
|
|
14
|
+
}, context: Rule.RuleContext, fixer: Rule.RuleFixer) => Rule.Fix | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { cssToXcssTransformer, supportedStylesMap, spaceTokenMap, } from './css-to-xcss';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { CompiledStyled } from './compiled-styled';
|
|
3
|
+
export { EmotionCSS } from './emotion-css';
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export { containsOnlySupportedAttrs } from './contains-only-supported-attrs';
|
|
2
1
|
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';
|
|
5
2
|
export { getAttributeValueIdentifier } from './get-attribute-value-identifier';
|
|
6
3
|
export { getFunctionArgumentAtPos } from './get-function-argument-at-pos';
|
|
7
4
|
export { getJSXAttributeByName } from './get-jsx-attribute-by-name';
|
|
@@ -9,7 +6,4 @@ export { getVariableDefinitionValue } from './get-variable-definition-value';
|
|
|
9
6
|
export { getVariableUsagesCount } from './get-variable-usage-count';
|
|
10
7
|
export { isFunctionNamed } from './is-function-named';
|
|
11
8
|
export { isValidCssPropertiesToTransform } from './is-valid-css-properties-to-transform';
|
|
12
|
-
export { isValidTagName } from './is-valid-tag-name';
|
|
13
9
|
export { updateJSXAttributeByName } from './update-jsx-attribute-by-name';
|
|
14
|
-
export { updateJSXElementName } from './update-jsx-element-name';
|
|
15
|
-
export { upsertImportDeclaration } from './upsert-import-declaration';
|
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.23.
|
|
4
|
+
"version": "8.23.3",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.jsxElementToBoxTransformer = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _utils = require("../utils");
|
|
10
|
-
var _cssToXcss = require("./css-to-xcss");
|
|
11
|
-
var jsxElementToBoxTransformer = exports.jsxElementToBoxTransformer = function jsxElementToBoxTransformer(node, context) {
|
|
12
|
-
return function (fixer) {
|
|
13
|
-
// Insert `import { Box, xcss } from '@atlaskit/primitives'`
|
|
14
|
-
// Or, if the import exists already, update it to include `Box`, and `xcss`
|
|
15
|
-
var importFixes = (0, _utils.upsertImportDeclaration)({
|
|
16
|
-
packageName: '@atlaskit/primitives',
|
|
17
|
-
specifiers: ['Box', 'xcss']
|
|
18
|
-
}, context, fixer);
|
|
19
|
-
var elementNameFixes = (0, _utils.updateJSXElementName)(node, 'Box', fixer);
|
|
20
|
-
var attributeFix = (0, _utils.updateJSXAttributeByName)('css', 'xcss', node, fixer);
|
|
21
|
-
var cssToXcssTransform = (0, _cssToXcss.cssToXcssTransformer)(node, context, fixer);
|
|
22
|
-
return [importFixes, attributeFix].concat((0, _toConsumableArray2.default)(elementNameFixes), (0, _toConsumableArray2.default)(cssToXcssTransform)).filter(function (fix) {
|
|
23
|
-
return Boolean(fix);
|
|
24
|
-
}); // Some of the transformers can return arrays with undefined, so filter them out
|
|
25
|
-
};
|
|
26
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.styledComponentToPrimitive = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
10
|
-
var _utils = require("../utils");
|
|
11
|
-
var _cssToXcss = require("./css-to-xcss");
|
|
12
|
-
/**
|
|
13
|
-
* All required validation steps have been taken care of before this
|
|
14
|
-
* transformer is called, so it just goes ahead providing all necessary fixes
|
|
15
|
-
*/
|
|
16
|
-
var styledComponentToPrimitive = exports.styledComponentToPrimitive = function styledComponentToPrimitive(_ref, context) {
|
|
17
|
-
var stylesRef = _ref.stylesRef,
|
|
18
|
-
jsxRef = _ref.jsxRef;
|
|
19
|
-
return function (fixer) {
|
|
20
|
-
// generates the new variable name: MyComponent -> myComponentStyles
|
|
21
|
-
var calculatedStylesVariableName = (0, _eslintCodemodUtils.isNodeOfType)(stylesRef.id, 'Identifier') && "".concat(stylesRef.id.name.replace(stylesRef.id.name[0], stylesRef.id.name[0].toLowerCase()), "Styles");
|
|
22
|
-
if (!calculatedStylesVariableName) {
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
var importFixes = (0, _utils.upsertImportDeclaration)({
|
|
26
|
-
packageName: '@atlaskit/primitives',
|
|
27
|
-
specifiers: ['Box', 'xcss']
|
|
28
|
-
}, context, fixer);
|
|
29
|
-
var stylesFixes = convertStyledComponentToXcss(stylesRef, calculatedStylesVariableName, fixer);
|
|
30
|
-
var jsxFixes = convertJsxCallSite(jsxRef, calculatedStylesVariableName, fixer);
|
|
31
|
-
return [importFixes].concat(stylesFixes, jsxFixes).filter(function (fix) {
|
|
32
|
-
return Boolean(fix);
|
|
33
|
-
}); // Some of the transformers can return arrays with undefined, so filter them out
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
var convertStyledComponentToXcss = function convertStyledComponentToXcss(stylesRef, newStylesVariableName, fixer) {
|
|
38
|
-
var fixes = [];
|
|
39
|
-
|
|
40
|
-
// renames the variable from MyComponent to myComponentStyles
|
|
41
|
-
fixes.push(fixer.replaceText(stylesRef.id, newStylesVariableName));
|
|
42
|
-
|
|
43
|
-
// renames the function call from styled.<tag> to xcss
|
|
44
|
-
if (stylesRef.init && (0, _eslintCodemodUtils.isNodeOfType)(stylesRef.init, 'CallExpression')) {
|
|
45
|
-
fixes.push(fixer.replaceText(stylesRef.init.callee, 'xcss'));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// converts CSS values to XCSS-compatible tokens
|
|
49
|
-
if (stylesRef.init && (0, _eslintCodemodUtils.isNodeOfType)(stylesRef.init, 'CallExpression')) {
|
|
50
|
-
var objectExpression = stylesRef.init.arguments[0];
|
|
51
|
-
if ((0, _eslintCodemodUtils.isNodeOfType)(objectExpression, 'ObjectExpression')) {
|
|
52
|
-
fixes.push.apply(fixes, (0, _toConsumableArray2.default)((0, _cssToXcss.styledObjectToXcssTokens)(objectExpression, fixer)));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return fixes;
|
|
56
|
-
};
|
|
57
|
-
var convertJsxCallSite = function convertJsxCallSite(jsxRef, newStylesVariableName, fixer) {
|
|
58
|
-
var fixes = [];
|
|
59
|
-
|
|
60
|
-
// renames the JSX call site
|
|
61
|
-
if ((0, _eslintCodemodUtils.isNodeOfType)(jsxRef.parent, 'JSXElement')) {
|
|
62
|
-
fixes.push.apply(fixes, (0, _toConsumableArray2.default)((0, _utils.updateJSXElementName)(jsxRef.parent, 'Box', fixer)));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// adds xcss prop
|
|
66
|
-
fixes.push(fixer.insertTextAfter(jsxRef.name, " xcss={".concat(newStylesVariableName, "}")));
|
|
67
|
-
return fixes;
|
|
68
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.containsOnlySupportedAttrs = void 0;
|
|
7
|
-
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
-
var supportedAttributes = ['css'];
|
|
9
|
-
var containsOnlySupportedAttrs = exports.containsOnlySupportedAttrs = function containsOnlySupportedAttrs(node) {
|
|
10
|
-
return node.openingElement.attributes.every(function (attr) {
|
|
11
|
-
if (!(0, _eslintCodemodUtils.isNodeOfType)(attr, 'JSXAttribute')) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
if (!(0, _eslintCodemodUtils.isNodeOfType)(attr.name, 'JSXIdentifier')) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
return supportedAttributes.includes(attr.name.name);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.validPrimitiveElements = exports.isValidTagName = void 0;
|
|
7
|
-
var validPrimitiveElements = exports.validPrimitiveElements = new Set(['div']);
|
|
8
|
-
var isValidTagName = exports.isValidTagName = function isValidTagName(node) {
|
|
9
|
-
if (node.openingElement.name.type !== 'JSXIdentifier') {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return validPrimitiveElements.has(node.openingElement.name.name);
|
|
13
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.updateJSXElementName = void 0;
|
|
7
|
-
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
-
var updateJSXElementName = exports.updateJSXElementName = function updateJSXElementName(node, newName, fixer) {
|
|
9
|
-
var openingElement = node.openingElement,
|
|
10
|
-
closingElement = node.closingElement;
|
|
11
|
-
var newOpeningElement = fixer.replaceText(openingElement.name, (0, _eslintCodemodUtils.jsxIdentifier)(newName).toString());
|
|
12
|
-
var newClosingElement = closingElement &&
|
|
13
|
-
// Self closing tags, like `<div />` don't need to have the closing tag updated
|
|
14
|
-
fixer.replaceText(closingElement.name, (0, _eslintCodemodUtils.jsxIdentifier)(newName).toString());
|
|
15
|
-
return [newOpeningElement, newClosingElement || undefined];
|
|
16
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.upsertImportDeclaration = void 0;
|
|
7
|
-
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
-
/**
|
|
9
|
-
* Note: Very naive implementation. Does not handle default imports, namespace imports, or aliased imports.
|
|
10
|
-
* Add that functionality when needed.
|
|
11
|
-
*
|
|
12
|
-
* However, does handle duplicate identifiers.
|
|
13
|
-
*/
|
|
14
|
-
var upsertImportDeclaration = exports.upsertImportDeclaration = function upsertImportDeclaration(_ref, context, fixer) {
|
|
15
|
-
var packageName = _ref.packageName,
|
|
16
|
-
specifiers = _ref.specifiers;
|
|
17
|
-
// Find any imports that match the packageName
|
|
18
|
-
var body = context.getSourceCode().ast.body;
|
|
19
|
-
var existingImports = body.filter(function (node) {
|
|
20
|
-
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'ImportDeclaration')) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
if (!(0, _eslintCodemodUtils.hasImportDeclaration)(node, packageName)) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* This can happen for cases like:
|
|
31
|
-
* ```
|
|
32
|
-
* import { Stack } from '@atlaskit/primitives'
|
|
33
|
-
* import type { StackProps } from '@atlaskit/primitives'
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* Ignore these cases for now to reduce scope creep
|
|
37
|
-
*
|
|
38
|
-
* TODO: Support multiple imports
|
|
39
|
-
*/
|
|
40
|
-
if (existingImports.length > 1) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// The import doesn't exist yet, we can just insert a whole new one
|
|
45
|
-
if (existingImports.length === 0) {
|
|
46
|
-
return fixer.insertTextBefore(body[0], "".concat((0, _eslintCodemodUtils.insertImportDeclaration)(packageName, specifiers), ";\n"));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// The import exists so, modify the existing one
|
|
50
|
-
var existingImport = existingImports[0]; // We have already validated that only one exists
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* `insertImportSpecifier()` has the unfortunate implementation detail of naively adding duplicate specifiers.
|
|
54
|
-
* e.g. calling
|
|
55
|
-
* `insertImportSpecifier(importDecl, 'xcss')`
|
|
56
|
-
* on
|
|
57
|
-
* `import { Inline, xcss } from '@atlaskit/primitives'`
|
|
58
|
-
* will result in:
|
|
59
|
-
* `import { Inline, xcss, xcss } from '@atlaskit/primitives'`.
|
|
60
|
-
* So, we need to filter out specifiers that are already imported.
|
|
61
|
-
*/
|
|
62
|
-
var uniqueImportSpecifiers = specifiers.filter(function (specifier) {
|
|
63
|
-
return !existingImport.specifiers.find(function (existingSpecifier) {
|
|
64
|
-
if (existingSpecifier.type !== 'ImportSpecifier') {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return existingSpecifier.imported.name === specifier;
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Ensures the import doesn't end up like: `import { Box, xcss, } from '@atlaskit/primitives';`
|
|
72
|
-
// which can happen if the import decl already contains all import specifiers
|
|
73
|
-
if (uniqueImportSpecifiers.length === 0) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
return fixer.replaceText(existingImport, "".concat((0, _eslintCodemodUtils.insertImportSpecifier)(existingImport,
|
|
77
|
-
// `insertImportSpecifier` only accepts one specifier, and we can't call it multiple times on the same import, because fixes can't overlap
|
|
78
|
-
// So, join the array into a string literal, and hope for the best 🤞
|
|
79
|
-
uniqueImportSpecifiers.join(', ')), ";\n"));
|
|
80
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { updateJSXAttributeByName, updateJSXElementName, upsertImportDeclaration } from '../utils';
|
|
2
|
-
import { cssToXcssTransformer } from './css-to-xcss';
|
|
3
|
-
export const jsxElementToBoxTransformer = (node, context) => {
|
|
4
|
-
return fixer => {
|
|
5
|
-
// Insert `import { Box, xcss } from '@atlaskit/primitives'`
|
|
6
|
-
// Or, if the import exists already, update it to include `Box`, and `xcss`
|
|
7
|
-
const importFixes = upsertImportDeclaration({
|
|
8
|
-
packageName: '@atlaskit/primitives',
|
|
9
|
-
specifiers: ['Box', 'xcss']
|
|
10
|
-
}, context, fixer);
|
|
11
|
-
const elementNameFixes = updateJSXElementName(node, 'Box', fixer);
|
|
12
|
-
const attributeFix = updateJSXAttributeByName('css', 'xcss', node, fixer);
|
|
13
|
-
const cssToXcssTransform = cssToXcssTransformer(node, context, fixer);
|
|
14
|
-
return [importFixes, attributeFix, ...elementNameFixes, ...cssToXcssTransform].filter(fix => Boolean(fix)); // Some of the transformers can return arrays with undefined, so filter them out
|
|
15
|
-
};
|
|
16
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
import { updateJSXElementName, upsertImportDeclaration } from '../utils';
|
|
3
|
-
import { styledObjectToXcssTokens } from './css-to-xcss';
|
|
4
|
-
/**
|
|
5
|
-
* All required validation steps have been taken care of before this
|
|
6
|
-
* transformer is called, so it just goes ahead providing all necessary fixes
|
|
7
|
-
*/
|
|
8
|
-
export const styledComponentToPrimitive = ({
|
|
9
|
-
stylesRef,
|
|
10
|
-
jsxRef
|
|
11
|
-
}, context) => {
|
|
12
|
-
return fixer => {
|
|
13
|
-
// generates the new variable name: MyComponent -> myComponentStyles
|
|
14
|
-
const calculatedStylesVariableName = isNodeOfType(stylesRef.id, 'Identifier') && `${stylesRef.id.name.replace(stylesRef.id.name[0], stylesRef.id.name[0].toLowerCase())}Styles`;
|
|
15
|
-
if (!calculatedStylesVariableName) {
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
const importFixes = upsertImportDeclaration({
|
|
19
|
-
packageName: '@atlaskit/primitives',
|
|
20
|
-
specifiers: ['Box', 'xcss']
|
|
21
|
-
}, context, fixer);
|
|
22
|
-
const stylesFixes = convertStyledComponentToXcss(stylesRef, calculatedStylesVariableName, fixer);
|
|
23
|
-
const jsxFixes = convertJsxCallSite(jsxRef, calculatedStylesVariableName, fixer);
|
|
24
|
-
return [importFixes, ...stylesFixes, ...jsxFixes].filter(fix => Boolean(fix)); // Some of the transformers can return arrays with undefined, so filter them out
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const convertStyledComponentToXcss = (stylesRef, newStylesVariableName, fixer) => {
|
|
29
|
-
const fixes = [];
|
|
30
|
-
|
|
31
|
-
// renames the variable from MyComponent to myComponentStyles
|
|
32
|
-
fixes.push(fixer.replaceText(stylesRef.id, newStylesVariableName));
|
|
33
|
-
|
|
34
|
-
// renames the function call from styled.<tag> to xcss
|
|
35
|
-
if (stylesRef.init && isNodeOfType(stylesRef.init, 'CallExpression')) {
|
|
36
|
-
fixes.push(fixer.replaceText(stylesRef.init.callee, 'xcss'));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// converts CSS values to XCSS-compatible tokens
|
|
40
|
-
if (stylesRef.init && isNodeOfType(stylesRef.init, 'CallExpression')) {
|
|
41
|
-
const objectExpression = stylesRef.init.arguments[0];
|
|
42
|
-
if (isNodeOfType(objectExpression, 'ObjectExpression')) {
|
|
43
|
-
fixes.push(...styledObjectToXcssTokens(objectExpression, fixer));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return fixes;
|
|
47
|
-
};
|
|
48
|
-
const convertJsxCallSite = (jsxRef, newStylesVariableName, fixer) => {
|
|
49
|
-
const fixes = [];
|
|
50
|
-
|
|
51
|
-
// renames the JSX call site
|
|
52
|
-
if (isNodeOfType(jsxRef.parent, 'JSXElement')) {
|
|
53
|
-
fixes.push(...updateJSXElementName(jsxRef.parent, 'Box', fixer));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// adds xcss prop
|
|
57
|
-
fixes.push(fixer.insertTextAfter(jsxRef.name, ` xcss={${newStylesVariableName}}`));
|
|
58
|
-
return fixes;
|
|
59
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
const supportedAttributes = ['css'];
|
|
3
|
-
export const containsOnlySupportedAttrs = node => {
|
|
4
|
-
return node.openingElement.attributes.every(attr => {
|
|
5
|
-
if (!isNodeOfType(attr, 'JSXAttribute')) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
if (!isNodeOfType(attr.name, 'JSXIdentifier')) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
return supportedAttributes.includes(attr.name.name);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsxIdentifier } from 'eslint-codemod-utils';
|
|
2
|
-
export const updateJSXElementName = (node, newName, fixer) => {
|
|
3
|
-
const {
|
|
4
|
-
openingElement,
|
|
5
|
-
closingElement
|
|
6
|
-
} = node;
|
|
7
|
-
const newOpeningElement = fixer.replaceText(openingElement.name, jsxIdentifier(newName).toString());
|
|
8
|
-
const newClosingElement = closingElement &&
|
|
9
|
-
// Self closing tags, like `<div />` don't need to have the closing tag updated
|
|
10
|
-
fixer.replaceText(closingElement.name, jsxIdentifier(newName).toString());
|
|
11
|
-
return [newOpeningElement, newClosingElement || undefined];
|
|
12
|
-
};
|