@atlaskit/eslint-plugin-design-system 8.18.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/rules/use-primitives/index.js +40 -35
  3. package/dist/cjs/rules/use-primitives/transformers/css-to-xcss.js +10 -3
  4. package/dist/cjs/rules/use-primitives/transformers/index.js +8 -1
  5. package/dist/cjs/rules/use-primitives/transformers/styled-component-to-primitive.js +68 -0
  6. package/dist/cjs/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.js +16 -0
  7. package/dist/cjs/rules/use-primitives/utils/find-valid-jsx-usage-to-transform.js +39 -0
  8. package/dist/cjs/rules/use-primitives/utils/find-valid-styled-component-call.js +52 -0
  9. package/dist/cjs/rules/use-primitives/utils/index.js +21 -0
  10. package/dist/cjs/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +38 -0
  11. package/dist/cjs/rules/use-primitives/utils/is-valid-tag-name.js +2 -2
  12. package/dist/cjs/rules/use-primitives/utils/update-jsx-element-name.js +1 -1
  13. package/dist/es2019/rules/use-primitives/index.js +41 -37
  14. package/dist/es2019/rules/use-primitives/transformers/css-to-xcss.js +9 -6
  15. package/dist/es2019/rules/use-primitives/transformers/index.js +2 -1
  16. package/dist/es2019/rules/use-primitives/transformers/styled-component-to-primitive.js +59 -0
  17. package/dist/es2019/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.js +14 -0
  18. package/dist/es2019/rules/use-primitives/utils/find-valid-jsx-usage-to-transform.js +32 -0
  19. package/dist/es2019/rules/use-primitives/utils/find-valid-styled-component-call.js +47 -0
  20. package/dist/es2019/rules/use-primitives/utils/index.js +3 -0
  21. package/dist/es2019/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +32 -0
  22. package/dist/es2019/rules/use-primitives/utils/is-valid-tag-name.js +1 -1
  23. package/dist/es2019/rules/use-primitives/utils/update-jsx-element-name.js +1 -1
  24. package/dist/esm/rules/use-primitives/index.js +41 -37
  25. package/dist/esm/rules/use-primitives/transformers/css-to-xcss.js +9 -2
  26. package/dist/esm/rules/use-primitives/transformers/index.js +2 -1
  27. package/dist/esm/rules/use-primitives/transformers/styled-component-to-primitive.js +61 -0
  28. package/dist/esm/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.js +16 -0
  29. package/dist/esm/rules/use-primitives/utils/find-valid-jsx-usage-to-transform.js +34 -0
  30. package/dist/esm/rules/use-primitives/utils/find-valid-styled-component-call.js +47 -0
  31. package/dist/esm/rules/use-primitives/utils/index.js +3 -0
  32. package/dist/esm/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +32 -0
  33. package/dist/esm/rules/use-primitives/utils/is-valid-tag-name.js +1 -1
  34. package/dist/esm/rules/use-primitives/utils/update-jsx-element-name.js +1 -1
  35. package/dist/types/rules/use-primitives/transformers/css-to-xcss.d.ts +2 -1
  36. package/dist/types/rules/use-primitives/transformers/index.d.ts +1 -0
  37. package/dist/types/rules/use-primitives/transformers/styled-component-to-primitive.d.ts +13 -0
  38. package/dist/types/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.d.ts +1 -1
  39. package/dist/types/rules/use-primitives/utils/find-valid-jsx-usage-to-transform.d.ts +7 -0
  40. package/dist/types/rules/use-primitives/utils/find-valid-styled-component-call.d.ts +7 -0
  41. package/dist/types/rules/use-primitives/utils/index.d.ts +3 -0
  42. package/dist/types/rules/use-primitives/utils/is-valid-css-properties-to-transform.d.ts +3 -0
  43. package/dist/types/rules/use-primitives/utils/is-valid-tag-name.d.ts +1 -0
  44. package/dist/types/rules/use-primitives/utils/update-jsx-element-name.d.ts +1 -1
  45. package/dist/types-ts4.5/rules/use-primitives/transformers/css-to-xcss.d.ts +2 -1
  46. package/dist/types-ts4.5/rules/use-primitives/transformers/index.d.ts +1 -0
  47. package/dist/types-ts4.5/rules/use-primitives/transformers/styled-component-to-primitive.d.ts +13 -0
  48. package/dist/types-ts4.5/rules/use-primitives/utils/convert-ast-object-expression-to-js-object.d.ts +1 -1
  49. package/dist/types-ts4.5/rules/use-primitives/utils/find-valid-jsx-usage-to-transform.d.ts +7 -0
  50. package/dist/types-ts4.5/rules/use-primitives/utils/find-valid-styled-component-call.d.ts +7 -0
  51. package/dist/types-ts4.5/rules/use-primitives/utils/index.d.ts +3 -0
  52. package/dist/types-ts4.5/rules/use-primitives/utils/is-valid-css-properties-to-transform.d.ts +3 -0
  53. package/dist/types-ts4.5/rules/use-primitives/utils/is-valid-tag-name.d.ts +1 -0
  54. package/dist/types-ts4.5/rules/use-primitives/utils/update-jsx-element-name.d.ts +1 -1
  55. package/package.json +1 -1
@@ -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,3 @@
1
+ import type { Rule } from 'eslint';
2
+ import { SimpleCallExpression } from 'eslint-codemod-utils';
3
+ export declare const isValidCssPropertiesToTransform: (node: SimpleCallExpression & Rule.NodeParentExtension) => boolean;
@@ -1,2 +1,3 @@
1
1
  import { JSXElement } from 'eslint-codemod-utils';
2
+ export declare const validPrimitiveElements: Set<string>;
2
3
  export declare const isValidTagName: (node: JSXElement) => boolean;
@@ -1,3 +1,3 @@
1
1
  import type { Rule } from 'eslint';
2
2
  import { JSXElement } from 'eslint-codemod-utils';
3
- export declare const updateJSXElementName: (node: JSXElement, newName: string, fixer: Rule.RuleFixer) => (Rule.Fix | null)[];
3
+ export declare const updateJSXElementName: (node: JSXElement, newName: string, fixer: Rule.RuleFixer) => (Rule.Fix | undefined)[];
@@ -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
  };
@@ -1,2 +1,3 @@
1
1
  export { cssToXcssTransformer, supportedStylesMap, spaceTokenMap, } from './css-to-xcss';
2
2
  export { jsxElementToBoxTransformer } from './jsx-element-to-box';
3
+ export { styledComponentToPrimitive } from './styled-component-to-primitive';
@@ -0,0 +1,13 @@
1
+ import type { Rule } from 'eslint';
2
+ import { JSXOpeningElement, VariableDeclarator } from 'eslint-codemod-utils';
3
+ type StylesRef = VariableDeclarator & Rule.NodeParentExtension;
4
+ type JSXRef = JSXOpeningElement & Rule.NodeParentExtension;
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 declare const styledComponentToPrimitive: ({ stylesRef, jsxRef, }: {
10
+ stylesRef: StylesRef;
11
+ jsxRef: JSXRef;
12
+ }, context: Rule.RuleContext) => (fixer: Rule.RuleFixer) => Rule.Fix[];
13
+ export {};
@@ -6,4 +6,4 @@ export type CSSPropStyleObject = {
6
6
  /**
7
7
  * Note: Not recursive. Only handles top level key/value pairs
8
8
  */
9
- export declare const convertASTObjectExpressionToJSObject: (styles: ObjectExpression & Partial<Rule.NodeParentExtension>) => CSSPropStyleObject;
9
+ export declare const convertASTObjectExpressionToJSObject: (styles: ObjectExpression & Partial<Rule.NodeParentExtension>) => CSSPropStyleObject | false;
@@ -0,0 +1,7 @@
1
+ import type { Rule, Scope } from 'eslint';
2
+ import { JSXOpeningElement } from 'eslint-codemod-utils';
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 declare const findValidJsxUsageToTransform: (componentName: string, scope: Scope.Scope) => (JSXOpeningElement & Rule.NodeParentExtension) | undefined;
@@ -0,0 +1,7 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type VariableDeclarator } from 'eslint-codemod-utils';
3
+ /**
4
+ * returns a variable reference if preconditions are favourable for
5
+ * the transformation to proceed, undefined otherwise.
6
+ */
7
+ export declare const findValidStyledComponentCall: (node: Rule.Node) => (VariableDeclarator & Rule.NodeParentExtension) | undefined;
@@ -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,3 @@
1
+ import type { Rule } from 'eslint';
2
+ import { SimpleCallExpression } from 'eslint-codemod-utils';
3
+ export declare const isValidCssPropertiesToTransform: (node: SimpleCallExpression & Rule.NodeParentExtension) => boolean;
@@ -1,2 +1,3 @@
1
1
  import { JSXElement } from 'eslint-codemod-utils';
2
+ export declare const validPrimitiveElements: Set<string>;
2
3
  export declare const isValidTagName: (node: JSXElement) => boolean;
@@ -1,3 +1,3 @@
1
1
  import type { Rule } from 'eslint';
2
2
  import { JSXElement } from 'eslint-codemod-utils';
3
- export declare const updateJSXElementName: (node: JSXElement, newName: string, fixer: Rule.RuleFixer) => (Rule.Fix | null)[];
3
+ export declare const updateJSXElementName: (node: JSXElement, newName: string, fixer: Rule.RuleFixer) => (Rule.Fix | undefined)[];
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.18.0",
4
+ "version": "8.18.1",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org/"