@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
@@ -2,14 +2,14 @@ import { typescriptEslintTester } from '../../__tests__/utils/_tester';
2
2
  import rule from '../index';
3
3
 
4
4
  typescriptEslintTester.run(
5
- 'no-imported-style-values',
6
- // @ts-expect-error
7
- rule,
8
- {
9
- valid: [
10
- {
11
- name: 'Basic valid test for css',
12
- code: `
5
+ 'no-imported-style-values',
6
+ // @ts-expect-error
7
+ rule,
8
+ {
9
+ valid: [
10
+ {
11
+ name: 'Basic valid test for css',
12
+ code: `
13
13
  import { css } from '@compiled/react';
14
14
  const sharedObject = { padding: 0 };
15
15
  const styles = css({
@@ -17,10 +17,10 @@ typescriptEslintTester.run(
17
17
  color: 'red',
18
18
  });
19
19
  `,
20
- },
21
- {
22
- name: 'Valid emotion css call',
23
- code: `
20
+ },
21
+ {
22
+ name: 'Valid emotion css call',
23
+ code: `
24
24
  import { css } from '@emotion/react';
25
25
  import { CURRENT_SURFACE_CSS_VAR, token } from '@atlaskit/tokens';
26
26
  const styles = css({
@@ -29,20 +29,20 @@ typescriptEslintTester.run(
29
29
  [CURRENT_SURFACE_CSS_VAR]: token('elevation.surface.overlay', N0),
30
30
  });
31
31
  `,
32
- },
33
- {
34
- name: 'Valid styled component',
35
- code: `
32
+ },
33
+ {
34
+ name: 'Valid styled component',
35
+ code: `
36
36
  import { styled } from '@compiled/react';
37
37
  import { token } from '@atlaskit/tokens';
38
38
  const Component = styled.div({
39
39
  borderRadius: token('border.radius', '3px')
40
40
  })
41
41
  `,
42
- },
43
- {
44
- name: 'Variables defined in same file',
45
- code: `
42
+ },
43
+ {
44
+ name: 'Variables defined in same file',
45
+ code: `
46
46
  import { css } from '@compiled/react';
47
47
  const color = 'red',
48
48
  const containerWidth = 0;
@@ -51,20 +51,20 @@ typescriptEslintTester.run(
51
51
  width: containerWidth
52
52
  });
53
53
  `,
54
- },
55
- {
56
- name: 'Importing token function',
57
- code: `
54
+ },
55
+ {
56
+ name: 'Importing token function',
57
+ code: `
58
58
  import { css } from '@compiled/react';
59
59
  import { token } from '@atlaskit/tokens';
60
60
  const styles = css({
61
61
  padding: token('space.150'),
62
62
  });
63
63
  `,
64
- },
65
- {
66
- name: 'Valid cssMap call',
67
- code: `
64
+ },
65
+ {
66
+ name: 'Valid cssMap call',
67
+ code: `
68
68
  import { cssMap } from '@compiled/react';
69
69
  import { token } from '@atlaskit/tokens';
70
70
  const styles = cssMap({
@@ -77,57 +77,57 @@ typescriptEslintTester.run(
77
77
  },
78
78
  });
79
79
  `,
80
- },
81
- {
82
- name: 'Custom import sources (subtractive)',
83
- code: `
80
+ },
81
+ {
82
+ name: 'Custom import sources (subtractive)',
83
+ code: `
84
84
  import { css } from '@compiled/react';
85
85
  import { color } from '../shared'
86
86
  const styles = css({
87
87
  color
88
88
  });
89
89
  `,
90
- options: [
91
- {
92
- importSources: [],
93
- },
94
- ],
95
- },
96
- {
97
- name: 'Custom allowed function',
98
- code: `
90
+ options: [
91
+ {
92
+ importSources: [],
93
+ },
94
+ ],
95
+ },
96
+ {
97
+ name: 'Custom allowed function',
98
+ code: `
99
99
  import { css } from '@compiled/react';
100
100
  import { getColor } from 'my-package'
101
101
  const styles = css({
102
102
  color: getColor()
103
103
  });
104
104
  `,
105
- options: [
106
- {
107
- allowedFunctionCalls: [['my-package', 'getColor']],
108
- },
109
- ],
110
- },
111
- {
112
- name: 'Custom allowed dynamic key',
113
- code: `
105
+ options: [
106
+ {
107
+ allowedFunctionCalls: [['my-package', 'getColor']],
108
+ },
109
+ ],
110
+ },
111
+ {
112
+ name: 'Custom allowed dynamic key',
113
+ code: `
114
114
  import { css } from '@compiled/react';
115
115
  import { colorKey } from 'my-package';
116
116
  const styles = css({
117
117
  [colorKey]: 'red',
118
118
  });
119
119
  `,
120
- options: [
121
- {
122
- allowedDynamicKeys: [['my-package', 'colorKey']],
123
- },
124
- ],
125
- },
126
- ],
127
- invalid: [
128
- {
129
- name: 'Importing spreadElement',
130
- code: `
120
+ options: [
121
+ {
122
+ allowedDynamicKeys: [['my-package', 'colorKey']],
123
+ },
124
+ ],
125
+ },
126
+ ],
127
+ invalid: [
128
+ {
129
+ name: 'Importing spreadElement',
130
+ code: `
131
131
  import { css } from '@compiled/react';
132
132
  import { importedStyles } from '../shared';
133
133
  const styles = css({
@@ -135,11 +135,11 @@ typescriptEslintTester.run(
135
135
  color: 'red',
136
136
  });
137
137
  `,
138
- errors: [{ messageId: 'no-imported-style-values' }],
139
- },
140
- {
141
- name: 'Importing functions to use within css',
142
- code: `
138
+ errors: [{ messageId: 'no-imported-style-values' }],
139
+ },
140
+ {
141
+ name: 'Importing functions to use within css',
142
+ code: `
143
143
  import { css } from '@compiled/react';
144
144
  import { getColor } from '@mui/theme';
145
145
  import { colorKey } from '../shared';
@@ -147,36 +147,36 @@ typescriptEslintTester.run(
147
147
  [colorKey]: getColor('red'),
148
148
  });
149
149
  `,
150
- errors: [
151
- { messageId: 'no-imported-style-values' },
152
- { messageId: 'no-imported-style-values' },
153
- ],
154
- },
155
- {
156
- name: 'Importing objects to use within css',
157
- code: `
150
+ errors: [
151
+ { messageId: 'no-imported-style-values' },
152
+ { messageId: 'no-imported-style-values' },
153
+ ],
154
+ },
155
+ {
156
+ name: 'Importing objects to use within css',
157
+ code: `
158
158
  import { css } from '@compiled/react';
159
159
  import { colors } from '@mui/theme';
160
160
  const styles = css({
161
161
  background: colors['red'],
162
162
  });
163
163
  `,
164
- errors: [{ messageId: 'no-imported-style-values' }],
165
- },
166
- {
167
- name: 'Importing variables to use within template literal',
168
- code: `
164
+ errors: [{ messageId: 'no-imported-style-values' }],
165
+ },
166
+ {
167
+ name: 'Importing variables to use within template literal',
168
+ code: `
169
169
  import { css } from '@compiled/react';
170
170
  import { HEIGHT } from '../shared';
171
171
  const styles = css({
172
172
  height: \`\${HEIGHT}px\`,
173
173
  });
174
174
  `,
175
- errors: [{ messageId: 'no-imported-style-values' }],
176
- },
177
- {
178
- name: 'Importing variables to within conditional expression',
179
- code: `
175
+ errors: [{ messageId: 'no-imported-style-values' }],
176
+ },
177
+ {
178
+ name: 'Importing variables to within conditional expression',
179
+ code: `
180
180
  import { css } from '@compiled/react';
181
181
  import { ff } from '@atlaskit/ff';
182
182
  import { HEIGHT } from '../shared';
@@ -184,14 +184,14 @@ typescriptEslintTester.run(
184
184
  width: ff('…') ? \`\${HEIGHT}px\` : undefined,
185
185
  });
186
186
  `,
187
- errors: [
188
- { messageId: 'no-imported-style-values' },
189
- { messageId: 'no-imported-style-values' },
190
- ],
191
- },
192
- {
193
- name: 'Invalid styled component',
194
- code: `
187
+ errors: [
188
+ { messageId: 'no-imported-style-values' },
189
+ { messageId: 'no-imported-style-values' },
190
+ ],
191
+ },
192
+ {
193
+ name: 'Invalid styled component',
194
+ code: `
195
195
  import { styled } from '@compiled/react';
196
196
  import { HEIGHT, importedStyles, getWidth } from '../shared';
197
197
 
@@ -203,15 +203,15 @@ typescriptEslintTester.run(
203
203
  width: getWidth(10),
204
204
  });
205
205
  `,
206
- errors: [
207
- { messageId: 'no-imported-style-values' },
208
- { messageId: 'no-imported-style-values' },
209
- { messageId: 'no-imported-style-values' },
210
- ],
211
- },
212
- {
213
- name: 'Invalid cssMap call',
214
- code: `
206
+ errors: [
207
+ { messageId: 'no-imported-style-values' },
208
+ { messageId: 'no-imported-style-values' },
209
+ { messageId: 'no-imported-style-values' },
210
+ ],
211
+ },
212
+ {
213
+ name: 'Invalid cssMap call',
214
+ code: `
215
215
  import { cssMap } from '@compiled/react';
216
216
  import { textColor, bgColor } from '../shared';
217
217
 
@@ -220,14 +220,14 @@ typescriptEslintTester.run(
220
220
  bg: { background: bgColor },
221
221
  });
222
222
  `,
223
- errors: [
224
- { messageId: 'no-imported-style-values' },
225
- { messageId: 'no-imported-style-values' },
226
- ],
227
- },
228
- {
229
- name: 'Invalid style composition in css prop',
230
- code: `
223
+ errors: [
224
+ { messageId: 'no-imported-style-values' },
225
+ { messageId: 'no-imported-style-values' },
226
+ ],
227
+ },
228
+ {
229
+ name: 'Invalid style composition in css prop',
230
+ code: `
231
231
  import { css } from '@compiled/react';
232
232
  import { buttonStyles } from '../shared';
233
233
 
@@ -237,20 +237,20 @@ typescriptEslintTester.run(
237
237
 
238
238
  export default () => <div css={[styles, buttonStyles]} />;
239
239
  `,
240
- errors: [{ messageId: 'no-imported-style-values' }],
241
- },
242
- {
243
- name: 'Importing value within style prop',
244
- code: `
240
+ errors: [{ messageId: 'no-imported-style-values' }],
241
+ },
242
+ {
243
+ name: 'Importing value within style prop',
244
+ code: `
245
245
  import { importedWidth } from '../shared';
246
246
 
247
247
  export default () => <div style={{ width: importedWidth }} />;
248
248
  `,
249
- errors: [{ messageId: 'no-imported-style-values' }],
250
- },
251
- {
252
- name: 'Importing member expression',
253
- code: `
249
+ errors: [{ messageId: 'no-imported-style-values' }],
250
+ },
251
+ {
252
+ name: 'Importing member expression',
253
+ code: `
254
254
  import { hello } from 'package';
255
255
  import { css } from '@compiled/react';
256
256
 
@@ -258,8 +258,8 @@ typescriptEslintTester.run(
258
258
  color: hello.world,
259
259
  });
260
260
  `,
261
- errors: [{ messageId: 'no-imported-style-values' }],
262
- },
263
- ],
264
- },
261
+ errors: [{ messageId: 'no-imported-style-values' }],
262
+ },
263
+ ],
264
+ },
265
265
  );
@@ -1,154 +1,150 @@
1
1
  import { createLintRule } from '../utils/create-rule';
2
2
  import {
3
- getImportSources,
4
- hasStyleObjectArguments,
3
+ getImportSources,
4
+ hasStyleObjectArguments,
5
5
  } from '@atlaskit/eslint-utils/is-supported-import';
6
6
  import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
7
7
  import { findVariable } from '@atlaskit/eslint-utils/find-variable';
8
8
  import type { Rule } from 'eslint';
9
9
  import {
10
- type AllowList,
11
- getAllowedDynamicKeys,
12
- getAllowedFunctionCalls,
13
- isAllowListedVariable,
10
+ type AllowList,
11
+ getAllowedDynamicKeys,
12
+ getAllowedFunctionCalls,
13
+ isAllowListedVariable,
14
14
  } from '@atlaskit/eslint-utils/allowed-function-calls';
15
15
  import type { Identifier, Node } from 'eslint-codemod-utils';
16
16
  import esquery from 'esquery';
17
17
 
18
18
  const schema: JSONSchema4 = [
19
- {
20
- type: 'object',
21
- properties: {
22
- importSources: {
23
- type: 'array',
24
- items: { type: 'string' },
25
- uniqueItems: true,
26
- },
27
- allowedFunctionCalls: {
28
- type: 'array',
29
- items: {
30
- type: 'array',
31
- minItems: 2,
32
- maxItems: 2,
33
- items: [{ type: 'string' }, { type: 'string' }],
34
- },
35
- uniqueItems: true,
36
- },
37
- allowedDynamicKeys: {
38
- type: 'array',
39
- items: {
40
- type: 'array',
41
- minItems: 2,
42
- maxItems: 2,
43
- items: [{ type: 'string' }, { type: 'string' }],
44
- },
45
- uniqueItems: true,
46
- },
47
- },
48
- },
19
+ {
20
+ type: 'object',
21
+ properties: {
22
+ importSources: {
23
+ type: 'array',
24
+ items: { type: 'string' },
25
+ uniqueItems: true,
26
+ },
27
+ allowedFunctionCalls: {
28
+ type: 'array',
29
+ items: {
30
+ type: 'array',
31
+ minItems: 2,
32
+ maxItems: 2,
33
+ items: [{ type: 'string' }, { type: 'string' }],
34
+ },
35
+ uniqueItems: true,
36
+ },
37
+ allowedDynamicKeys: {
38
+ type: 'array',
39
+ items: {
40
+ type: 'array',
41
+ minItems: 2,
42
+ maxItems: 2,
43
+ items: [{ type: 'string' }, { type: 'string' }],
44
+ },
45
+ uniqueItems: true,
46
+ },
47
+ },
48
+ },
49
49
  ];
50
50
 
51
51
  const isIdentifierImported = (
52
- identifier: Identifier,
53
- context: Rule.RuleContext,
54
- functionAllowList: AllowList,
55
- keysAllowList: AllowList,
52
+ identifier: Identifier,
53
+ context: Rule.RuleContext,
54
+ functionAllowList: AllowList,
55
+ keysAllowList: AllowList,
56
56
  ): boolean => {
57
- const variable = findVariable({
58
- identifier: identifier,
59
- sourceCode: context.sourceCode,
60
- });
61
- if (!variable) {
62
- return false;
63
- }
57
+ const variable = findVariable({
58
+ identifier: identifier,
59
+ sourceCode: context.sourceCode,
60
+ });
61
+ if (!variable) {
62
+ return false;
63
+ }
64
64
 
65
- const isImported = variable.defs.some(
66
- (definition) => definition.type === 'ImportBinding',
67
- );
65
+ const isImported = variable.defs.some((definition) => definition.type === 'ImportBinding');
68
66
 
69
- // check if imported variable is allowed
70
- return (
71
- isImported &&
72
- !isAllowListedVariable({
73
- allowList: functionAllowList,
74
- variable,
75
- }) &&
76
- !isAllowListedVariable({ allowList: keysAllowList, variable })
77
- );
67
+ // check if imported variable is allowed
68
+ return (
69
+ isImported &&
70
+ !isAllowListedVariable({
71
+ allowList: functionAllowList,
72
+ variable,
73
+ }) &&
74
+ !isAllowListedVariable({ allowList: keysAllowList, variable })
75
+ );
78
76
  };
79
77
 
80
78
  const checkIdentifier = (
81
- identifier: Identifier,
82
- context: Rule.RuleContext,
83
- functionAllowList: AllowList,
84
- keysAllowList: AllowList,
79
+ identifier: Identifier,
80
+ context: Rule.RuleContext,
81
+ functionAllowList: AllowList,
82
+ keysAllowList: AllowList,
85
83
  ) => {
86
- if (
87
- isIdentifierImported(identifier, context, functionAllowList, keysAllowList)
88
- ) {
89
- context.report({
90
- node: identifier,
91
- messageId: 'no-imported-style-values',
92
- });
93
- }
84
+ if (isIdentifierImported(identifier, context, functionAllowList, keysAllowList)) {
85
+ context.report({
86
+ node: identifier,
87
+ messageId: 'no-imported-style-values',
88
+ });
89
+ }
94
90
  };
95
91
 
96
92
  export const rule = createLintRule({
97
- meta: {
98
- name: 'no-imported-style-values',
99
- docs: {
100
- description: 'Disallows imports of style values',
101
- recommended: true,
102
- severity: 'warn',
103
- },
104
- messages: {
105
- 'no-imported-style-values':
106
- '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.',
107
- },
108
- type: 'problem',
109
- schema,
110
- },
111
- create(context) {
112
- const importSources = getImportSources(context);
113
- const functionAllowList = getAllowedFunctionCalls(context.options);
114
- const keysAllowList = getAllowedDynamicKeys(context.options);
93
+ meta: {
94
+ name: 'no-imported-style-values',
95
+ docs: {
96
+ description: 'Disallows imports of style values',
97
+ recommended: true,
98
+ severity: 'warn',
99
+ },
100
+ messages: {
101
+ 'no-imported-style-values':
102
+ '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.',
103
+ },
104
+ type: 'problem',
105
+ schema,
106
+ },
107
+ create(context) {
108
+ const importSources = getImportSources(context);
109
+ const functionAllowList = getAllowedFunctionCalls(context.options);
110
+ const keysAllowList = getAllowedDynamicKeys(context.options);
115
111
 
116
- const checkForIdentifiers = (node: Node) => {
117
- const matches = esquery(node, 'Identifier');
112
+ const checkForIdentifiers = (node: Node) => {
113
+ const matches = esquery(node, 'Identifier');
118
114
 
119
- for (const match of matches) {
120
- if (match.type === 'Identifier') {
121
- checkIdentifier(match, context, functionAllowList, keysAllowList);
122
- }
123
- }
124
- };
115
+ for (const match of matches) {
116
+ if (match.type === 'Identifier') {
117
+ checkIdentifier(match, context, functionAllowList, keysAllowList);
118
+ }
119
+ }
120
+ };
125
121
 
126
- return {
127
- // Checking css/cssMap/keyframes/styled/xcss calls
128
- CallExpression(node) {
129
- const { references } = context.sourceCode.getScope(node.callee);
122
+ return {
123
+ // Checking css/cssMap/keyframes/styled/xcss calls
124
+ CallExpression(node) {
125
+ const { references } = context.sourceCode.getScope(node.callee);
130
126
 
131
- if (!hasStyleObjectArguments(node.callee, references, importSources)) {
132
- return;
133
- }
134
- node.arguments.forEach(checkForIdentifiers);
135
- },
136
- 'JSXAttribute[name.name="css"] Identifier': (node: Node) => {
137
- if (node.type !== 'Identifier') {
138
- return;
139
- }
127
+ if (!hasStyleObjectArguments(node.callee, references, importSources)) {
128
+ return;
129
+ }
130
+ node.arguments.forEach(checkForIdentifiers);
131
+ },
132
+ 'JSXAttribute[name.name="css"] Identifier': (node: Node) => {
133
+ if (node.type !== 'Identifier') {
134
+ return;
135
+ }
140
136
 
141
- checkIdentifier(node, context, functionAllowList, keysAllowList);
142
- },
143
- 'JSXAttribute[name.name="style"] Identifier': (node: Node) => {
144
- if (node.type !== 'Identifier') {
145
- return;
146
- }
137
+ checkIdentifier(node, context, functionAllowList, keysAllowList);
138
+ },
139
+ 'JSXAttribute[name.name="style"] Identifier': (node: Node) => {
140
+ if (node.type !== 'Identifier') {
141
+ return;
142
+ }
147
143
 
148
- checkIdentifier(node, context, functionAllowList, keysAllowList);
149
- },
150
- };
151
- },
144
+ checkIdentifier(node, context, functionAllowList, keysAllowList);
145
+ },
146
+ };
147
+ },
152
148
  });
153
149
 
154
150
  export default rule;