@atlaskit/eslint-plugin-ui-styling-standard 0.11.1 → 0.11.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -0
  3. package/constellation/index/overview.mdx +1 -0
  4. package/constellation/no-imported-style-values/usage.mdx +146 -0
  5. package/dist/cjs/presets/all.codegen.js +2 -1
  6. package/dist/cjs/presets/recommended.codegen.js +2 -1
  7. package/dist/cjs/rules/index.codegen.js +3 -1
  8. package/dist/cjs/rules/no-imported-style-values/index.js +145 -0
  9. package/dist/es2019/presets/all.codegen.js +2 -1
  10. package/dist/es2019/presets/recommended.codegen.js +2 -1
  11. package/dist/es2019/rules/index.codegen.js +3 -1
  12. package/dist/es2019/rules/no-imported-style-values/index.js +125 -0
  13. package/dist/esm/presets/all.codegen.js +2 -1
  14. package/dist/esm/presets/recommended.codegen.js +2 -1
  15. package/dist/esm/rules/index.codegen.js +3 -1
  16. package/dist/esm/rules/no-imported-style-values/index.js +138 -0
  17. package/dist/types/index.codegen.d.ts +2 -0
  18. package/dist/types/presets/all.codegen.d.ts +2 -1
  19. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  20. package/dist/types/rules/index.codegen.d.ts +1 -0
  21. package/dist/types/rules/no-imported-style-values/index.d.ts +3 -0
  22. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  23. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  24. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  25. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  26. package/dist/types-ts4.5/rules/no-imported-style-values/index.d.ts +3 -0
  27. package/package.json +2 -2
  28. package/src/presets/all.codegen.tsx +2 -1
  29. package/src/presets/recommended.codegen.tsx +2 -1
  30. package/src/rules/index.codegen.tsx +3 -1
  31. package/src/rules/no-imported-style-values/README.md +144 -0
  32. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +265 -0
  33. package/src/rules/no-imported-style-values/index.tsx +154 -0
@@ -0,0 +1,138 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ import { createLintRule } from '../utils/create-rule';
5
+ import { getImportSources, hasStyleObjectArguments } from '@atlaskit/eslint-utils/is-supported-import';
6
+ import { findVariable } from '@atlaskit/eslint-utils/find-variable';
7
+ import { getAllowedDynamicKeys, getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
8
+ import esquery from 'esquery';
9
+ var schema = [{
10
+ type: 'object',
11
+ properties: {
12
+ importSources: {
13
+ type: 'array',
14
+ items: {
15
+ type: 'string'
16
+ },
17
+ uniqueItems: true
18
+ },
19
+ allowedFunctionCalls: {
20
+ type: 'array',
21
+ items: {
22
+ type: 'array',
23
+ minItems: 2,
24
+ maxItems: 2,
25
+ items: [{
26
+ type: 'string'
27
+ }, {
28
+ type: 'string'
29
+ }]
30
+ },
31
+ uniqueItems: true
32
+ },
33
+ allowedDynamicKeys: {
34
+ type: 'array',
35
+ items: {
36
+ type: 'array',
37
+ minItems: 2,
38
+ maxItems: 2,
39
+ items: [{
40
+ type: 'string'
41
+ }, {
42
+ type: 'string'
43
+ }]
44
+ },
45
+ uniqueItems: true
46
+ }
47
+ }
48
+ }];
49
+ var isIdentifierImported = function isIdentifierImported(identifier, context, functionAllowList, keysAllowList) {
50
+ var variable = findVariable({
51
+ identifier: identifier,
52
+ sourceCode: context.sourceCode
53
+ });
54
+ if (!variable) {
55
+ return false;
56
+ }
57
+ var isImported = variable.defs.some(function (definition) {
58
+ return definition.type === 'ImportBinding';
59
+ });
60
+
61
+ // check if imported variable is allowed
62
+ return isImported && !isAllowListedVariable({
63
+ allowList: functionAllowList,
64
+ variable: variable
65
+ }) && !isAllowListedVariable({
66
+ allowList: keysAllowList,
67
+ variable: variable
68
+ });
69
+ };
70
+ var checkIdentifier = function checkIdentifier(identifier, context, functionAllowList, keysAllowList) {
71
+ if (isIdentifierImported(identifier, context, functionAllowList, keysAllowList)) {
72
+ context.report({
73
+ node: identifier,
74
+ messageId: 'no-imported-style-values'
75
+ });
76
+ }
77
+ };
78
+ export var rule = createLintRule({
79
+ meta: {
80
+ name: 'no-imported-style-values',
81
+ docs: {
82
+ description: 'Disallows imports of style values',
83
+ recommended: true,
84
+ severity: 'warn'
85
+ },
86
+ messages: {
87
+ 'no-imported-style-values': 'Styles should not be imported to use in css, cssMap, styled, keyframes or xcss calls. All styles should be defined and used in the same file instead.'
88
+ },
89
+ type: 'problem',
90
+ schema: schema
91
+ },
92
+ create: function create(context) {
93
+ var importSources = getImportSources(context);
94
+ var functionAllowList = getAllowedFunctionCalls(context.options);
95
+ var keysAllowList = getAllowedDynamicKeys(context.options);
96
+ var checkForIdentifiers = function checkForIdentifiers(node) {
97
+ var matches = esquery(node, 'Identifier');
98
+ var _iterator = _createForOfIteratorHelper(matches),
99
+ _step;
100
+ try {
101
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
102
+ var match = _step.value;
103
+ if (match.type === 'Identifier') {
104
+ checkIdentifier(match, context, functionAllowList, keysAllowList);
105
+ }
106
+ }
107
+ } catch (err) {
108
+ _iterator.e(err);
109
+ } finally {
110
+ _iterator.f();
111
+ }
112
+ };
113
+ return {
114
+ // Checking css/cssMap/keyframes/styled/xcss calls
115
+ CallExpression: function CallExpression(node) {
116
+ var _context$sourceCode$g = context.sourceCode.getScope(node.callee),
117
+ references = _context$sourceCode$g.references;
118
+ if (!hasStyleObjectArguments(node.callee, references, importSources)) {
119
+ return;
120
+ }
121
+ node.arguments.forEach(checkForIdentifiers);
122
+ },
123
+ 'JSXAttribute[name.name="css"] Identifier': function JSXAttributeNameNameCssIdentifier(node) {
124
+ if (node.type !== 'Identifier') {
125
+ return;
126
+ }
127
+ checkIdentifier(node, context, functionAllowList, keysAllowList);
128
+ },
129
+ 'JSXAttribute[name.name="style"] Identifier': function JSXAttributeNameNameStyleIdentifier(node) {
130
+ if (node.type !== 'Identifier') {
131
+ return;
132
+ }
133
+ checkIdentifier(node, context, functionAllowList, keysAllowList);
134
+ }
135
+ };
136
+ }
137
+ });
138
+ export default rule;
@@ -12,6 +12,7 @@ export declare const configs: {
12
12
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
13
13
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
14
14
  '@atlaskit/ui-styling-standard/no-important-styles': string;
15
+ '@atlaskit/ui-styling-standard/no-imported-style-values': string;
15
16
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
16
17
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
17
18
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -48,6 +49,7 @@ export declare const configs: {
48
49
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
49
50
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
50
51
  '@atlaskit/ui-styling-standard/no-important-styles': string;
52
+ '@atlaskit/ui-styling-standard/no-imported-style-values': string;
51
53
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
52
54
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
53
55
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -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::42dc97374e2e4fd9ea068b3564bdcb72>>
3
+ * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -15,6 +15,7 @@ declare const _default: {
15
15
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
16
16
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
17
17
  '@atlaskit/ui-styling-standard/no-important-styles': string;
18
+ '@atlaskit/ui-styling-standard/no-imported-style-values': string;
18
19
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
19
20
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
20
21
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -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::42dc97374e2e4fd9ea068b3564bdcb72>>
3
+ * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -15,6 +15,7 @@ declare const _default: {
15
15
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
16
16
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
17
17
  '@atlaskit/ui-styling-standard/no-important-styles': string;
18
+ '@atlaskit/ui-styling-standard/no-imported-style-values': string;
18
19
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
19
20
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
20
21
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -8,6 +8,7 @@ declare const _default: {
8
8
  'no-dynamic-styles': import("eslint").Rule.RuleModule;
9
9
  'no-exported-styles': import("eslint").Rule.RuleModule;
10
10
  'no-important-styles': import("eslint").Rule.RuleModule;
11
+ 'no-imported-style-values': import("eslint").Rule.RuleModule;
11
12
  'no-nested-selectors': import("eslint").Rule.RuleModule;
12
13
  'no-unsafe-values': import("eslint").Rule.RuleModule;
13
14
  };
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ export declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -12,6 +12,7 @@ export declare const configs: {
12
12
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
13
13
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
14
14
  '@atlaskit/ui-styling-standard/no-important-styles': string;
15
+ '@atlaskit/ui-styling-standard/no-imported-style-values': string;
15
16
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
16
17
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
17
18
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -48,6 +49,7 @@ export declare const configs: {
48
49
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
49
50
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
50
51
  '@atlaskit/ui-styling-standard/no-important-styles': string;
52
+ '@atlaskit/ui-styling-standard/no-imported-style-values': string;
51
53
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
52
54
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
53
55
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -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::42dc97374e2e4fd9ea068b3564bdcb72>>
3
+ * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -15,6 +15,7 @@ declare const _default: {
15
15
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
16
16
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
17
17
  '@atlaskit/ui-styling-standard/no-important-styles': string;
18
+ '@atlaskit/ui-styling-standard/no-imported-style-values': string;
18
19
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
19
20
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
20
21
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -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::42dc97374e2e4fd9ea068b3564bdcb72>>
3
+ * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -15,6 +15,7 @@ declare const _default: {
15
15
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
16
16
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
17
17
  '@atlaskit/ui-styling-standard/no-important-styles': string;
18
+ '@atlaskit/ui-styling-standard/no-imported-style-values': string;
18
19
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
19
20
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
20
21
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -8,6 +8,7 @@ declare const _default: {
8
8
  'no-dynamic-styles': import("eslint").Rule.RuleModule;
9
9
  'no-exported-styles': import("eslint").Rule.RuleModule;
10
10
  'no-important-styles': import("eslint").Rule.RuleModule;
11
+ 'no-imported-style-values': import("eslint").Rule.RuleModule;
11
12
  'no-nested-selectors': import("eslint").Rule.RuleModule;
12
13
  'no-unsafe-values': import("eslint").Rule.RuleModule;
13
14
  };
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ export declare const rule: Rule.RuleModule;
3
+ export default rule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "author": "Atlassian Pty Ltd",
5
5
  "description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
6
6
  "license": "Apache-2.0",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@atlaskit/ds-lib": "^2.3.0",
53
- "@atlaskit/eslint-plugin-design-system": "^9.5.0",
53
+ "@atlaskit/eslint-plugin-design-system": "^9.6.0",
54
54
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
55
55
  "@atlassian/codegen": "*",
56
56
  "@compiled/eslint-plugin": "^0.13.6",
@@ -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::42dc97374e2e4fd9ea068b3564bdcb72>>
3
+ * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
@@ -19,6 +19,7 @@ export default {
19
19
  '@atlaskit/ui-styling-standard/no-dynamic-styles': 'warn',
20
20
  '@atlaskit/ui-styling-standard/no-exported-styles': 'warn',
21
21
  '@atlaskit/ui-styling-standard/no-important-styles': 'warn',
22
+ '@atlaskit/ui-styling-standard/no-imported-style-values': 'warn',
22
23
  '@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
23
24
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'warn',
24
25
  '@atlaskit/design-system/consistent-css-prop-usage': [
@@ -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::42dc97374e2e4fd9ea068b3564bdcb72>>
3
+ * @codegen <<SignedSource::96336e6094dbcbf456aaef313b624fbf>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
@@ -19,6 +19,7 @@ export default {
19
19
  '@atlaskit/ui-styling-standard/no-dynamic-styles': 'warn',
20
20
  '@atlaskit/ui-styling-standard/no-exported-styles': 'warn',
21
21
  '@atlaskit/ui-styling-standard/no-important-styles': 'warn',
22
+ '@atlaskit/ui-styling-standard/no-imported-style-values': 'warn',
22
23
  '@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
23
24
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'warn',
24
25
  '@atlaskit/design-system/consistent-css-prop-usage': [
@@ -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::1c60c9984196cab3d54e3144c59ba97c>>
3
+ * @codegen <<SignedSource::648acb81f0f43d8ce56f7d6c22db8856>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  import convertPropsSyntax from './convert-props-syntax';
@@ -12,6 +12,7 @@ import noContainerQueries from './no-container-queries';
12
12
  import noDynamicStyles from './no-dynamic-styles';
13
13
  import noExportedStyles from './no-exported-styles';
14
14
  import noImportantStyles from './no-important-styles';
15
+ import noImportedStyleValues from './no-imported-style-values';
15
16
  import noNestedSelectors from './no-nested-selectors';
16
17
  import noUnsafeValues from './no-unsafe-values';
17
18
 
@@ -25,6 +26,7 @@ export default {
25
26
  'no-dynamic-styles': noDynamicStyles,
26
27
  'no-exported-styles': noExportedStyles,
27
28
  'no-important-styles': noImportantStyles,
29
+ 'no-imported-style-values': noImportedStyleValues,
28
30
  'no-nested-selectors': noNestedSelectors,
29
31
  'no-unsafe-values': noUnsafeValues,
30
32
  };
@@ -0,0 +1,144 @@
1
+ This rule disallows using imported style values in `css`, `cssMap`, `styled`, `keyframes` and `xcss` calls.
2
+
3
+ Importing style values may result in unexpected errors when used in these APIs, because its value will be null at runtime when using `@compiled/react`. Additionally, co-locating style definitions with their usage is considered best practice in order to improve code readability and build performance.
4
+
5
+ ## Examples
6
+
7
+ ### Incorrect
8
+
9
+ ```js
10
+ import { css } from '@compiled/react';
11
+ import { colors, getColor } from '@mui/theme';
12
+
13
+ const styles = css({
14
+ [colorKey]: getColor('red'),
15
+ background: colors['red'],
16
+ });
17
+ ```
18
+
19
+ ```js
20
+ import { css } from '@compiled/react';
21
+ import { buttonStyles, cssShared, HEIGHT, colorKey } from '../shared';
22
+ import { ff } from '@atlaskit/ff';
23
+
24
+ const sharedObject = { padding: 0 };
25
+
26
+ const styles = css({
27
+ ...cssShared,
28
+ ...sharedObject,
29
+ height: `${HEIGHT}px`,
30
+ width: ff('…') ? `${HEIGHT}px` : undefined,
31
+ });
32
+ ```
33
+
34
+ Importing styles to use in style composition is not allowed.
35
+
36
+ ```js
37
+ import { css } from '@compiled/react';
38
+ import { buttonStyles } from '../shared';
39
+
40
+ const styles = css({
41
+ color: 'red',
42
+ });
43
+
44
+ export default () => <div css={[styles, buttonStyles]} />;
45
+ ```
46
+
47
+ Importing styles to pass to the style prop is also not allowed.
48
+
49
+ ```js
50
+ import { importedWidth } from '../shared';
51
+
52
+ export default () => <div style={{ width: importedWidth }} />;
53
+ ```
54
+
55
+ ### Correct
56
+
57
+ Co-locate your styles next to your components to improve code readability, linting, and build performance.
58
+
59
+ ```js
60
+ import { css } from '@compiled/react';
61
+ import { token } from '@atlaskit/tokens';
62
+
63
+ const styles = css({
64
+ color: 'red',
65
+ padding: token('space.150'),
66
+ });
67
+ export const Component = ({ children }) => <div css={styles}>{children}></div>;
68
+ ```
69
+
70
+ ```js
71
+ import { keyframes } from '@compiled/react';
72
+
73
+ const animation = keyframes({});
74
+ const styles = css({ animate: `${animation} 1s ease-in` });
75
+ export const Component = ({ children }) => <div css={styles}>{children}></div>;
76
+ ```
77
+
78
+ ## Options
79
+
80
+ ### `allowedDynamicKeys: [string, string][]`
81
+
82
+ Use this to allow specified imports as dynamic keys, in addition to the built-in allow-list.
83
+
84
+ Each value should be a two-element array. The first item is the entrypoint, and the second item is a named export.
85
+
86
+ Default imports are not supported.
87
+
88
+ ```tsx
89
+ // .eslintrc.js
90
+
91
+ // ...
92
+ rules: {
93
+ '@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
94
+ 'error',
95
+ {
96
+ allowedDynamicKeys: [
97
+ ['@atlaskit/primitives/responsive', 'media'],
98
+ ]
99
+ },
100
+ ],
101
+ // ...
102
+ },
103
+ // ...
104
+ ```
105
+
106
+ ### `allowedFunctionCalls: [string, string][]`
107
+
108
+ Use this to allow specific functions to be called, in addition to the built-in allow-list.
109
+
110
+ Each value should be a two-element array. The first item is the entrypoint, and the second item is a named export.
111
+
112
+ Default imports are not currently supported.
113
+
114
+ ```tsx
115
+ // .eslintrc.js
116
+
117
+ // ...
118
+ rules: {
119
+ '@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
120
+ 'error',
121
+ {
122
+ allowedFunctionCalls: [
123
+ ['@atlaskit/tokens', 'token'],
124
+ ]
125
+ },
126
+ ],
127
+ // ...
128
+ },
129
+ // ...
130
+ ```
131
+
132
+ ### `importSources: string[]`
133
+
134
+ By default, this rule will check `css` usages from:
135
+
136
+ - `@atlaskit/css`
137
+ - `@atlaskit/primitives`
138
+ - `@compiled/react`
139
+ - `@emotion/react`
140
+ - `@emotion/core`
141
+ - `@emotion/styled`
142
+ - `styled-components`
143
+
144
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).