@atlaskit/eslint-plugin-ui-styling-standard 0.18.0 → 0.18.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 (137) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -1
  3. package/afm-cc/tsconfig.json +0 -28
  4. package/afm-jira/tsconfig.json +0 -27
  5. package/build/tsconfig.json +0 -18
  6. package/constellation/atlaskit-theme/usage.mdx +0 -132
  7. package/constellation/consistent-css-prop-usage/usage.mdx +0 -7
  8. package/constellation/convert-props-syntax/usage.mdx +0 -130
  9. package/constellation/enforce-style-prop/usage.mdx +0 -47
  10. package/constellation/index/migration-guide.mdx +0 -309
  11. package/constellation/index/overview.mdx +0 -250
  12. package/constellation/index/props.mdx +0 -30
  13. package/constellation/local-cx-xcss/usage.mdx +0 -53
  14. package/constellation/no-array-arguments/usage.mdx +0 -49
  15. package/constellation/no-classname-prop/usage.mdx +0 -49
  16. package/constellation/no-container-queries/usage.mdx +0 -101
  17. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -8
  18. package/constellation/no-dynamic-styles/usage.mdx +0 -130
  19. package/constellation/no-empty-styled-expression/usage.mdx +0 -8
  20. package/constellation/no-exported-css/usage.mdx +0 -8
  21. package/constellation/no-exported-keyframes/usage.mdx +0 -8
  22. package/constellation/no-exported-styles/usage.mdx +0 -87
  23. package/constellation/no-global-styles/usage.mdx +0 -60
  24. package/constellation/no-important-styles/usage.mdx +0 -33
  25. package/constellation/no-imported-style-values/usage.mdx +0 -157
  26. package/constellation/no-invalid-css-map/usage.mdx +0 -8
  27. package/constellation/no-js-xcss/usage.mdx +0 -7
  28. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -8
  29. package/constellation/no-nested-selectors/usage.mdx +0 -95
  30. package/constellation/no-styled/usage.mdx +0 -92
  31. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -8
  32. package/constellation/no-suppress-xcss/usage.mdx +0 -28
  33. package/constellation/no-unsafe-selectors/usage.mdx +0 -370
  34. package/constellation/no-unsafe-values/usage.mdx +0 -318
  35. package/constellation/use-compiled/usage.mdx +0 -54
  36. package/index.js +0 -24
  37. package/scripts/codegen.tsx +0 -373
  38. package/src/index.codegen.tsx +0 -14
  39. package/src/index.tsx +0 -1
  40. package/src/presets/all.codegen.tsx +0 -79
  41. package/src/presets/recommended.codegen.tsx +0 -79
  42. package/src/rules/TEMPLATE.md +0 -29
  43. package/src/rules/__tests__/utils/_tester.tsx +0 -40
  44. package/src/rules/atlaskit-theme/README.md +0 -130
  45. package/src/rules/atlaskit-theme/__tests__/test.ts +0 -133
  46. package/src/rules/atlaskit-theme/index.ts +0 -134
  47. package/src/rules/convert-props-syntax/README.md +0 -128
  48. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +0 -76
  49. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +0 -584
  50. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +0 -140
  51. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +0 -69
  52. package/src/rules/convert-props-syntax/index.tsx +0 -414
  53. package/src/rules/enforce-style-prop/README.md +0 -45
  54. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +0 -243
  55. package/src/rules/enforce-style-prop/index.tsx +0 -172
  56. package/src/rules/external-rules.tsx +0 -177
  57. package/src/rules/index.codegen.tsx +0 -42
  58. package/src/rules/local-cx-xcss/README.md +0 -51
  59. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +0 -102
  60. package/src/rules/local-cx-xcss/index.tsx +0 -62
  61. package/src/rules/no-array-arguments/README.md +0 -47
  62. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +0 -107
  63. package/src/rules/no-array-arguments/index.tsx +0 -86
  64. package/src/rules/no-classname-prop/README.md +0 -47
  65. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +0 -39
  66. package/src/rules/no-classname-prop/index.tsx +0 -34
  67. package/src/rules/no-container-queries/README.md +0 -99
  68. package/src/rules/no-container-queries/__tests__/rule.test.tsx +0 -139
  69. package/src/rules/no-container-queries/index.tsx +0 -94
  70. package/src/rules/no-dynamic-styles/README.md +0 -128
  71. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +0 -135
  72. package/src/rules/no-dynamic-styles/index.tsx +0 -60
  73. package/src/rules/no-exported-styles/README.md +0 -85
  74. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +0 -216
  75. package/src/rules/no-exported-styles/index.tsx +0 -52
  76. package/src/rules/no-global-styles/README.md +0 -58
  77. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +0 -33
  78. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +0 -46
  79. package/src/rules/no-global-styles/index.tsx +0 -82
  80. package/src/rules/no-important-styles/README.md +0 -31
  81. package/src/rules/no-important-styles/__tests__/rule.test.tsx +0 -165
  82. package/src/rules/no-important-styles/index.tsx +0 -70
  83. package/src/rules/no-imported-style-values/README.md +0 -155
  84. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +0 -491
  85. package/src/rules/no-imported-style-values/index.tsx +0 -188
  86. package/src/rules/no-nested-selectors/README.md +0 -93
  87. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +0 -335
  88. package/src/rules/no-nested-selectors/index.tsx +0 -99
  89. package/src/rules/no-styled/README.md +0 -90
  90. package/src/rules/no-styled/__tests__/rule.test.tsx +0 -73
  91. package/src/rules/no-styled/index.tsx +0 -45
  92. package/src/rules/no-unsafe-selectors/README.md +0 -368
  93. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +0 -368
  94. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +0 -57
  95. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +0 -73
  96. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +0 -40
  97. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +0 -101
  98. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +0 -131
  99. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +0 -132
  100. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +0 -25
  101. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +0 -35
  102. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +0 -257
  103. package/src/rules/no-unsafe-selectors/constants.tsx +0 -91
  104. package/src/rules/no-unsafe-selectors/index.tsx +0 -198
  105. package/src/rules/no-unsafe-selectors/lint-selector.tsx +0 -155
  106. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +0 -55
  107. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +0 -226
  108. package/src/rules/no-unsafe-values/README.md +0 -316
  109. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +0 -27
  110. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +0 -37
  111. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +0 -229
  112. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +0 -267
  113. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +0 -52
  114. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +0 -106
  115. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +0 -44
  116. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +0 -48
  117. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +0 -75
  118. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +0 -121
  119. package/src/rules/no-unsafe-values/index.tsx +0 -94
  120. package/src/rules/no-unsafe-values/messages.tsx +0 -86
  121. package/src/rules/no-unsafe-values/utils.tsx +0 -387
  122. package/src/rules/use-compiled/README.md +0 -52
  123. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +0 -73
  124. package/src/rules/use-compiled/__tests__/css.test.tsx +0 -126
  125. package/src/rules/use-compiled/__tests__/imports.test.tsx +0 -158
  126. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +0 -140
  127. package/src/rules/use-compiled/__tests__/pragma.test.tsx +0 -108
  128. package/src/rules/use-compiled/__tests__/styled.test.tsx +0 -114
  129. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +0 -15
  130. package/src/rules/use-compiled/index.tsx +0 -252
  131. package/src/rules/use-compiled/is-safe.tsx +0 -159
  132. package/src/rules/use-compiled/utils.tsx +0 -33
  133. package/src/rules/utils/create-rule-with-typed-config.tsx +0 -86
  134. package/src/rules/utils/create-rule.tsx +0 -13
  135. package/tsconfig.app.json +0 -47
  136. package/tsconfig.dev.json +0 -45
  137. package/tsconfig.json +0 -25
@@ -1,318 +0,0 @@
1
- # no-unsafe-values
2
-
3
- Blocks styles that are difficult or impossible to statically analyze.
4
-
5
- ## Examples
6
-
7
- ### Function calls
8
-
9
- #### Incorrect
10
-
11
- Function calls are blocked as arguments or as values, unless they are specified in
12
- `allowedFunctionCalls` (or in the default list).
13
-
14
- ```tsx
15
- import { css } from '@compiled/react';
16
-
17
- function getStyles() {
18
- return { width: 100 };
19
- }
20
-
21
- const styles = css(getStyles());
22
- ```
23
-
24
- ```tsx
25
- import { css } from '@compiled/react';
26
-
27
- function getWidth() {
28
- return 100;
29
- }
30
-
31
- const styles = css({
32
- width: getWidth(),
33
- });
34
- ```
35
-
36
- #### Correct
37
-
38
- Use inline literals for static values.
39
-
40
- ```tsx
41
- import { css } from '@compiled/react';
42
-
43
- const styles = css({ width: 100 });
44
- ```
45
-
46
- Use the `style` prop for dynamic values.
47
-
48
- ```tsx
49
- const Component = ({ width }) => <div style={{ width }} />;
50
- ```
51
-
52
- Some functions such as `tokens()` are allowed.
53
-
54
- ```tsx
55
- import { css } from '@compiled/react';
56
- import { token } from '@atlaskit/tokens';
57
-
58
- const styles = css({ padding: token('space.100') });
59
- ```
60
-
61
- ### Dynamic keys
62
-
63
- #### Incorrect
64
-
65
- Dynamic keys are blocked, unless they are specified in `allowedDynamicKeys` (or in the default
66
- list).
67
-
68
- ```tsx
69
- import { css } from '@compiled/react';
70
-
71
- const HOVER_SELECTOR = '&:hover';
72
- const MARGIN = 'margin';
73
-
74
- const styles = css({
75
- [HOVER_SELECTOR]: {
76
- [MARGIN]: 0,
77
- },
78
- [`${HOVER_SELECTOR} > p`]: {
79
- width: 100,
80
- },
81
- });
82
- ```
83
-
84
- #### Correct
85
-
86
- Use literal values for pseudo-states and property names.
87
-
88
- Don't use nested selectors, apply styles directly instead.
89
-
90
- ```tsx
91
- import { css } from '@compiled/react';
92
-
93
- const styles = css({
94
- '&:hover': {
95
- margin: 0,
96
- },
97
- });
98
-
99
- const paragraphStyles = css({
100
- width: 100,
101
- });
102
- ```
103
-
104
- ### Variables
105
-
106
- #### Incorrect
107
-
108
- Variables are only allowed as values if they:
109
-
110
- - have a simple, static value
111
- - are defined in the same file
112
-
113
- ```tsx
114
- import { css } from '@compiled/react';
115
- import { HEIGHT } from '../shared';
116
-
117
- const styles = css({
118
- height: HEIGHT,
119
- });
120
- ```
121
-
122
- #### Correct
123
-
124
- Use inlined values.
125
-
126
- ```tsx
127
- import { css } from '@compiled/react';
128
-
129
- const styles = css({
130
- height: '32px',
131
- });
132
- ```
133
-
134
- Alternatively, define variables in the same file.
135
-
136
- ```tsx
137
- import { css } from '@compiled/react';
138
-
139
- const HEIGHT = '32px';
140
-
141
- const styles = css({
142
- height: HEIGHT,
143
- });
144
- ```
145
-
146
- ### Object access
147
-
148
- #### Incorrect
149
-
150
- Don't access object members in values.
151
-
152
- ```tsx
153
- import { css } from '@compiled/react';
154
- import { token } from '@atlaskit/tokens';
155
-
156
- const colors = {
157
- text: token('color.text'),
158
- };
159
-
160
- const styles = css({
161
- color: colors.text,
162
- });
163
- ```
164
-
165
- #### Correct
166
-
167
- Use inlined values.
168
-
169
- ```tsx
170
- import { css } from '@compiled/react';
171
- import { token } from '@atlaskit/tokens';
172
-
173
- const styles = css({
174
- color: token('color.text'),
175
- });
176
- ```
177
-
178
- ### Spread elements
179
-
180
- #### Incorrect
181
-
182
- Don't use the spread operator in styles.
183
-
184
- ```tsx
185
- import { css } from '@compiled/react';
186
- import { token } from '@atlaskit/tokens';
187
-
188
- const subtleTextStyles = {
189
- color: token('color.text.subtle'),
190
- };
191
-
192
- const styles = css({
193
- ...subtleTextStyles,
194
- margin: 0,
195
- });
196
- ```
197
-
198
- #### Correct
199
-
200
- Use the `css` prop to compose styles.
201
-
202
- ```tsx
203
- import { css } from '@compiled/react';
204
- import { token } from '@atlaskit/tokens';
205
-
206
- const subtleTextStyles = {
207
- color: token('color.text.subtle'),
208
- };
209
-
210
- const styles = css({
211
- margin: 0,
212
- });
213
-
214
- const Component = () => <div css={[subtleTextStyles, styles]} />;
215
- ```
216
-
217
- ### Array values
218
-
219
- #### Incorrect
220
-
221
- Don't use array values. This syntax is not supported by Compiled, or most other CSS-in-JS libraries.
222
-
223
- ```tsx
224
- import { css } from '@compiled/react';
225
- import { token } from '@atlaskit/tokens';
226
-
227
- const boldMixin = { fontWeight: token('font.weight.bold') };
228
-
229
- const styles = css({
230
- '&::before': [boldMixin, { color: token('color.text.danger') }],
231
- });
232
- ```
233
-
234
- #### Correct
235
-
236
- Use a single object with inlined styles.
237
-
238
- ```tsx
239
- import { css } from '@compiled/react';
240
- import { token } from '@atlaskit/tokens';
241
-
242
- const styles = css({
243
- '&::before': {
244
- fontWeight: token('font.weight.bold'),
245
- color: token('color.text.danger'),
246
- },
247
- });
248
- ```
249
-
250
- ## Options
251
-
252
- ### `allowedDynamicKeys: [string, string][]`
253
-
254
- Use this to allow specified imports as dynamic keys, in addition to the built-in allow-list.
255
-
256
- Each value should be a two-element array. The first item is the entrypoint, and the second item is a
257
- named export.
258
-
259
- Default imports are not supported.
260
-
261
- ```tsx
262
- // .eslintrc.js
263
-
264
- // ...
265
- rules: {
266
- '@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
267
- 'error',
268
- {
269
- allowedDynamicKeys: [
270
- ['@atlaskit/primitives/responsive', 'media'],
271
- ]
272
- },
273
- ],
274
- // ...
275
- },
276
- // ...
277
- ```
278
-
279
- ### `allowedFunctionCalls: [string, string][]`
280
-
281
- Use this to allow specific functions to be called, in addition to the built-in allow-list.
282
-
283
- Each value should be a two-element array. The first item is the entrypoint, and the second item is a
284
- named export.
285
-
286
- Default imports are not currently supported.
287
-
288
- ```tsx
289
- // .eslintrc.js
290
-
291
- // ...
292
- rules: {
293
- '@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
294
- 'error',
295
- {
296
- allowedFunctionCalls: [
297
- ['@atlaskit/tokens', 'token'],
298
- ]
299
- },
300
- ],
301
- // ...
302
- },
303
- // ...
304
- ```
305
-
306
- ### `importSources: string[]`
307
-
308
- By default, this rule will check styles using:
309
-
310
- - `@atlaskit/css`
311
- - `@atlaskit/primitives`
312
- - `@compiled/react`
313
- - `@emotion/react`
314
- - `@emotion/core`
315
- - `@emotion/styled`
316
- - `styled-components`
317
-
318
- Override this list with the `importSources` option, which accepts an array of package names.
@@ -1,54 +0,0 @@
1
- # use-compiled
2
-
3
- Blocks CSS-in-JS libraries other than `@compiled/react`, including Emotion and styled-components.
4
-
5
- **WARNING** It may be unsafe to mix usages of `@compiled/react` with other CSS-in-JS libraries on
6
- the same component. When converting to `@compiled/react` verify ALL changes. For this reason, the
7
- autofixer has been disabled by default, but it may be useful to enable to empower a migration.
8
-
9
- ## Examples
10
-
11
- ### Incorrect
12
-
13
- ```tsx
14
- /** @jsx jsx */
15
- import { css } from '@emotion/core';
16
- import { jsx } from '@emotion/react';
17
- import styled from '@emotion/styled';
18
- ```
19
-
20
- ```tsx
21
- import styled, { css } from 'styled-components';
22
- ```
23
-
24
- ### Correct
25
-
26
- We expect usage of `xcss` with `@atlaskit/primitives` when working with Primitives, and `css` with
27
- `@compiled/react` when working with custom or native code.
28
-
29
- ```tsx
30
- /** @jsx jsx */
31
- import { jsx, css, styled } from '@compiled/react';
32
-
33
- const styles = css({ color: 'var(--ds-color-text)' });
34
- export default () => <div css={styles}>…</div>;
35
- ```
36
-
37
- ```tsx
38
- import { xcss, Box } from '@atlaskit/primitives';
39
-
40
- const styles = xcss({ color: 'color.text' });
41
- export default () => <Box xcss={styles}>…</Box>;
42
- ```
43
-
44
- ## Options
45
-
46
- ### `canAutoFix: boolean`
47
-
48
- Determines whether or not the autofixer is enabled.
49
-
50
- Defaults to `false` due to safety concerns when mixing Compiled and other CSS-in-JS libraries on the
51
- same component.
52
-
53
- Even when enabled, the autofixer will only convert usages that are deemed safe. Currently this is
54
- limited to purely static styles where all keys and values are simple literals.
package/index.js DELETED
@@ -1,24 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- /* eslint-disable global-require */
3
- // Used only for internal repo usage.
4
- const path = require('path');
5
-
6
- const paths = require('tsconfig-paths');
7
-
8
- if (!require.extensions['.ts']) {
9
- // ts-node can only handle being registered once, see https://github.com/TypeStrong/ts-node/issues/409
10
- require('ts-node').register({
11
- project: path.join(__dirname, 'tsconfig.json'),
12
- });
13
- }
14
-
15
- try {
16
- // We programatically register tsconfig paths here so it picks up the tsconfig here
17
- // instead of in root CWD.
18
- paths.register(paths.loadConfig(__dirname));
19
- } catch (e) {
20
- // eslint-disable-next-line no-console
21
- console.log(e);
22
- }
23
-
24
- module.exports = require('./src/index');