@atlaskit/eslint-plugin-ui-styling-standard 0.11.5 → 0.11.6

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 (49) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +10 -7
  3. package/constellation/atlaskit-theme/usage.mdx +113 -0
  4. package/constellation/convert-props-syntax/usage.mdx +32 -22
  5. package/constellation/enforce-style-prop/usage.mdx +21 -18
  6. package/constellation/index/overview.mdx +91 -76
  7. package/constellation/local-cx-xcss/usage.mdx +10 -6
  8. package/constellation/no-array-arguments/usage.mdx +10 -9
  9. package/constellation/no-classname-prop/usage.mdx +7 -4
  10. package/constellation/no-container-queries/usage.mdx +17 -15
  11. package/constellation/no-dynamic-styles/usage.mdx +26 -29
  12. package/constellation/no-exported-styles/usage.mdx +23 -18
  13. package/constellation/no-important-styles/usage.mdx +5 -3
  14. package/constellation/no-imported-style-values/usage.mdx +30 -22
  15. package/constellation/no-nested-selectors/usage.mdx +22 -20
  16. package/constellation/no-unsafe-values/usage.mdx +45 -51
  17. package/dist/cjs/index.codegen.js +1 -1
  18. package/dist/cjs/presets/all.codegen.js +2 -1
  19. package/dist/cjs/presets/recommended.codegen.js +2 -1
  20. package/dist/cjs/rules/atlaskit-theme/index.js +95 -0
  21. package/dist/cjs/rules/index.codegen.js +3 -1
  22. package/dist/es2019/index.codegen.js +1 -1
  23. package/dist/es2019/presets/all.codegen.js +2 -1
  24. package/dist/es2019/presets/recommended.codegen.js +2 -1
  25. package/dist/es2019/rules/atlaskit-theme/index.js +85 -0
  26. package/dist/es2019/rules/index.codegen.js +3 -1
  27. package/dist/esm/index.codegen.js +1 -1
  28. package/dist/esm/presets/all.codegen.js +2 -1
  29. package/dist/esm/presets/recommended.codegen.js +2 -1
  30. package/dist/esm/rules/atlaskit-theme/index.js +89 -0
  31. package/dist/esm/rules/index.codegen.js +3 -1
  32. package/dist/types/index.codegen.d.ts +2 -0
  33. package/dist/types/presets/all.codegen.d.ts +2 -1
  34. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  35. package/dist/types/rules/atlaskit-theme/index.d.ts +3 -0
  36. package/dist/types/rules/index.codegen.d.ts +1 -0
  37. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  38. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  39. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  40. package/dist/types-ts4.5/rules/atlaskit-theme/index.d.ts +3 -0
  41. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  42. package/package.json +2 -2
  43. package/src/index.codegen.tsx +3 -3
  44. package/src/presets/all.codegen.tsx +66 -69
  45. package/src/presets/recommended.codegen.tsx +66 -69
  46. package/src/rules/atlaskit-theme/README.md +109 -0
  47. package/src/rules/atlaskit-theme/__tests__/test.ts +122 -0
  48. package/src/rules/atlaskit-theme/index.ts +136 -0
  49. package/src/rules/index.codegen.tsx +15 -13
@@ -8,14 +8,14 @@ This rule prevents the usage of styles that are difficult/impossible to statical
8
8
 
9
9
  **Function calls**
10
10
 
11
- Function calls are not allowed as arguments or as values,
12
- unless they are specified in `allowedFunctionCalls` (or in the default list).
11
+ Function calls are not allowed as arguments or as values, unless they are specified in
12
+ `allowedFunctionCalls` (or in the default list).
13
13
 
14
14
  ```tsx
15
15
  import { css } from '@compiled/react';
16
16
 
17
17
  function getStyles() {
18
- return { width: 100 };
18
+ return { width: 100 };
19
19
  }
20
20
 
21
21
  const styles = css(getStyles());
@@ -25,30 +25,30 @@ const styles = css(getStyles());
25
25
  import { css } from '@compiled/react';
26
26
 
27
27
  function getWidth() {
28
- return 100;
28
+ return 100;
29
29
  }
30
30
 
31
31
  const styles = css({
32
- width: getWidth(),
32
+ width: getWidth(),
33
33
  });
34
34
  ```
35
35
 
36
36
  **Dynamic keys**
37
37
 
38
- Dynamic keys are not allowed,
39
- unless they are specified in `allowedDynamicKeys` (or in the default list).
38
+ Dynamic keys are not allowed, unless they are specified in `allowedDynamicKeys` (or in the default
39
+ list).
40
40
 
41
41
  ```tsx
42
42
  import { css } from '@compiled/react';
43
43
  import { SELECTOR } from 'my-package';
44
44
 
45
45
  const styles = css({
46
- [SELECTOR]: {
47
- color: 'red',
48
- },
49
- [`${SELECTOR} > p`]: {
50
- width: 100,
51
- },
46
+ [SELECTOR]: {
47
+ color: 'red',
48
+ },
49
+ [`${SELECTOR} > p`]: {
50
+ width: 100,
51
+ },
52
52
  });
53
53
  ```
54
54
 
@@ -56,19 +56,19 @@ const styles = css({
56
56
 
57
57
  Variables are not allowed as values, unless they:
58
58
 
59
- - Have a simple, static value
60
- - Are defined in the same file
59
+ - Have a simple, static value
60
+ - Are defined in the same file
61
61
 
62
62
  ```tsx
63
63
  import { css } from '@compiled/react';
64
64
  import { SELECTOR } from 'my-package';
65
65
 
66
66
  function myFunction() {
67
- return '5px';
67
+ return '5px';
68
68
  }
69
69
 
70
70
  const styles = css({
71
- height: myFunction,
71
+ height: myFunction,
72
72
  });
73
73
  ```
74
74
 
@@ -81,11 +81,11 @@ import { css } from '@compiled/react';
81
81
  import { token } from '@atlaskit/tokens';
82
82
 
83
83
  const colors = {
84
- text: token('color.text'),
84
+ text: token('color.text'),
85
85
  };
86
86
 
87
87
  const styles = css({
88
- color: colors.text,
88
+ color: colors.text,
89
89
  });
90
90
  ```
91
91
 
@@ -97,24 +97,23 @@ Spread elements are not allowed.
97
97
  import { css } from '@compiled/react';
98
98
 
99
99
  const buttonStyles = {
100
- color: 'blue',
100
+ color: 'blue',
101
101
  };
102
102
 
103
103
  const styles = css({
104
- ...buttonStyles,
104
+ ...buttonStyles,
105
105
  });
106
106
  ```
107
107
 
108
108
  **Array values**
109
109
 
110
- Array values are not allowed.
111
- This syntax is not supported by most styling libraries.
110
+ Array values are not allowed. This syntax is not supported by most styling libraries.
112
111
 
113
112
  ```tsx
114
113
  import { css } from '@compiled/react';
115
114
 
116
115
  const styles = css({
117
- '::before': [{ fontWeight: 'bold' }, { color: 'red' }],
116
+ '::before': [{ fontWeight: 'bold' }, { color: 'red' }],
118
117
  });
119
118
  ```
120
119
 
@@ -122,33 +121,26 @@ const styles = css({
122
121
 
123
122
  Things to note about the following example:
124
123
 
125
- - The `warningStyles` are conditionally applied using the `css` prop
126
- - The dynamic `width` is applied using the `style` prop
127
- - The `token()` calls are allowed because they are statically analyzable (and in the default allow-list)
124
+ - The `warningStyles` are conditionally applied using the `css` prop
125
+ - The dynamic `width` is applied using the `style` prop
126
+ - The `token()` calls are allowed because they are statically analyzable (and in the default
127
+ allow-list)
128
128
 
129
129
  ```tsx
130
130
  import { css } from '@compiled/react';
131
131
  import { token } from '@atlaskit/tokens';
132
132
 
133
133
  const baseStyles = css({
134
- height: 100,
134
+ height: 100,
135
135
  });
136
136
 
137
137
  const warningStyles = css({
138
- color: token('color.text.warning'),
139
- backgroundColor: token('color.background.warning'),
138
+ color: token('color.text.warning'),
139
+ backgroundColor: token('color.background.warning'),
140
140
  });
141
141
 
142
- const Component = ({
143
- isWarning,
144
- width,
145
- }: {
146
- isWarning: boolean;
147
- width: number;
148
- }) => {
149
- return (
150
- <div style={{ width }} css={[baseStyles, isWarning && warningStyles]} />
151
- );
142
+ const Component = ({ isWarning, width }: { isWarning: boolean; width: number }) => {
143
+ return <div style={{ width }} css={[baseStyles, isWarning && warningStyles]} />;
152
144
  };
153
145
  ```
154
146
 
@@ -158,7 +150,8 @@ const Component = ({
158
150
 
159
151
  Use this to allow specified imports as dynamic keys, in addition to the built-in allow-list.
160
152
 
161
- Each value should be a two-element array. The first item is the entrypoint, and the second item is a named export.
153
+ Each value should be a two-element array. The first item is the entrypoint, and the second item is a
154
+ named export.
162
155
 
163
156
  Default imports are not supported.
164
157
 
@@ -184,7 +177,8 @@ Default imports are not supported.
184
177
 
185
178
  Use this to allow specific functions to be called, in addition to the built-in allow-list.
186
179
 
187
- Each value should be a two-element array. The first item is the entrypoint, and the second item is a named export.
180
+ Each value should be a two-element array. The first item is the entrypoint, and the second item is a
181
+ named export.
188
182
 
189
183
  Default imports are not currently supported.
190
184
 
@@ -210,13 +204,13 @@ Default imports are not currently supported.
210
204
 
211
205
  By default, this rule will check `css` usages from:
212
206
 
213
- - `@atlaskit/css`
214
- - `@atlaskit/primitives`
215
- - `@compiled/react`
216
- - `@emotion/react`
217
- - `@emotion/core`
218
- - `@emotion/styled`
219
- - `styled-components`
207
+ - `@atlaskit/css`
208
+ - `@atlaskit/primitives`
209
+ - `@compiled/react`
210
+ - `@emotion/react`
211
+ - `@emotion/core`
212
+ - `@emotion/styled`
213
+ - `styled-components`
220
214
 
221
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
222
- This will override the built-in allow-list.
215
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an
216
+ array of package names (strings). This will override the built-in allow-list.
@@ -16,7 +16,7 @@ var _recommended = _interopRequireDefault(require("./presets/recommended.codegen
16
16
  var _index = _interopRequireDefault(require("./rules/index.codegen"));
17
17
  /**
18
18
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
19
- * @codegen <<SignedSource::3fd41935576c9346ca1f1e0c787a0a48>>
19
+ * @codegen <<SignedSource::16a3441765e5a97f9f32de7fd0de17f0>>
20
20
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
21
21
  */
22
22
 
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
9
+ * @codegen <<SignedSource::a0c326baf3aa4e87ac809b303ba34682>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
11
11
  */
12
12
  var _default = exports.default = {
13
13
  plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
14
14
  rules: {
15
+ '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
15
16
  '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
16
17
  '@atlaskit/ui-styling-standard/enforce-style-prop': 'warn',
17
18
  '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
9
+ * @codegen <<SignedSource::a0c326baf3aa4e87ac809b303ba34682>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
11
11
  */
12
12
  var _default = exports.default = {
13
13
  plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
14
14
  rules: {
15
+ '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
15
16
  '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
16
17
  '@atlaskit/ui-styling-standard/enforce-style-prop': 'warn',
17
18
  '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.rule = exports.default = void 0;
7
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
8
+ var _createRule = require("../utils/create-rule");
9
+ var isIdentifierReferenced = function isIdentifierReferenced(hasImportSpecifier, node, references) {
10
+ return references.some(function (reference) {
11
+ var _reference$resolved;
12
+ return reference.identifier === node && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(hasImportSpecifier));
13
+ });
14
+ };
15
+ var isTypographyImportSpecifier = function isTypographyImportSpecifier(def) {
16
+ var _def$parent, _def$parent2, _def$parent3;
17
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.type) === 'ImportDeclaration' && (def.node.imported.name === 'typography' && ((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value) === '@atlaskit/theme' || ((_def$parent3 = def.parent) === null || _def$parent3 === void 0 ? void 0 : _def$parent3.source.value) === '@atlaskit/theme/typography');
18
+ };
19
+ var isElevationImportSpecifier = function isElevationImportSpecifier(def) {
20
+ var _def$parent4, _def$parent5, _def$parent6;
21
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent4 = def.parent) === null || _def$parent4 === void 0 ? void 0 : _def$parent4.type) === 'ImportDeclaration' && (def.node.imported.name === 'elevation' && ((_def$parent5 = def.parent) === null || _def$parent5 === void 0 ? void 0 : _def$parent5.source.value) === '@atlaskit/theme' || ((_def$parent6 = def.parent) === null || _def$parent6 === void 0 ? void 0 : _def$parent6.source.value) === '@atlaskit/theme/elevation');
22
+ };
23
+ var isSkeletonShimmerImportSpecifier = function isSkeletonShimmerImportSpecifier(def) {
24
+ var _def$parent7, _def$parent8, _def$parent9;
25
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent7 = def.parent) === null || _def$parent7 === void 0 ? void 0 : _def$parent7.type) === 'ImportDeclaration' && def.node.imported.name === 'skeletonShimmer' && typeof ((_def$parent8 = def.parent) === null || _def$parent8 === void 0 ? void 0 : _def$parent8.source.value) === 'string' && ((_def$parent9 = def.parent) === null || _def$parent9 === void 0 || (_def$parent9 = _def$parent9.source.value) === null || _def$parent9 === void 0 ? void 0 : _def$parent9.startsWith('@atlaskit/theme'));
26
+ };
27
+ var checkIdentifier = function checkIdentifier(node, context, references) {
28
+ if (isIdentifierReferenced(isTypographyImportSpecifier, node, references)) {
29
+ context.report({
30
+ messageId: 'usingTypography',
31
+ node: node
32
+ });
33
+ }
34
+ if (isIdentifierReferenced(isElevationImportSpecifier, node, references)) {
35
+ context.report({
36
+ messageId: 'usingElevation',
37
+ node: node
38
+ });
39
+ }
40
+ if (isIdentifierReferenced(isSkeletonShimmerImportSpecifier, node, references)) {
41
+ context.report({
42
+ messageId: 'usingSkeletonShimmer',
43
+ node: node
44
+ });
45
+ }
46
+ };
47
+ var rule = exports.rule = (0, _createRule.createLintRule)({
48
+ meta: {
49
+ name: 'atlaskit-theme',
50
+ docs: {
51
+ description: 'Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand',
52
+ recommended: true,
53
+ severity: 'error'
54
+ },
55
+ messages: {
56
+ usingTypography: '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',
57
+ usingElevation: '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',
58
+ usingSkeletonShimmer: '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'
59
+ },
60
+ schema: [],
61
+ type: 'problem'
62
+ },
63
+ create: function create(context) {
64
+ var importSources = (0, _isSupportedImport.getImportSources)(context);
65
+ return {
66
+ 'CallExpression Identifier': function CallExpressionIdentifier(node) {
67
+ var _context$getScope = context.getScope(),
68
+ references = _context$getScope.references;
69
+ var ancestors = context.getAncestors();
70
+
71
+ // Check if ancestor node is a call expression to Compiled
72
+ if (ancestors.some(function (ancestor) {
73
+ return ancestor.type === 'CallExpression' && ancestor.callee && (0, _isSupportedImport.isCompiled)(ancestor.callee, references, importSources);
74
+ })) {
75
+ // Check identifier for violations
76
+ checkIdentifier(node, context, references);
77
+ }
78
+ },
79
+ 'TaggedTemplateExpression Identifier': function TaggedTemplateExpressionIdentifier(node) {
80
+ var _context$getScope2 = context.getScope(),
81
+ references = _context$getScope2.references;
82
+ var ancestors = context.getAncestors();
83
+
84
+ // Check if ancestor node is a tagged template expression to Compiled
85
+ if (ancestors.some(function (ancestor) {
86
+ return ancestor.type === 'TaggedTemplateExpression' && ancestor.tag && (0, _isSupportedImport.isCompiled)(ancestor.tag, references, importSources);
87
+ })) {
88
+ // Check identifier for violations
89
+ checkIdentifier(node, context, references);
90
+ }
91
+ }
92
+ };
93
+ }
94
+ });
95
+ var _default = exports.default = rule;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _atlaskitTheme = _interopRequireDefault(require("./atlaskit-theme"));
8
9
  var _convertPropsSyntax = _interopRequireDefault(require("./convert-props-syntax"));
9
10
  var _enforceStyleProp = _interopRequireDefault(require("./enforce-style-prop"));
10
11
  var _localCxXcss = _interopRequireDefault(require("./local-cx-xcss"));
@@ -19,10 +20,11 @@ var _noNestedSelectors = _interopRequireDefault(require("./no-nested-selectors")
19
20
  var _noUnsafeValues = _interopRequireDefault(require("./no-unsafe-values"));
20
21
  /**
21
22
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
22
- * @codegen <<SignedSource::648acb81f0f43d8ce56f7d6c22db8856>>
23
+ * @codegen <<SignedSource::78ffc29d20fd2fe3727a620cb4ddf192>>
23
24
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
24
25
  */
25
26
  var _default = exports.default = {
27
+ 'atlaskit-theme': _atlaskitTheme.default,
26
28
  'convert-props-syntax': _convertPropsSyntax.default,
27
29
  'enforce-style-prop': _enforceStyleProp.default,
28
30
  'local-cx-xcss': _localCxXcss.default,
@@ -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::3fd41935576c9346ca1f1e0c787a0a48>>
3
+ * @codegen <<SignedSource::16a3441765e5a97f9f32de7fd0de17f0>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  import all from './presets/all.codegen';
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
3
+ * @codegen <<SignedSource::a0c326baf3aa4e87ac809b303ba34682>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
7
7
  plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
8
  rules: {
9
+ '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
9
10
  '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
10
11
  '@atlaskit/ui-styling-standard/enforce-style-prop': 'warn',
11
12
  '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
3
+ * @codegen <<SignedSource::a0c326baf3aa4e87ac809b303ba34682>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
7
7
  plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
8
  rules: {
9
+ '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
9
10
  '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
10
11
  '@atlaskit/ui-styling-standard/enforce-style-prop': 'warn',
11
12
  '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
@@ -0,0 +1,85 @@
1
+ import { getImportSources, isCompiled } from '@atlaskit/eslint-utils/is-supported-import';
2
+ import { createLintRule } from '../utils/create-rule';
3
+ const isIdentifierReferenced = (hasImportSpecifier, node, references) => references.some(reference => {
4
+ var _reference$resolved;
5
+ return reference.identifier === node && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(hasImportSpecifier));
6
+ });
7
+ const isTypographyImportSpecifier = def => {
8
+ var _def$parent, _def$parent2, _def$parent3;
9
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.type) === 'ImportDeclaration' && (def.node.imported.name === 'typography' && ((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value) === '@atlaskit/theme' || ((_def$parent3 = def.parent) === null || _def$parent3 === void 0 ? void 0 : _def$parent3.source.value) === '@atlaskit/theme/typography');
10
+ };
11
+ const isElevationImportSpecifier = def => {
12
+ var _def$parent4, _def$parent5, _def$parent6;
13
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent4 = def.parent) === null || _def$parent4 === void 0 ? void 0 : _def$parent4.type) === 'ImportDeclaration' && (def.node.imported.name === 'elevation' && ((_def$parent5 = def.parent) === null || _def$parent5 === void 0 ? void 0 : _def$parent5.source.value) === '@atlaskit/theme' || ((_def$parent6 = def.parent) === null || _def$parent6 === void 0 ? void 0 : _def$parent6.source.value) === '@atlaskit/theme/elevation');
14
+ };
15
+ const isSkeletonShimmerImportSpecifier = def => {
16
+ var _def$parent7, _def$parent8, _def$parent9, _def$parent9$source$v;
17
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent7 = def.parent) === null || _def$parent7 === void 0 ? void 0 : _def$parent7.type) === 'ImportDeclaration' && def.node.imported.name === 'skeletonShimmer' && typeof ((_def$parent8 = def.parent) === null || _def$parent8 === void 0 ? void 0 : _def$parent8.source.value) === 'string' && ((_def$parent9 = def.parent) === null || _def$parent9 === void 0 ? void 0 : (_def$parent9$source$v = _def$parent9.source.value) === null || _def$parent9$source$v === void 0 ? void 0 : _def$parent9$source$v.startsWith('@atlaskit/theme'));
18
+ };
19
+ const checkIdentifier = (node, context, references) => {
20
+ if (isIdentifierReferenced(isTypographyImportSpecifier, node, references)) {
21
+ context.report({
22
+ messageId: 'usingTypography',
23
+ node
24
+ });
25
+ }
26
+ if (isIdentifierReferenced(isElevationImportSpecifier, node, references)) {
27
+ context.report({
28
+ messageId: 'usingElevation',
29
+ node
30
+ });
31
+ }
32
+ if (isIdentifierReferenced(isSkeletonShimmerImportSpecifier, node, references)) {
33
+ context.report({
34
+ messageId: 'usingSkeletonShimmer',
35
+ node
36
+ });
37
+ }
38
+ };
39
+ export const rule = createLintRule({
40
+ meta: {
41
+ name: 'atlaskit-theme',
42
+ docs: {
43
+ description: 'Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand',
44
+ recommended: true,
45
+ severity: 'error'
46
+ },
47
+ messages: {
48
+ usingTypography: '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',
49
+ usingElevation: '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',
50
+ usingSkeletonShimmer: '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'
51
+ },
52
+ schema: [],
53
+ type: 'problem'
54
+ },
55
+ create(context) {
56
+ const importSources = getImportSources(context);
57
+ return {
58
+ 'CallExpression Identifier': node => {
59
+ const {
60
+ references
61
+ } = context.getScope();
62
+ const ancestors = context.getAncestors();
63
+
64
+ // Check if ancestor node is a call expression to Compiled
65
+ if (ancestors.some(ancestor => ancestor.type === 'CallExpression' && ancestor.callee && isCompiled(ancestor.callee, references, importSources))) {
66
+ // Check identifier for violations
67
+ checkIdentifier(node, context, references);
68
+ }
69
+ },
70
+ 'TaggedTemplateExpression Identifier': node => {
71
+ const {
72
+ references
73
+ } = context.getScope();
74
+ const ancestors = context.getAncestors();
75
+
76
+ // Check if ancestor node is a tagged template expression to Compiled
77
+ if (ancestors.some(ancestor => ancestor.type === 'TaggedTemplateExpression' && ancestor.tag && isCompiled(ancestor.tag, references, importSources))) {
78
+ // Check identifier for violations
79
+ checkIdentifier(node, context, references);
80
+ }
81
+ }
82
+ };
83
+ }
84
+ });
85
+ export default rule;
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::648acb81f0f43d8ce56f7d6c22db8856>>
3
+ * @codegen <<SignedSource::78ffc29d20fd2fe3727a620cb4ddf192>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
+ import atlaskitTheme from './atlaskit-theme';
6
7
  import convertPropsSyntax from './convert-props-syntax';
7
8
  import enforceStyleProp from './enforce-style-prop';
8
9
  import localCxXcss from './local-cx-xcss';
@@ -16,6 +17,7 @@ import noImportedStyleValues from './no-imported-style-values';
16
17
  import noNestedSelectors from './no-nested-selectors';
17
18
  import noUnsafeValues from './no-unsafe-values';
18
19
  export default {
20
+ 'atlaskit-theme': atlaskitTheme,
19
21
  'convert-props-syntax': convertPropsSyntax,
20
22
  'enforce-style-prop': enforceStyleProp,
21
23
  'local-cx-xcss': localCxXcss,
@@ -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::3fd41935576c9346ca1f1e0c787a0a48>>
3
+ * @codegen <<SignedSource::16a3441765e5a97f9f32de7fd0de17f0>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  import all from './presets/all.codegen';
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
3
+ * @codegen <<SignedSource::a0c326baf3aa4e87ac809b303ba34682>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
7
7
  plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
8
  rules: {
9
+ '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
9
10
  '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
10
11
  '@atlaskit/ui-styling-standard/enforce-style-prop': 'warn',
11
12
  '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
3
+ * @codegen <<SignedSource::a0c326baf3aa4e87ac809b303ba34682>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
7
7
  plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
8
  rules: {
9
+ '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
9
10
  '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
10
11
  '@atlaskit/ui-styling-standard/enforce-style-prop': 'warn',
11
12
  '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
@@ -0,0 +1,89 @@
1
+ import { getImportSources, isCompiled } from '@atlaskit/eslint-utils/is-supported-import';
2
+ import { createLintRule } from '../utils/create-rule';
3
+ var isIdentifierReferenced = function isIdentifierReferenced(hasImportSpecifier, node, references) {
4
+ return references.some(function (reference) {
5
+ var _reference$resolved;
6
+ return reference.identifier === node && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(hasImportSpecifier));
7
+ });
8
+ };
9
+ var isTypographyImportSpecifier = function isTypographyImportSpecifier(def) {
10
+ var _def$parent, _def$parent2, _def$parent3;
11
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.type) === 'ImportDeclaration' && (def.node.imported.name === 'typography' && ((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value) === '@atlaskit/theme' || ((_def$parent3 = def.parent) === null || _def$parent3 === void 0 ? void 0 : _def$parent3.source.value) === '@atlaskit/theme/typography');
12
+ };
13
+ var isElevationImportSpecifier = function isElevationImportSpecifier(def) {
14
+ var _def$parent4, _def$parent5, _def$parent6;
15
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent4 = def.parent) === null || _def$parent4 === void 0 ? void 0 : _def$parent4.type) === 'ImportDeclaration' && (def.node.imported.name === 'elevation' && ((_def$parent5 = def.parent) === null || _def$parent5 === void 0 ? void 0 : _def$parent5.source.value) === '@atlaskit/theme' || ((_def$parent6 = def.parent) === null || _def$parent6 === void 0 ? void 0 : _def$parent6.source.value) === '@atlaskit/theme/elevation');
16
+ };
17
+ var isSkeletonShimmerImportSpecifier = function isSkeletonShimmerImportSpecifier(def) {
18
+ var _def$parent7, _def$parent8, _def$parent9;
19
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent7 = def.parent) === null || _def$parent7 === void 0 ? void 0 : _def$parent7.type) === 'ImportDeclaration' && def.node.imported.name === 'skeletonShimmer' && typeof ((_def$parent8 = def.parent) === null || _def$parent8 === void 0 ? void 0 : _def$parent8.source.value) === 'string' && ((_def$parent9 = def.parent) === null || _def$parent9 === void 0 || (_def$parent9 = _def$parent9.source.value) === null || _def$parent9 === void 0 ? void 0 : _def$parent9.startsWith('@atlaskit/theme'));
20
+ };
21
+ var checkIdentifier = function checkIdentifier(node, context, references) {
22
+ if (isIdentifierReferenced(isTypographyImportSpecifier, node, references)) {
23
+ context.report({
24
+ messageId: 'usingTypography',
25
+ node: node
26
+ });
27
+ }
28
+ if (isIdentifierReferenced(isElevationImportSpecifier, node, references)) {
29
+ context.report({
30
+ messageId: 'usingElevation',
31
+ node: node
32
+ });
33
+ }
34
+ if (isIdentifierReferenced(isSkeletonShimmerImportSpecifier, node, references)) {
35
+ context.report({
36
+ messageId: 'usingSkeletonShimmer',
37
+ node: node
38
+ });
39
+ }
40
+ };
41
+ export var rule = createLintRule({
42
+ meta: {
43
+ name: 'atlaskit-theme',
44
+ docs: {
45
+ description: 'Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand',
46
+ recommended: true,
47
+ severity: 'error'
48
+ },
49
+ messages: {
50
+ usingTypography: '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',
51
+ usingElevation: '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',
52
+ usingSkeletonShimmer: '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'
53
+ },
54
+ schema: [],
55
+ type: 'problem'
56
+ },
57
+ create: function create(context) {
58
+ var importSources = getImportSources(context);
59
+ return {
60
+ 'CallExpression Identifier': function CallExpressionIdentifier(node) {
61
+ var _context$getScope = context.getScope(),
62
+ references = _context$getScope.references;
63
+ var ancestors = context.getAncestors();
64
+
65
+ // Check if ancestor node is a call expression to Compiled
66
+ if (ancestors.some(function (ancestor) {
67
+ return ancestor.type === 'CallExpression' && ancestor.callee && isCompiled(ancestor.callee, references, importSources);
68
+ })) {
69
+ // Check identifier for violations
70
+ checkIdentifier(node, context, references);
71
+ }
72
+ },
73
+ 'TaggedTemplateExpression Identifier': function TaggedTemplateExpressionIdentifier(node) {
74
+ var _context$getScope2 = context.getScope(),
75
+ references = _context$getScope2.references;
76
+ var ancestors = context.getAncestors();
77
+
78
+ // Check if ancestor node is a tagged template expression to Compiled
79
+ if (ancestors.some(function (ancestor) {
80
+ return ancestor.type === 'TaggedTemplateExpression' && ancestor.tag && isCompiled(ancestor.tag, references, importSources);
81
+ })) {
82
+ // Check identifier for violations
83
+ checkIdentifier(node, context, references);
84
+ }
85
+ }
86
+ };
87
+ }
88
+ });
89
+ export default rule;