@atlaskit/eslint-plugin-ui-styling-standard 0.15.2 → 0.16.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 (105) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/constellation/consistent-css-prop-usage/usage.mdx +3 -1
  3. package/constellation/index/migration-guide.mdx +309 -0
  4. package/constellation/index/overview.mdx +4 -0
  5. package/constellation/index/props.mdx +9 -5
  6. package/constellation/no-css-tagged-template-expression/usage.mdx +5 -2
  7. package/constellation/no-empty-styled-expression/usage.mdx +5 -2
  8. package/constellation/no-exported-css/usage.mdx +5 -2
  9. package/constellation/no-exported-keyframes/usage.mdx +5 -2
  10. package/constellation/no-invalid-css-map/usage.mdx +5 -2
  11. package/constellation/no-js-xcss/usage.mdx +3 -1
  12. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +5 -2
  13. package/constellation/no-styled-tagged-template-expression/usage.mdx +5 -2
  14. package/constellation/no-suppress-xcss/usage.mdx +6 -3
  15. package/dist/types/rules/no-unsafe-selectors/constants.d.ts +1 -4
  16. package/index.js +9 -9
  17. package/package.json +3 -3
  18. package/scripts/codegen.tsx +223 -284
  19. package/src/rules/__tests__/utils/_tester.tsx +24 -24
  20. package/src/rules/atlaskit-theme/README.md +21 -19
  21. package/src/rules/atlaskit-theme/__tests__/test.ts +53 -53
  22. package/src/rules/atlaskit-theme/index.ts +107 -115
  23. package/src/rules/convert-props-syntax/README.md +32 -22
  24. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +46 -46
  25. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +175 -175
  26. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +52 -52
  27. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +33 -33
  28. package/src/rules/convert-props-syntax/index.tsx +356 -386
  29. package/src/rules/enforce-style-prop/README.md +21 -18
  30. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +90 -96
  31. package/src/rules/enforce-style-prop/index.tsx +144 -160
  32. package/src/rules/external-rules.tsx +163 -164
  33. package/src/rules/local-cx-xcss/README.md +10 -6
  34. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +26 -26
  35. package/src/rules/local-cx-xcss/index.tsx +46 -56
  36. package/src/rules/no-array-arguments/README.md +2 -1
  37. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +37 -46
  38. package/src/rules/no-array-arguments/index.tsx +68 -69
  39. package/src/rules/no-classname-prop/README.md +7 -4
  40. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +22 -22
  41. package/src/rules/no-classname-prop/index.tsx +25 -25
  42. package/src/rules/no-container-queries/README.md +11 -9
  43. package/src/rules/no-container-queries/__tests__/rule.test.tsx +47 -50
  44. package/src/rules/no-container-queries/index.tsx +75 -81
  45. package/src/rules/no-dynamic-styles/README.md +16 -19
  46. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +58 -67
  47. package/src/rules/no-dynamic-styles/index.tsx +45 -48
  48. package/src/rules/no-exported-styles/README.md +17 -12
  49. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +102 -111
  50. package/src/rules/no-exported-styles/index.tsx +36 -36
  51. package/src/rules/no-global-styles/README.md +15 -14
  52. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +28 -28
  53. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +37 -37
  54. package/src/rules/no-global-styles/index.tsx +59 -62
  55. package/src/rules/no-important-styles/README.md +5 -3
  56. package/src/rules/no-important-styles/__tests__/rule.test.tsx +66 -66
  57. package/src/rules/no-important-styles/index.tsx +49 -49
  58. package/src/rules/no-imported-style-values/README.md +23 -15
  59. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +123 -123
  60. package/src/rules/no-imported-style-values/index.tsx +116 -120
  61. package/src/rules/no-nested-selectors/README.md +15 -13
  62. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +141 -128
  63. package/src/rules/no-styled/README.md +14 -9
  64. package/src/rules/no-styled/__tests__/rule.test.tsx +31 -31
  65. package/src/rules/no-styled/index.tsx +34 -41
  66. package/src/rules/no-unsafe-selectors/README.md +103 -93
  67. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +21 -24
  68. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +44 -44
  69. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +21 -21
  70. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +57 -57
  71. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +58 -58
  72. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +85 -85
  73. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +12 -12
  74. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +23 -23
  75. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +133 -114
  76. package/src/rules/no-unsafe-selectors/constants.tsx +69 -77
  77. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +38 -38
  78. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +178 -184
  79. package/src/rules/no-unsafe-values/README.md +34 -40
  80. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +13 -13
  81. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +18 -18
  82. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +104 -104
  83. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +128 -128
  84. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +23 -23
  85. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +38 -38
  86. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +18 -18
  87. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +18 -18
  88. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +28 -28
  89. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +47 -47
  90. package/src/rules/no-unsafe-values/index.tsx +76 -78
  91. package/src/rules/no-unsafe-values/messages.tsx +12 -12
  92. package/src/rules/no-unsafe-values/utils.tsx +370 -382
  93. package/src/rules/use-compiled/README.md +11 -8
  94. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +32 -32
  95. package/src/rules/use-compiled/__tests__/css.test.tsx +53 -53
  96. package/src/rules/use-compiled/__tests__/imports.test.tsx +90 -95
  97. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +47 -47
  98. package/src/rules/use-compiled/__tests__/pragma.test.tsx +64 -64
  99. package/src/rules/use-compiled/__tests__/styled.test.tsx +53 -53
  100. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +10 -10
  101. package/src/rules/use-compiled/index.tsx +203 -226
  102. package/src/rules/use-compiled/is-safe.tsx +113 -117
  103. package/src/rules/use-compiled/utils.tsx +14 -18
  104. package/src/rules/utils/create-rule-with-typed-config.tsx +62 -63
  105. package/src/rules/utils/create-rule.tsx +3 -6
@@ -5,81 +5,78 @@ import { createLintRule } from '../utils/create-rule';
5
5
  const restrictedFileTypes = ['.css', '.less', '.sass', '.scss'];
6
6
 
7
7
  const restrictedImports = {
8
- '@emotion/core': ['Global'],
9
- '@emotion/react': ['Global'],
10
- 'styled-components': ['createGlobalStyle', 'injectGlobal'],
8
+ '@emotion/core': ['Global'],
9
+ '@emotion/react': ['Global'],
10
+ 'styled-components': ['createGlobalStyle', 'injectGlobal'],
11
11
  };
12
12
 
13
13
  type RestrictedImportSource = keyof typeof restrictedImports;
14
- function isRestrictedImportSource(
15
- importSource: string,
16
- ): importSource is RestrictedImportSource {
17
- return importSource in restrictedImports;
14
+ function isRestrictedImportSource(importSource: string): importSource is RestrictedImportSource {
15
+ return importSource in restrictedImports;
18
16
  }
19
17
 
20
18
  export const rule = createLintRule({
21
- meta: {
22
- name: 'no-global-styles',
23
- docs: {
24
- description:
25
- 'Prevents global styles through CSS-in-JS or CSS module imports',
26
- recommended: true,
27
- severity: 'warn',
28
- },
29
- messages: {
30
- 'no-global-styles': 'Global styles are not allowed.',
31
- 'no-css-modules': 'Importing CSS files is not allowed.',
32
- },
33
- type: 'problem',
34
- },
35
- create(context) {
36
- function checkFileType(node: ESTree.ImportDeclaration) {
37
- const importSource = node.source.value as string;
38
- if (restrictedFileTypes.some((suffix) => importSource.endsWith(suffix))) {
39
- context.report({
40
- node: node.source,
41
- messageId: 'no-css-modules',
42
- });
43
- }
44
- }
19
+ meta: {
20
+ name: 'no-global-styles',
21
+ docs: {
22
+ description: 'Prevents global styles through CSS-in-JS or CSS module imports',
23
+ recommended: true,
24
+ severity: 'warn',
25
+ },
26
+ messages: {
27
+ 'no-global-styles': 'Global styles are not allowed.',
28
+ 'no-css-modules': 'Importing CSS files is not allowed.',
29
+ },
30
+ type: 'problem',
31
+ },
32
+ create(context) {
33
+ function checkFileType(node: ESTree.ImportDeclaration) {
34
+ const importSource = node.source.value as string;
35
+ if (restrictedFileTypes.some((suffix) => importSource.endsWith(suffix))) {
36
+ context.report({
37
+ node: node.source,
38
+ messageId: 'no-css-modules',
39
+ });
40
+ }
41
+ }
45
42
 
46
- function checkImports(node: ESTree.ImportDeclaration) {
47
- const importSource = node.source.value as string;
48
- if (!isRestrictedImportSource(importSource)) {
49
- return;
50
- }
43
+ function checkImports(node: ESTree.ImportDeclaration) {
44
+ const importSource = node.source.value as string;
45
+ if (!isRestrictedImportSource(importSource)) {
46
+ return;
47
+ }
51
48
 
52
- for (const importName of restrictedImports[importSource]) {
53
- const specifier = node.specifiers
54
- .filter(isImportSpecifier)
55
- .find((specifier) => specifier.imported.name === importName);
49
+ for (const importName of restrictedImports[importSource]) {
50
+ const specifier = node.specifiers
51
+ .filter(isImportSpecifier)
52
+ .find((specifier) => specifier.imported.name === importName);
56
53
 
57
- if (specifier) {
58
- context.report({
59
- node: specifier,
60
- messageId: 'no-global-styles',
61
- });
62
- }
63
- }
64
- }
54
+ if (specifier) {
55
+ context.report({
56
+ node: specifier,
57
+ messageId: 'no-global-styles',
58
+ });
59
+ }
60
+ }
61
+ }
65
62
 
66
- return {
67
- ImportDeclaration(node: ESTree.ImportDeclaration) {
68
- checkFileType(node);
69
- checkImports(node);
70
- },
71
- 'JSXOpeningElement[name.name="style"]'(node: ESTree.Node) {
72
- context.report({
73
- node,
74
- messageId: 'no-global-styles',
75
- });
76
- },
77
- };
78
- },
63
+ return {
64
+ ImportDeclaration(node: ESTree.ImportDeclaration) {
65
+ checkFileType(node);
66
+ checkImports(node);
67
+ },
68
+ 'JSXOpeningElement[name.name="style"]'(node: ESTree.Node) {
69
+ context.report({
70
+ node,
71
+ messageId: 'no-global-styles',
72
+ });
73
+ },
74
+ };
75
+ },
79
76
  });
80
77
 
81
78
  export default rule;
82
79
 
83
80
  function isImportSpecifier(node: ESTree.Node): node is ESTree.ImportSpecifier {
84
- return node.type === 'ImportSpecifier';
81
+ return node.type === 'ImportSpecifier';
85
82
  }
@@ -1,6 +1,8 @@
1
1
  This rule prevents the usage of the `!important` flag in style declarations.
2
2
 
3
- Properly composed styles will never need an `!important` flag. It is used to override specificity when working across different scopes, and the UI Styling Standard enforces styles with minimal scope.
3
+ Properly composed styles will never need an `!important` flag. It is used to override specificity
4
+ when working across different scopes, and the UI Styling Standard enforces styles with minimal
5
+ scope.
4
6
 
5
7
  The use of `!important` is a code smell and greatly impacts readability and determinism.
6
8
 
@@ -12,7 +14,7 @@ The use of `!important` is a code smell and greatly impacts readability and dete
12
14
  import { css } from '@compiled/react';
13
15
 
14
16
  const styles = css({
15
- color: 'red!important',
17
+ color: 'red!important',
16
18
  });
17
19
  ```
18
20
 
@@ -22,6 +24,6 @@ const styles = css({
22
24
  import { css } from '@compiled/react';
23
25
 
24
26
  const styles = css({
25
- color: 'red',
27
+ color: 'red',
26
28
  });
27
29
  ```
@@ -2,56 +2,56 @@ import { tester } from '../../__tests__/utils/_tester';
2
2
  import rule from '../index';
3
3
 
4
4
  tester.run('no-important-styles', rule, {
5
- valid: [
6
- `
5
+ valid: [
6
+ `
7
7
  import { css } from '@compiled/react';
8
8
 
9
9
  const styles = css({
10
10
  color: 'red'
11
11
  });
12
12
  `,
13
- {
14
- name: 'custom import sources (subtractive)',
15
- code: `
13
+ {
14
+ name: 'custom import sources (subtractive)',
15
+ code: `
16
16
  import { css } from '@compiled/react';
17
17
 
18
18
  const styles = css({
19
19
  color: 'red !important'
20
20
  });
21
21
  `,
22
- options: [
23
- {
24
- importSources: [],
25
- },
26
- ],
27
- },
28
- ],
29
- invalid: [
30
- {
31
- name: 'basic test case',
32
- code: `
22
+ options: [
23
+ {
24
+ importSources: [],
25
+ },
26
+ ],
27
+ },
28
+ ],
29
+ invalid: [
30
+ {
31
+ name: 'basic test case',
32
+ code: `
33
33
  import { css } from '@compiled/react';
34
34
 
35
35
  const styles = css({
36
36
  color: 'red !important'
37
37
  });
38
38
  `,
39
- errors: [{ messageId: 'no-important-styles' }],
40
- },
41
- {
42
- name: 'whitespace handling',
43
- code: `
39
+ errors: [{ messageId: 'no-important-styles' }],
40
+ },
41
+ {
42
+ name: 'whitespace handling',
43
+ code: `
44
44
  import { css } from '@compiled/react';
45
45
 
46
46
  const styles = css({
47
47
  color: 'red !important '
48
48
  });
49
49
  `,
50
- errors: [{ messageId: 'no-important-styles' }],
51
- },
52
- {
53
- name: 'nesting',
54
- code: `
50
+ errors: [{ messageId: 'no-important-styles' }],
51
+ },
52
+ {
53
+ name: 'nesting',
54
+ code: `
55
55
  import { css } from '@compiled/react';
56
56
 
57
57
  const styles = css({
@@ -65,11 +65,11 @@ tester.run('no-important-styles', rule, {
65
65
  }
66
66
  });
67
67
  `,
68
- errors: [{ messageId: 'no-important-styles' }],
69
- },
70
- {
71
- name: 'styled API',
72
- code: `
68
+ errors: [{ messageId: 'no-important-styles' }],
69
+ },
70
+ {
71
+ name: 'styled API',
72
+ code: `
73
73
  import { styled } from '@compiled/react';
74
74
 
75
75
  const Component = styled.div({
@@ -83,11 +83,11 @@ tester.run('no-important-styles', rule, {
83
83
  }
84
84
  });
85
85
  `,
86
- errors: [{ messageId: 'no-important-styles' }],
87
- },
88
- {
89
- name: 'keyframes API',
90
- code: `
86
+ errors: [{ messageId: 'no-important-styles' }],
87
+ },
88
+ {
89
+ name: 'keyframes API',
90
+ code: `
91
91
  import { keyframes } from '@compiled/react';
92
92
 
93
93
  const fadeOut = keyframes({
@@ -99,11 +99,11 @@ tester.run('no-important-styles', rule, {
99
99
  },
100
100
  });
101
101
  `,
102
- errors: [{ messageId: 'no-important-styles' }],
103
- },
104
- {
105
- name: 'cssMap API',
106
- code: `
102
+ errors: [{ messageId: 'no-important-styles' }],
103
+ },
104
+ {
105
+ name: 'cssMap API',
106
+ code: `
107
107
  import { cssMap } from '@compiled/react';
108
108
 
109
109
  const borderStyleMap = cssMap({
@@ -111,34 +111,34 @@ tester.run('no-important-styles', rule, {
111
111
  solid: { borderStyle: 'solid' },
112
112
  });
113
113
  `,
114
- errors: [{ messageId: 'no-important-styles' }],
115
- },
116
- {
117
- name: 'xcss API',
118
- code: `
114
+ errors: [{ messageId: 'no-important-styles' }],
115
+ },
116
+ {
117
+ name: 'xcss API',
118
+ code: `
119
119
  import { xcss } from '@atlaskit/primitives';
120
120
 
121
121
  const styles = xcss({
122
122
  display: 'block !important'
123
123
  });
124
124
  `,
125
- errors: [{ messageId: 'no-important-styles' }],
126
- },
127
- {
128
- name: 'custom import sources (additive)',
129
- code: `
125
+ errors: [{ messageId: 'no-important-styles' }],
126
+ },
127
+ {
128
+ name: 'custom import sources (additive)',
129
+ code: `
130
130
  import { css } from 'custom-library';
131
131
 
132
132
  const styles = css({
133
133
  color: 'red !important'
134
134
  });
135
135
  `,
136
- errors: [{ messageId: 'no-important-styles' }],
137
- options: [{ importSources: ['custom-library'] }],
138
- },
139
- {
140
- name: 'template string',
141
- code: `
136
+ errors: [{ messageId: 'no-important-styles' }],
137
+ options: [{ importSources: ['custom-library'] }],
138
+ },
139
+ {
140
+ name: 'template string',
141
+ code: `
142
142
  import { css } from '@compiled/react';
143
143
 
144
144
  const color = 'red';
@@ -147,19 +147,19 @@ tester.run('no-important-styles', rule, {
147
147
  color: \`\${color}!important\`
148
148
  });
149
149
  `,
150
- errors: [{ messageId: 'no-important-styles' }],
151
- },
152
- {
153
- name: 'uses default when options object is provided without importSources',
154
- code: `
150
+ errors: [{ messageId: 'no-important-styles' }],
151
+ },
152
+ {
153
+ name: 'uses default when options object is provided without importSources',
154
+ code: `
155
155
  import { css } from '@compiled/react';
156
156
 
157
157
  const styles = css({
158
158
  color: 'red !important'
159
159
  });
160
160
  `,
161
- errors: [{ messageId: 'no-important-styles' }],
162
- options: [{}],
163
- },
164
- ],
161
+ errors: [{ messageId: 'no-important-styles' }],
162
+ options: [{}],
163
+ },
164
+ ],
165
165
  });
@@ -7,64 +7,64 @@ import { importSources } from '@atlaskit/eslint-utils/schema';
7
7
  import { createLintRuleWithTypedConfig } from '../utils/create-rule-with-typed-config';
8
8
 
9
9
  export const rule = createLintRuleWithTypedConfig({
10
- meta: {
11
- name: 'no-important-styles',
12
- docs: {
13
- description: 'Disallows important style declarations',
14
- recommended: true,
15
- severity: 'warn',
16
- },
17
- messages: {
18
- 'no-important-styles':
19
- 'Important style declarations are disallowed. Refactor so the `!important` flag is not needed.',
20
- },
21
- type: 'problem',
22
- schema: {
23
- type: 'object',
24
- properties: {
25
- importSources,
26
- },
27
- },
28
- },
29
- create(context, { importSources }) {
30
- return {
31
- CallExpression(node) {
32
- const { references } = context.getScope();
10
+ meta: {
11
+ name: 'no-important-styles',
12
+ docs: {
13
+ description: 'Disallows important style declarations',
14
+ recommended: true,
15
+ severity: 'warn',
16
+ },
17
+ messages: {
18
+ 'no-important-styles':
19
+ 'Important style declarations are disallowed. Refactor so the `!important` flag is not needed.',
20
+ },
21
+ type: 'problem',
22
+ schema: {
23
+ type: 'object',
24
+ properties: {
25
+ importSources,
26
+ },
27
+ },
28
+ },
29
+ create(context, { importSources }) {
30
+ return {
31
+ CallExpression(node) {
32
+ const { references } = context.getScope();
33
33
 
34
- if (!hasStyleObjectArguments(node.callee, references, importSources)) {
35
- return;
36
- }
34
+ if (!hasStyleObjectArguments(node.callee, references, importSources)) {
35
+ return;
36
+ }
37
37
 
38
- const matches = esquery(node, 'Property');
39
- for (const match of matches) {
40
- if (match.type !== 'Property') {
41
- return;
42
- }
38
+ const matches = esquery(node, 'Property');
39
+ for (const match of matches) {
40
+ if (match.type !== 'Property') {
41
+ return;
42
+ }
43
43
 
44
- if (isImportant(match.value)) {
45
- context.report({
46
- node: match.value,
47
- messageId: 'no-important-styles',
48
- });
49
- }
50
- }
51
- },
52
- };
53
- },
44
+ if (isImportant(match.value)) {
45
+ context.report({
46
+ node: match.value,
47
+ messageId: 'no-important-styles',
48
+ });
49
+ }
50
+ }
51
+ },
52
+ };
53
+ },
54
54
  });
55
55
 
56
56
  export default rule;
57
57
 
58
58
  const importantRegex = /!\s*important\s*$/;
59
59
  function isImportant(node: Property['value']): boolean {
60
- if (node.type === 'Literal') {
61
- return typeof node.value === 'string' && importantRegex.test(node.value);
62
- }
60
+ if (node.type === 'Literal') {
61
+ return typeof node.value === 'string' && importantRegex.test(node.value);
62
+ }
63
63
 
64
- if (node.type === 'TemplateLiteral') {
65
- const joinedRaw = node.quasis.map((element) => element.value.raw).join('');
66
- return importantRegex.test(joinedRaw);
67
- }
64
+ if (node.type === 'TemplateLiteral') {
65
+ const joinedRaw = node.quasis.map((element) => element.value.raw).join('');
66
+ return importantRegex.test(joinedRaw);
67
+ }
68
68
 
69
- return false;
69
+ return false;
70
70
  }
@@ -1,6 +1,10 @@
1
- This rule disallows using imported style values in `css`, `cssMap`, `styled`, `keyframes` and `xcss` calls.
1
+ This rule disallows using imported style values in `css`, `cssMap`, `styled`, `keyframes` and `xcss`
2
+ calls.
2
3
 
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
+ Importing style values may result in unexpected errors when used in these APIs, because its value
5
+ will be null at runtime when using `@compiled/react`. Additionally, co-locating style definitions
6
+ with their usage is considered best practice in order to improve code readability and build
7
+ performance.
4
8
 
5
9
  ## Examples
6
10
 
@@ -11,8 +15,8 @@ import { css } from '@compiled/react';
11
15
  import { colors, getColor } from '@mui/theme';
12
16
 
13
17
  const styles = css({
14
- [colorKey]: getColor('red'),
15
- background: colors['red'],
18
+ [colorKey]: getColor('red'),
19
+ background: colors['red'],
16
20
  });
17
21
  ```
18
22
 
@@ -24,10 +28,10 @@ import { ff } from '@atlaskit/ff';
24
28
  const sharedObject = { padding: 0 };
25
29
 
26
30
  const styles = css({
27
- ...cssShared,
28
- ...sharedObject,
29
- height: `${HEIGHT}px`,
30
- width: ff('…') ? `${HEIGHT}px` : undefined,
31
+ ...cssShared,
32
+ ...sharedObject,
33
+ height: `${HEIGHT}px`,
34
+ width: ff('…') ? `${HEIGHT}px` : undefined,
31
35
  });
32
36
  ```
33
37
 
@@ -38,7 +42,7 @@ import { css } from '@compiled/react';
38
42
  import { buttonStyles } from '../shared';
39
43
 
40
44
  const styles = css({
41
- color: 'red',
45
+ color: 'red',
42
46
  });
43
47
 
44
48
  export default () => <div css={[styles, buttonStyles]} />;
@@ -54,15 +58,16 @@ export default () => <div style={{ width: importedWidth }} />;
54
58
 
55
59
  ### Correct
56
60
 
57
- Co-locate your styles next to your components to improve code readability, linting, and build performance.
61
+ Co-locate your styles next to your components to improve code readability, linting, and build
62
+ performance.
58
63
 
59
64
  ```js
60
65
  import { css } from '@compiled/react';
61
66
  import { token } from '@atlaskit/tokens';
62
67
 
63
68
  const styles = css({
64
- color: 'red',
65
- padding: token('space.150'),
69
+ color: 'red',
70
+ padding: token('space.150'),
66
71
  });
67
72
  export const Component = ({ children }) => <div css={styles}>{children}></div>;
68
73
  ```
@@ -81,7 +86,8 @@ export const Component = ({ children }) => <div css={styles}>{children}></div>;
81
86
 
82
87
  Use this to allow specified imports as dynamic keys, in addition to the built-in allow-list.
83
88
 
84
- Each value should be a two-element array. The first item is the entrypoint, and the second item is a named export.
89
+ Each value should be a two-element array. The first item is the entrypoint, and the second item is a
90
+ named export.
85
91
 
86
92
  Default imports are not supported.
87
93
 
@@ -107,7 +113,8 @@ Default imports are not supported.
107
113
 
108
114
  Use this to allow specific functions to be called, in addition to the built-in allow-list.
109
115
 
110
- Each value should be a two-element array. The first item is the entrypoint, and the second item is a named export.
116
+ Each value should be a two-element array. The first item is the entrypoint, and the second item is a
117
+ named export.
111
118
 
112
119
  Default imports are not currently supported.
113
120
 
@@ -141,4 +148,5 @@ By default, this rule will check `css` usages from:
141
148
  - `@emotion/styled`
142
149
  - `styled-components`
143
150
 
144
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
151
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an
152
+ array of package names (strings).