@atlaskit/eslint-plugin-design-system 8.38.0 → 9.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.
Files changed (23) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/constellation/consistent-css-prop-usage/usage.mdx +3 -19
  3. package/dist/cjs/rules/consistent-css-prop-usage/index.js +53 -85
  4. package/dist/cjs/rules/use-tokens-typography/transformers/style-object.js +47 -6
  5. package/dist/cjs/rules/use-tokens-typography/utils.js +39 -3
  6. package/dist/cjs/rules/utils/is-supported-import.js +12 -3
  7. package/dist/es2019/rules/consistent-css-prop-usage/index.js +21 -48
  8. package/dist/es2019/rules/use-tokens-typography/transformers/style-object.js +49 -8
  9. package/dist/es2019/rules/use-tokens-typography/utils.js +37 -5
  10. package/dist/es2019/rules/utils/is-supported-import.js +15 -2
  11. package/dist/esm/rules/consistent-css-prop-usage/index.js +53 -85
  12. package/dist/esm/rules/use-tokens-typography/transformers/style-object.js +49 -8
  13. package/dist/esm/rules/use-tokens-typography/utils.js +37 -4
  14. package/dist/esm/rules/utils/is-supported-import.js +11 -2
  15. package/dist/types/rules/consistent-css-prop-usage/types.d.ts +1 -2
  16. package/dist/types/rules/use-tokens-typography/transformers/style-object.d.ts +4 -0
  17. package/dist/types/rules/use-tokens-typography/utils.d.ts +8 -4
  18. package/dist/types/rules/utils/is-supported-import.d.ts +5 -4
  19. package/dist/types-ts4.5/rules/consistent-css-prop-usage/types.d.ts +1 -2
  20. package/dist/types-ts4.5/rules/use-tokens-typography/transformers/style-object.d.ts +4 -0
  21. package/dist/types-ts4.5/rules/use-tokens-typography/utils.d.ts +8 -4
  22. package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +5 -4
  23. package/package.json +3 -3
@@ -1,4 +1,5 @@
1
- import { CallExpression, EslintNode, Property } from 'eslint-codemod-utils';
1
+ import type { Rule } from 'eslint';
2
+ import { CallExpression, Directive, EslintNode, ImportDeclaration, ModuleDeclaration, Property, Statement, StringableASTNode } from 'eslint-codemod-utils';
2
3
  export declare const typographyProperties: string[];
3
4
  export declare const isTypographyProperty: (propertyName: string) => boolean;
4
5
  export declare const isFontSize: (node: EslintNode) => node is CallExpression;
@@ -189,6 +190,9 @@ export declare const fontFamilyTokens: ({
189
190
  export declare function findFontFamilyValueForToken(tokenName: string): string;
190
191
  export declare function notUndefined<V>(value: V | undefined): value is V;
191
192
  export declare function isValidPropertyNode(node: Property): boolean;
192
- export declare function getTokenProperty(propertyName: string, tokenName: string, tokenFallback: string): import("eslint-codemod-utils").StringableASTNode<Property>;
193
- export declare function getLiteralProperty(propertyName: string, propertyValue: string): import("eslint-codemod-utils").StringableASTNode<Property>;
194
- export declare function convertPropertyNodeToStringableNode(node: Property): import("eslint-codemod-utils").StringableASTNode<Property>;
193
+ export declare function getTokenProperty(propertyName: string, tokenName: string, tokenFallback: string, isFallbackMember?: boolean): StringableASTNode<Property>;
194
+ export declare function getLiteralProperty(propertyName: string, propertyValue: string): StringableASTNode<Property>;
195
+ export declare function convertPropertyNodeToStringableNode(node: Property): StringableASTNode<Property>;
196
+ export declare function insertTokensImport(root: (Directive | Statement | ModuleDeclaration)[], fixer: Rule.RuleFixer): Rule.Fix;
197
+ export declare function insertFallbackImportFull(root: (Directive | Statement | ModuleDeclaration)[], fixer: Rule.RuleFixer): Rule.Fix;
198
+ export declare function insertFallbackImportSpecifier(fixer: Rule.RuleFixer, themeImportNode: ImportDeclaration): Rule.Fix | undefined;
@@ -31,7 +31,8 @@ export declare const isCxFunction: SupportedNameChecker;
31
31
  export declare const isCssMap: SupportedNameChecker;
32
32
  export declare const isKeyframes: SupportedNameChecker;
33
33
  export declare const isStyled: SupportedNameChecker;
34
- export declare const isImportedFrom: (moduleName: string, exactMatch?: boolean) => (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
34
+ export declare const isXcss: SupportedNameChecker;
35
+ export declare const isImportedFrom: (moduleName: string, exactMatch?: boolean) => (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
35
36
  /**
36
37
  * Determine if this node is specifically from a `'styled-components'` import.
37
38
  * This is because `styled-components@3.4` APIs are not consistent with Emotion and Compiled,
@@ -39,7 +40,7 @@ export declare const isImportedFrom: (moduleName: string, exactMatch?: boolean)
39
40
  *
40
41
  * This can be cleaned up when `'styled-components'` is no longer a valid ImportSource.
41
42
  */
42
- export declare const isStyledComponents: (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
43
- export declare const isCompiled: (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
44
- export declare const isEmotion: (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
43
+ export declare const isStyledComponents: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
44
+ export declare const isCompiled: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
45
+ export declare const isEmotion: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
45
46
  export {};
@@ -5,6 +5,5 @@ export type RuleConfig = {
5
5
  cssImportSource: ImportSource;
6
6
  xcssImportSource: ImportSource;
7
7
  excludeReactComponents: boolean;
8
- autoFixNames: boolean;
9
- fixNamesOnly: boolean;
8
+ autoFix: boolean;
10
9
  };
@@ -8,6 +8,8 @@ interface Refs {
8
8
  fontSizeNode: Property;
9
9
  fontSizeRaw: string | number;
10
10
  tokensImportNode: ImportDeclaration | undefined;
11
+ themeImportNode: ImportDeclaration | undefined;
12
+ shouldAddFallbackImport: 'full' | 'specifier' | false;
11
13
  }
12
14
  type Check = {
13
15
  success: boolean;
@@ -17,6 +19,8 @@ interface FixerRefs {
17
19
  matchingToken: TokenValueMap;
18
20
  nodesToReplace: Property[];
19
21
  tokensImportNode: ImportDeclaration | undefined;
22
+ themeImportNode: ImportDeclaration | undefined;
23
+ shouldAddFallbackImport: Refs['shouldAddFallbackImport'];
20
24
  fontWeightReplacement: StringableASTNode<Property> | undefined;
21
25
  fontFamilyReplacement: StringableASTNode<Property> | undefined;
22
26
  fontStyleReplacement: StringableASTNode<Property> | undefined;
@@ -1,4 +1,5 @@
1
- import { CallExpression, EslintNode, Property } from 'eslint-codemod-utils';
1
+ import type { Rule } from 'eslint';
2
+ import { CallExpression, Directive, EslintNode, ImportDeclaration, ModuleDeclaration, Property, Statement, StringableASTNode } from 'eslint-codemod-utils';
2
3
  export declare const typographyProperties: string[];
3
4
  export declare const isTypographyProperty: (propertyName: string) => boolean;
4
5
  export declare const isFontSize: (node: EslintNode) => node is CallExpression;
@@ -189,6 +190,9 @@ export declare const fontFamilyTokens: ({
189
190
  export declare function findFontFamilyValueForToken(tokenName: string): string;
190
191
  export declare function notUndefined<V>(value: V | undefined): value is V;
191
192
  export declare function isValidPropertyNode(node: Property): boolean;
192
- export declare function getTokenProperty(propertyName: string, tokenName: string, tokenFallback: string): import("eslint-codemod-utils").StringableASTNode<Property>;
193
- export declare function getLiteralProperty(propertyName: string, propertyValue: string): import("eslint-codemod-utils").StringableASTNode<Property>;
194
- export declare function convertPropertyNodeToStringableNode(node: Property): import("eslint-codemod-utils").StringableASTNode<Property>;
193
+ export declare function getTokenProperty(propertyName: string, tokenName: string, tokenFallback: string, isFallbackMember?: boolean): StringableASTNode<Property>;
194
+ export declare function getLiteralProperty(propertyName: string, propertyValue: string): StringableASTNode<Property>;
195
+ export declare function convertPropertyNodeToStringableNode(node: Property): StringableASTNode<Property>;
196
+ export declare function insertTokensImport(root: (Directive | Statement | ModuleDeclaration)[], fixer: Rule.RuleFixer): Rule.Fix;
197
+ export declare function insertFallbackImportFull(root: (Directive | Statement | ModuleDeclaration)[], fixer: Rule.RuleFixer): Rule.Fix;
198
+ export declare function insertFallbackImportSpecifier(fixer: Rule.RuleFixer, themeImportNode: ImportDeclaration): Rule.Fix | undefined;
@@ -31,7 +31,8 @@ export declare const isCxFunction: SupportedNameChecker;
31
31
  export declare const isCssMap: SupportedNameChecker;
32
32
  export declare const isKeyframes: SupportedNameChecker;
33
33
  export declare const isStyled: SupportedNameChecker;
34
- export declare const isImportedFrom: (moduleName: string, exactMatch?: boolean) => (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
34
+ export declare const isXcss: SupportedNameChecker;
35
+ export declare const isImportedFrom: (moduleName: string, exactMatch?: boolean) => (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
35
36
  /**
36
37
  * Determine if this node is specifically from a `'styled-components'` import.
37
38
  * This is because `styled-components@3.4` APIs are not consistent with Emotion and Compiled,
@@ -39,7 +40,7 @@ export declare const isImportedFrom: (moduleName: string, exactMatch?: boolean)
39
40
  *
40
41
  * This can be cleaned up when `'styled-components'` is no longer a valid ImportSource.
41
42
  */
42
- export declare const isStyledComponents: (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
43
- export declare const isCompiled: (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
44
- export declare const isEmotion: (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
43
+ export declare const isStyledComponents: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
44
+ export declare const isCompiled: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
45
+ export declare const isEmotion: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
45
46
  export {};
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.38.0",
4
+ "version": "9.1.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -48,13 +48,13 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@atlaskit/ds-lib": "^2.2.0",
51
- "@atlaskit/theme": "^12.6.0",
51
+ "@atlaskit/theme": "^12.7.0",
52
52
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
53
53
  "@atlassian/codegen": "*",
54
54
  "@atlassian/eslint-utils": "^0.4.0",
55
55
  "@emotion/react": "^11.7.1",
56
56
  "@emotion/styled": "^11.0.0",
57
- "@types/eslint": "^8.4.5",
57
+ "@types/eslint": "^8.56.6",
58
58
  "@types/estraverse": "^5.1.7",
59
59
  "eslint": "^8.49.0",
60
60
  "jscodeshift": "^0.13.0",