@atlaskit/eslint-plugin-ui-styling-standard 0.15.1 → 0.16.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 (99) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/constellation/index/migration-guide.mdx +309 -0
  3. package/constellation/index/overview.mdx +4 -0
  4. package/constellation/index/props.mdx +9 -5
  5. package/dist/cjs/rules/no-nested-selectors/index.js +68 -49
  6. package/dist/es2019/rules/no-nested-selectors/index.js +63 -45
  7. package/dist/esm/rules/no-nested-selectors/index.js +64 -49
  8. package/dist/types/rules/no-unsafe-selectors/constants.d.ts +1 -4
  9. package/index.js +9 -9
  10. package/package.json +3 -3
  11. package/scripts/codegen.tsx +223 -284
  12. package/src/rules/__tests__/utils/_tester.tsx +24 -24
  13. package/src/rules/atlaskit-theme/README.md +21 -19
  14. package/src/rules/atlaskit-theme/__tests__/test.ts +53 -53
  15. package/src/rules/atlaskit-theme/index.ts +107 -115
  16. package/src/rules/convert-props-syntax/README.md +32 -22
  17. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +46 -46
  18. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +175 -175
  19. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +52 -52
  20. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +33 -33
  21. package/src/rules/convert-props-syntax/index.tsx +356 -386
  22. package/src/rules/enforce-style-prop/README.md +21 -18
  23. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +90 -96
  24. package/src/rules/enforce-style-prop/index.tsx +144 -160
  25. package/src/rules/external-rules.tsx +163 -164
  26. package/src/rules/local-cx-xcss/README.md +10 -6
  27. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +26 -26
  28. package/src/rules/local-cx-xcss/index.tsx +46 -56
  29. package/src/rules/no-array-arguments/README.md +2 -1
  30. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +37 -46
  31. package/src/rules/no-array-arguments/index.tsx +68 -69
  32. package/src/rules/no-classname-prop/README.md +7 -4
  33. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +22 -22
  34. package/src/rules/no-classname-prop/index.tsx +25 -25
  35. package/src/rules/no-container-queries/README.md +11 -9
  36. package/src/rules/no-container-queries/__tests__/rule.test.tsx +47 -50
  37. package/src/rules/no-container-queries/index.tsx +75 -81
  38. package/src/rules/no-dynamic-styles/README.md +16 -19
  39. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +58 -67
  40. package/src/rules/no-dynamic-styles/index.tsx +45 -48
  41. package/src/rules/no-exported-styles/README.md +17 -12
  42. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +102 -111
  43. package/src/rules/no-exported-styles/index.tsx +36 -36
  44. package/src/rules/no-global-styles/README.md +15 -14
  45. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +28 -28
  46. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +37 -37
  47. package/src/rules/no-global-styles/index.tsx +59 -62
  48. package/src/rules/no-important-styles/README.md +5 -3
  49. package/src/rules/no-important-styles/__tests__/rule.test.tsx +66 -66
  50. package/src/rules/no-important-styles/index.tsx +49 -49
  51. package/src/rules/no-imported-style-values/README.md +23 -15
  52. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +123 -123
  53. package/src/rules/no-imported-style-values/index.tsx +116 -120
  54. package/src/rules/no-nested-selectors/README.md +15 -13
  55. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +186 -149
  56. package/src/rules/no-nested-selectors/index.tsx +92 -105
  57. package/src/rules/no-styled/README.md +14 -9
  58. package/src/rules/no-styled/__tests__/rule.test.tsx +31 -31
  59. package/src/rules/no-styled/index.tsx +34 -41
  60. package/src/rules/no-unsafe-selectors/README.md +103 -93
  61. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +21 -24
  62. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +44 -44
  63. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +21 -21
  64. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +57 -57
  65. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +58 -58
  66. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +85 -85
  67. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +12 -12
  68. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +23 -23
  69. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +114 -114
  70. package/src/rules/no-unsafe-selectors/constants.tsx +69 -77
  71. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +38 -38
  72. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +178 -184
  73. package/src/rules/no-unsafe-values/README.md +34 -40
  74. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +13 -13
  75. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +18 -18
  76. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +104 -104
  77. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +128 -128
  78. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +23 -23
  79. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +38 -38
  80. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +18 -18
  81. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +18 -18
  82. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +28 -28
  83. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +47 -47
  84. package/src/rules/no-unsafe-values/index.tsx +76 -78
  85. package/src/rules/no-unsafe-values/messages.tsx +12 -12
  86. package/src/rules/no-unsafe-values/utils.tsx +370 -382
  87. package/src/rules/use-compiled/README.md +11 -8
  88. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +32 -32
  89. package/src/rules/use-compiled/__tests__/css.test.tsx +53 -53
  90. package/src/rules/use-compiled/__tests__/imports.test.tsx +90 -95
  91. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +47 -47
  92. package/src/rules/use-compiled/__tests__/pragma.test.tsx +64 -64
  93. package/src/rules/use-compiled/__tests__/styled.test.tsx +53 -53
  94. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +10 -10
  95. package/src/rules/use-compiled/index.tsx +203 -226
  96. package/src/rules/use-compiled/is-safe.tsx +113 -117
  97. package/src/rules/use-compiled/utils.tsx +14 -18
  98. package/src/rules/utils/create-rule-with-typed-config.tsx +62 -63
  99. package/src/rules/utils/create-rule.tsx +3 -6
@@ -6,35 +6,35 @@ import { RuleTester } from 'eslint';
6
6
  import __noop from '@atlaskit/ds-lib/noop';
7
7
 
8
8
  (RuleTester as any).describe = (text: string, method: Function) => {
9
- const origHasAssertions = expect.hasAssertions;
10
- describe(text, () => {
11
- beforeAll(() => {
12
- // Stub out expect.hasAssertions beforeEach from jest-presetup.js
13
- expect.hasAssertions = __noop;
14
- });
15
- afterAll(() => {
16
- expect.hasAssertions = origHasAssertions;
17
- });
9
+ const origHasAssertions = expect.hasAssertions;
10
+ describe(text, () => {
11
+ beforeAll(() => {
12
+ // Stub out expect.hasAssertions beforeEach from jest-presetup.js
13
+ expect.hasAssertions = __noop;
14
+ });
15
+ afterAll(() => {
16
+ expect.hasAssertions = origHasAssertions;
17
+ });
18
18
 
19
- method();
20
- });
19
+ method();
20
+ });
21
21
  };
22
22
 
23
23
  export const typescriptEslintTester = new ESLintUtils.RuleTester({
24
- parser: '@typescript-eslint/parser',
25
- parserOptions: {
26
- ecmaVersion: 2020,
27
- sourceType: 'module',
28
- ecmaFeatures: {
29
- jsx: true,
30
- },
31
- },
24
+ parser: '@typescript-eslint/parser',
25
+ parserOptions: {
26
+ ecmaVersion: 2020,
27
+ sourceType: 'module',
28
+ ecmaFeatures: {
29
+ jsx: true,
30
+ },
31
+ },
32
32
  });
33
33
 
34
34
  export const tester = new RuleTester({
35
- parser: require.resolve('@babel/eslint-parser'),
36
- parserOptions: {
37
- ecmaVersion: 6,
38
- sourceType: 'module',
39
- },
35
+ parser: require.resolve('@babel/eslint-parser'),
36
+ parserOptions: {
37
+ ecmaVersion: 6,
38
+ sourceType: 'module',
39
+ },
40
40
  });
@@ -1,4 +1,5 @@
1
- This rule bans certain usages of `@atlaskit/theme` that `@compiled/react` is unable to compile. This includes `typography`, `elevation` and `skeletonShimmer`.
1
+ This rule bans certain usages of `@atlaskit/theme` that `@compiled/react` is unable to compile. This
2
+ includes `typography`, `elevation` and `skeletonShimmer`.
2
3
 
3
4
  ## Examples
4
5
 
@@ -13,7 +14,7 @@ import { styled } from '@compiled/react';
13
14
  import { typography } from '@atlaskit/theme';
14
15
 
15
16
  export const HeadingComponent = styled.h2`
16
- ${typography.h200()};
17
+ ${typography.h200()};
17
18
  `;
18
19
  ```
19
20
 
@@ -30,7 +31,7 @@ export const HeadingComponent = styled.h2(typography.h200());
30
31
  import { styled } from '@compiled/react';
31
32
 
32
33
  const HeadingComponent = styled.h2({
33
- fontSize: '20px',
34
+ fontSize: '20px',
34
35
  });
35
36
  ```
36
37
 
@@ -40,13 +41,13 @@ import { token } from '@atlaskit/tokens';
40
41
  import { styled } from '@compiled/react';
41
42
 
42
43
  const TitleComponent = styled.span({
43
- marginTop: token('space.150', '12px'),
44
+ marginTop: token('space.150', '12px'),
44
45
  });
45
46
 
46
47
  export const Title = (props) => (
47
- <Heading level="h200" as="h3">
48
- <TitleComponent {...props} />
49
- </Heading>
48
+ <Heading level="h200" as="h3">
49
+ <TitleComponent {...props} />
50
+ </Heading>
50
51
  );
51
52
  ```
52
53
 
@@ -61,7 +62,7 @@ import { styled } from '@compiled/react';
61
62
  import { elevation } from '@atlaskit/theme';
62
63
 
63
64
  export const ElevationComponent = styled.div`
64
- ${elevation.e100()};
65
+ ${elevation.e100()};
65
66
  `;
66
67
  ```
67
68
 
@@ -72,16 +73,17 @@ import { styled } from '@compiled/react';
72
73
  import { token } from '@atlaskit/tokens';
73
74
 
74
75
  export const TestComponent = styled.div({
75
- boxShadow: token(
76
- 'elevation.shadow.raised',
77
- '0 1px 1px rgba(9,30,66,0.25),0 0 1px 1px rgba(9,30,66,0.13)',
78
- ),
76
+ boxShadow: token(
77
+ 'elevation.shadow.raised',
78
+ '0 1px 1px rgba(9,30,66,0.25),0 0 1px 1px rgba(9,30,66,0.13)',
79
+ ),
79
80
  });
80
81
  ```
81
82
 
82
83
  ### Skeleton Shimmer
83
84
 
84
- You can preview our `@atlaskit/skeleton` (docs available to internal Atlassians only: [link](https://staging.atlassian.design/components/skeleton/examples)).
85
+ You can preview our `@atlaskit/skeleton` (docs available to internal Atlassians only:
86
+ [link](https://staging.atlassian.design/components/skeleton/examples)).
85
87
 
86
88
  Otherwise, please use an SVG skeleton or your own `@compiled/react` variant yourself.
87
89
 
@@ -92,7 +94,7 @@ import { styled } from '@compiled/react';
92
94
  import { skeletonShimmer } from '@atlaskit/theme/constants';
93
95
 
94
96
  export const SkeletonShimmerComponent = styled.div`
95
- ${skeletonShimmer};
97
+ ${skeletonShimmer};
96
98
  `;
97
99
  ```
98
100
 
@@ -100,10 +102,10 @@ export const SkeletonShimmerComponent = styled.div`
100
102
 
101
103
  ```tsx
102
104
  export const SkeletonShimmerComponent = () => {
103
- return (
104
- <Wrapper>
105
- <object data="./skeleton.svg" type="image/svg+xml"></object>
106
- </Wrapper>
107
- );
105
+ return (
106
+ <Wrapper>
107
+ <object data="./skeleton.svg" type="image/svg+xml"></object>
108
+ </Wrapper>
109
+ );
108
110
  };
109
111
  ```
@@ -3,19 +3,19 @@ import { typescriptEslintTester } from '../../__tests__/utils/_tester';
3
3
  import rule from '../index';
4
4
 
5
5
  const valid = [
6
- {
7
- name: 'Valid typography use in styled-components',
8
- code: outdent`
6
+ {
7
+ name: 'Valid typography use in styled-components',
8
+ code: outdent`
9
9
  import styled from 'styled-components';
10
10
  import { typography } from '@atlaskit/theme';
11
11
  export const HeadingComponent = styled.h2\`
12
12
  \${typography.h200()};
13
13
  \`;
14
14
  `,
15
- },
16
- {
17
- name: 'Valid typography use in compiled (fontFallback)',
18
- code: outdent`
15
+ },
16
+ {
17
+ name: 'Valid typography use in compiled (fontFallback)',
18
+ code: outdent`
19
19
  import { styled } from '@compiled/react';
20
20
  import { fontFallback } from '@atlaskit/theme/typography';
21
21
  import { token } from '@atlaskit/tokens';
@@ -23,20 +23,20 @@ const valid = [
23
23
  font: \${token('font.body', fontFallback.body.medium)}
24
24
  \`;
25
25
  `,
26
- },
27
- {
28
- name: 'Valid elevation use in styled-components',
29
- code: outdent`
26
+ },
27
+ {
28
+ name: 'Valid elevation use in styled-components',
29
+ code: outdent`
30
30
  import styled from 'styled-components';
31
31
  import { elevation } from '@atlaskit/theme';
32
32
  export const HeadingComponent = styled.h2\`
33
33
  \${elevation.e100};
34
34
  \`;
35
35
  `,
36
- },
37
- {
38
- name: 'Valid skeleton shimmer use in styled-components',
39
- code: outdent`
36
+ },
37
+ {
38
+ name: 'Valid skeleton shimmer use in styled-components',
39
+ code: outdent`
40
40
  import styled from 'styled-components';
41
41
  import { skeletonShimmer } from '@atlaskit/theme/constants';
42
42
 
@@ -44,13 +44,13 @@ const valid = [
44
44
  \${skeletonShimmer};
45
45
  \`
46
46
  `,
47
- },
47
+ },
48
48
  ];
49
49
 
50
50
  const typography = [
51
- {
52
- name: 'Invalid typography use in compiled with template expression',
53
- code: outdent`
51
+ {
52
+ name: 'Invalid typography use in compiled with template expression',
53
+ code: outdent`
54
54
  import { styled } from '@compiled/react';
55
55
  import { typography } from '@atlaskit/theme';
56
56
 
@@ -58,24 +58,24 @@ const typography = [
58
58
  \${typography.h200()};
59
59
  \`;
60
60
  `,
61
- errors: [{ messageId: 'usingTypography' }],
62
- },
63
- {
64
- name: 'Invalid typography use in compiled with function call',
65
- code: outdent`
61
+ errors: [{ messageId: 'usingTypography' }],
62
+ },
63
+ {
64
+ name: 'Invalid typography use in compiled with function call',
65
+ code: outdent`
66
66
  import { styled } from '@compiled/react';
67
67
  import { typography } from '@atlaskit/theme';
68
68
 
69
69
  export const HeadingComponent = styled.h2(typography.h200());
70
70
  `,
71
- errors: [{ messageId: 'usingTypography' }],
72
- },
71
+ errors: [{ messageId: 'usingTypography' }],
72
+ },
73
73
  ];
74
74
 
75
75
  const elevation = [
76
- {
77
- name: 'Invalid elevation use in compiled with template expression',
78
- code: outdent`
76
+ {
77
+ name: 'Invalid elevation use in compiled with template expression',
78
+ code: outdent`
79
79
  import { styled } from '@compiled/react';
80
80
  import { elevation } from '@atlaskit/theme';
81
81
 
@@ -83,24 +83,24 @@ const elevation = [
83
83
  \${elevation.e100()};
84
84
  \`;
85
85
  `,
86
- errors: [{ messageId: 'usingElevation' }],
87
- },
88
- {
89
- name: 'Invalid elevation use in compiled with function call',
90
- code: outdent`
86
+ errors: [{ messageId: 'usingElevation' }],
87
+ },
88
+ {
89
+ name: 'Invalid elevation use in compiled with function call',
90
+ code: outdent`
91
91
  import { styled } from '@compiled/react';
92
92
  import { elevation } from '@atlaskit/theme';
93
93
 
94
94
  export const ElevationComponent = styled.div(elevation.e100());
95
95
  `,
96
- errors: [{ messageId: 'usingElevation' }],
97
- },
96
+ errors: [{ messageId: 'usingElevation' }],
97
+ },
98
98
  ];
99
99
 
100
100
  const skeletonShimmer = [
101
- {
102
- name: 'Invalid skeleton shimmer use in compiled with template expression',
103
- code: outdent`
101
+ {
102
+ name: 'Invalid skeleton shimmer use in compiled with template expression',
103
+ code: outdent`
104
104
  import { styled } from '@compiled/react';
105
105
  import { skeletonShimmer } from '@atlaskit/theme/constants';
106
106
 
@@ -108,26 +108,26 @@ const skeletonShimmer = [
108
108
  \${skeletonShimmer};
109
109
  \`;
110
110
  `,
111
- errors: [{ messageId: 'usingSkeletonShimmer' }],
112
- },
113
- {
114
- name: 'Invalid skeleton shimmer use in compiled with function call',
115
- code: outdent`
111
+ errors: [{ messageId: 'usingSkeletonShimmer' }],
112
+ },
113
+ {
114
+ name: 'Invalid skeleton shimmer use in compiled with function call',
115
+ code: outdent`
116
116
  import { styled } from '@compiled/react';
117
117
  import { skeletonShimmer } from '@atlaskit/theme/constants';
118
118
 
119
119
  export const SkeletonShimmerComponent = styled.div(skeletonShimmer);
120
120
  `,
121
- errors: [{ messageId: 'usingSkeletonShimmer' }],
122
- },
121
+ errors: [{ messageId: 'usingSkeletonShimmer' }],
122
+ },
123
123
  ];
124
124
 
125
125
  typescriptEslintTester.run(
126
- 'atlaskit-theme',
127
- // @ts-expect-error
128
- rule,
129
- {
130
- valid,
131
- invalid: [...typography, ...elevation, ...skeletonShimmer],
132
- },
126
+ 'atlaskit-theme',
127
+ // @ts-expect-error
128
+ rule,
129
+ {
130
+ valid,
131
+ invalid: [...typography, ...elevation, ...skeletonShimmer],
132
+ },
133
133
  );
@@ -1,142 +1,134 @@
1
1
  import type { Rule, Scope } from 'eslint';
2
2
 
3
- import {
4
- getImportSources,
5
- isCompiled,
6
- } from '@atlaskit/eslint-utils/is-supported-import';
3
+ import { getImportSources, isCompiled } from '@atlaskit/eslint-utils/is-supported-import';
7
4
  import { createLintRule } from '../utils/create-rule';
8
5
 
9
6
  const isIdentifierReferenced = (
10
- hasImportSpecifier: (def: Scope.Definition) => boolean,
11
- node: Rule.Node,
12
- references: Scope.Reference[],
7
+ hasImportSpecifier: (def: Scope.Definition) => boolean,
8
+ node: Rule.Node,
9
+ references: Scope.Reference[],
13
10
  ): boolean =>
14
- references.some(
15
- (reference) =>
16
- reference.identifier === node &&
17
- reference.resolved?.defs.some(hasImportSpecifier),
18
- );
11
+ references.some(
12
+ (reference) =>
13
+ reference.identifier === node && reference.resolved?.defs.some(hasImportSpecifier),
14
+ );
19
15
 
20
16
  const isTypographyImportSpecifier = (def: Scope.Definition): boolean =>
21
- def.node.type === 'ImportSpecifier' &&
22
- def.node.imported.type === 'Identifier' &&
23
- def.parent?.type === 'ImportDeclaration' &&
24
- ((def.node.imported.name === 'typography' &&
25
- def.parent?.source.value === '@atlaskit/theme') ||
26
- def.parent?.source.value === '@atlaskit/theme/typography');
17
+ def.node.type === 'ImportSpecifier' &&
18
+ def.node.imported.type === 'Identifier' &&
19
+ def.parent?.type === 'ImportDeclaration' &&
20
+ ((def.node.imported.name === 'typography' && def.parent?.source.value === '@atlaskit/theme') ||
21
+ def.parent?.source.value === '@atlaskit/theme/typography');
27
22
 
28
23
  const isElevationImportSpecifier = (def: Scope.Definition): boolean =>
29
- def.node.type === 'ImportSpecifier' &&
30
- def.node.imported.type === 'Identifier' &&
31
- def.parent?.type === 'ImportDeclaration' &&
32
- ((def.node.imported.name === 'elevation' &&
33
- def.parent?.source.value === '@atlaskit/theme') ||
34
- def.parent?.source.value === '@atlaskit/theme/elevation');
24
+ def.node.type === 'ImportSpecifier' &&
25
+ def.node.imported.type === 'Identifier' &&
26
+ def.parent?.type === 'ImportDeclaration' &&
27
+ ((def.node.imported.name === 'elevation' && def.parent?.source.value === '@atlaskit/theme') ||
28
+ def.parent?.source.value === '@atlaskit/theme/elevation');
35
29
 
36
30
  const isSkeletonShimmerImportSpecifier = (def: Scope.Definition): boolean =>
37
- def.node.type === 'ImportSpecifier' &&
38
- def.node.imported.type === 'Identifier' &&
39
- def.parent?.type === 'ImportDeclaration' &&
40
- def.node.imported.name === 'skeletonShimmer' &&
41
- typeof def.parent?.source.value === 'string' &&
42
- def.parent?.source.value?.startsWith('@atlaskit/theme');
31
+ def.node.type === 'ImportSpecifier' &&
32
+ def.node.imported.type === 'Identifier' &&
33
+ def.parent?.type === 'ImportDeclaration' &&
34
+ def.node.imported.name === 'skeletonShimmer' &&
35
+ typeof def.parent?.source.value === 'string' &&
36
+ def.parent?.source.value?.startsWith('@atlaskit/theme');
43
37
 
44
38
  const checkIdentifier = (
45
- node: Rule.Node,
46
- context: Rule.RuleContext,
47
- references: Scope.Reference[],
39
+ node: Rule.Node,
40
+ context: Rule.RuleContext,
41
+ references: Scope.Reference[],
48
42
  ) => {
49
- if (isIdentifierReferenced(isTypographyImportSpecifier, node, references)) {
50
- context.report({
51
- messageId: 'usingTypography',
52
- node,
53
- });
54
- }
43
+ if (isIdentifierReferenced(isTypographyImportSpecifier, node, references)) {
44
+ context.report({
45
+ messageId: 'usingTypography',
46
+ node,
47
+ });
48
+ }
55
49
 
56
- if (isIdentifierReferenced(isElevationImportSpecifier, node, references)) {
57
- context.report({
58
- messageId: 'usingElevation',
59
- node,
60
- });
61
- }
50
+ if (isIdentifierReferenced(isElevationImportSpecifier, node, references)) {
51
+ context.report({
52
+ messageId: 'usingElevation',
53
+ node,
54
+ });
55
+ }
62
56
 
63
- if (
64
- isIdentifierReferenced(isSkeletonShimmerImportSpecifier, node, references)
65
- ) {
66
- context.report({
67
- messageId: 'usingSkeletonShimmer',
68
- node,
69
- });
70
- }
57
+ if (isIdentifierReferenced(isSkeletonShimmerImportSpecifier, node, references)) {
58
+ context.report({
59
+ messageId: 'usingSkeletonShimmer',
60
+ node,
61
+ });
62
+ }
71
63
  };
72
64
 
73
65
  export const rule = createLintRule({
74
- meta: {
75
- name: 'atlaskit-theme',
76
- docs: {
77
- description:
78
- 'Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand',
79
- recommended: true,
80
- severity: 'error',
81
- },
82
- messages: {
83
- usingTypography:
84
- 'Typography does not work with Compiled. Please utilise alternatives like Heading or tokens instead and see https://atlassian.design/components/eslint-plugin-ui-styling-standard/atlaskit-theme/usage',
85
- usingElevation:
86
- 'Elevation does not work with Compiled. Please use a token with a fallback instead and see https://atlassian.design/components/eslint-plugin-ui-styling-standard/atlaskit-theme/usage',
87
- usingSkeletonShimmer:
88
- 'Skeleton Shimmer does not work with Compiled. Please use an SVG skeleton instead and see https://atlassian.design/components/eslint-plugin-ui-styling-standard/atlaskit-theme/usage',
89
- },
90
- schema: [],
91
- type: 'problem',
92
- },
93
- create(context) {
94
- const importSources = getImportSources(context);
66
+ meta: {
67
+ name: 'atlaskit-theme',
68
+ docs: {
69
+ description:
70
+ 'Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand',
71
+ recommended: true,
72
+ severity: 'error',
73
+ },
74
+ messages: {
75
+ usingTypography:
76
+ 'Typography does not work with Compiled. Please utilise alternatives like Heading or tokens instead and see https://atlassian.design/components/eslint-plugin-ui-styling-standard/atlaskit-theme/usage',
77
+ usingElevation:
78
+ 'Elevation does not work with Compiled. Please use a token with a fallback instead and see https://atlassian.design/components/eslint-plugin-ui-styling-standard/atlaskit-theme/usage',
79
+ usingSkeletonShimmer:
80
+ 'Skeleton Shimmer does not work with Compiled. Please use an SVG skeleton instead and see https://atlassian.design/components/eslint-plugin-ui-styling-standard/atlaskit-theme/usage',
81
+ },
82
+ schema: [],
83
+ type: 'problem',
84
+ },
85
+ create(context) {
86
+ const importSources = getImportSources(context);
95
87
 
96
- return {
97
- 'CallExpression Identifier': (node: Rule.Node): void => {
98
- const { references } = context.getScope();
99
- const ancestors = context.getAncestors();
88
+ return {
89
+ 'CallExpression Identifier': (node: Rule.Node): void => {
90
+ const { references } = context.getScope();
91
+ const ancestors = context.getAncestors();
100
92
 
101
- // Check if ancestor node is a call expression to Compiled
102
- if (
103
- ancestors.some(
104
- (ancestor) =>
105
- ancestor.type === 'CallExpression' &&
106
- ancestor.callee &&
107
- isCompiled(ancestor.callee, references, importSources),
108
- )
109
- ) {
110
- // Ignore the fontFallback object as it contains strings to be used as token fallbacks
111
- if ('name' in node && node.name !== 'fontFallback') {
112
- // Check identifier for violations
113
- checkIdentifier(node, context, references);
114
- }
115
- }
116
- },
93
+ // Check if ancestor node is a call expression to Compiled
94
+ if (
95
+ ancestors.some(
96
+ (ancestor) =>
97
+ ancestor.type === 'CallExpression' &&
98
+ ancestor.callee &&
99
+ isCompiled(ancestor.callee, references, importSources),
100
+ )
101
+ ) {
102
+ // Ignore the fontFallback object as it contains strings to be used as token fallbacks
103
+ if ('name' in node && node.name !== 'fontFallback') {
104
+ // Check identifier for violations
105
+ checkIdentifier(node, context, references);
106
+ }
107
+ }
108
+ },
117
109
 
118
- 'TaggedTemplateExpression Identifier': (node: Rule.Node): void => {
119
- const { references } = context.getScope();
120
- const ancestors = context.getAncestors();
110
+ 'TaggedTemplateExpression Identifier': (node: Rule.Node): void => {
111
+ const { references } = context.getScope();
112
+ const ancestors = context.getAncestors();
121
113
 
122
- // Check if ancestor node is a tagged template expression to Compiled
123
- if (
124
- ancestors.some(
125
- (ancestor) =>
126
- ancestor.type === 'TaggedTemplateExpression' &&
127
- ancestor.tag &&
128
- isCompiled(ancestor.tag, references, importSources),
129
- )
130
- ) {
131
- // Ignore the fontFallback object as it contains strings to be used as token fallbacks
132
- if ('name' in node && node.name !== 'fontFallback') {
133
- // Check identifier for violations
134
- checkIdentifier(node, context, references);
135
- }
136
- }
137
- },
138
- };
139
- },
114
+ // Check if ancestor node is a tagged template expression to Compiled
115
+ if (
116
+ ancestors.some(
117
+ (ancestor) =>
118
+ ancestor.type === 'TaggedTemplateExpression' &&
119
+ ancestor.tag &&
120
+ isCompiled(ancestor.tag, references, importSources),
121
+ )
122
+ ) {
123
+ // Ignore the fontFallback object as it contains strings to be used as token fallbacks
124
+ if ('name' in node && node.name !== 'fontFallback') {
125
+ // Check identifier for violations
126
+ checkIdentifier(node, context, references);
127
+ }
128
+ }
129
+ },
130
+ };
131
+ },
140
132
  });
141
133
 
142
134
  export default rule;