@atlaskit/eslint-plugin-ui-styling-standard 0.18.0 → 0.18.2

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 (140) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/rules/no-imported-style-values/index.js +36 -5
  3. package/dist/es2019/rules/no-imported-style-values/index.js +36 -5
  4. package/dist/esm/rules/no-imported-style-values/index.js +36 -5
  5. package/package.json +1 -1
  6. package/afm-cc/tsconfig.json +0 -28
  7. package/afm-jira/tsconfig.json +0 -27
  8. package/build/tsconfig.json +0 -18
  9. package/constellation/atlaskit-theme/usage.mdx +0 -132
  10. package/constellation/consistent-css-prop-usage/usage.mdx +0 -7
  11. package/constellation/convert-props-syntax/usage.mdx +0 -130
  12. package/constellation/enforce-style-prop/usage.mdx +0 -47
  13. package/constellation/index/migration-guide.mdx +0 -309
  14. package/constellation/index/overview.mdx +0 -250
  15. package/constellation/index/props.mdx +0 -30
  16. package/constellation/local-cx-xcss/usage.mdx +0 -53
  17. package/constellation/no-array-arguments/usage.mdx +0 -49
  18. package/constellation/no-classname-prop/usage.mdx +0 -49
  19. package/constellation/no-container-queries/usage.mdx +0 -101
  20. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -8
  21. package/constellation/no-dynamic-styles/usage.mdx +0 -130
  22. package/constellation/no-empty-styled-expression/usage.mdx +0 -8
  23. package/constellation/no-exported-css/usage.mdx +0 -8
  24. package/constellation/no-exported-keyframes/usage.mdx +0 -8
  25. package/constellation/no-exported-styles/usage.mdx +0 -87
  26. package/constellation/no-global-styles/usage.mdx +0 -60
  27. package/constellation/no-important-styles/usage.mdx +0 -33
  28. package/constellation/no-imported-style-values/usage.mdx +0 -157
  29. package/constellation/no-invalid-css-map/usage.mdx +0 -8
  30. package/constellation/no-js-xcss/usage.mdx +0 -7
  31. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -8
  32. package/constellation/no-nested-selectors/usage.mdx +0 -95
  33. package/constellation/no-styled/usage.mdx +0 -92
  34. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -8
  35. package/constellation/no-suppress-xcss/usage.mdx +0 -28
  36. package/constellation/no-unsafe-selectors/usage.mdx +0 -370
  37. package/constellation/no-unsafe-values/usage.mdx +0 -318
  38. package/constellation/use-compiled/usage.mdx +0 -54
  39. package/index.js +0 -24
  40. package/scripts/codegen.tsx +0 -373
  41. package/src/index.codegen.tsx +0 -14
  42. package/src/index.tsx +0 -1
  43. package/src/presets/all.codegen.tsx +0 -79
  44. package/src/presets/recommended.codegen.tsx +0 -79
  45. package/src/rules/TEMPLATE.md +0 -29
  46. package/src/rules/__tests__/utils/_tester.tsx +0 -40
  47. package/src/rules/atlaskit-theme/README.md +0 -130
  48. package/src/rules/atlaskit-theme/__tests__/test.ts +0 -133
  49. package/src/rules/atlaskit-theme/index.ts +0 -134
  50. package/src/rules/convert-props-syntax/README.md +0 -128
  51. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +0 -76
  52. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +0 -584
  53. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +0 -140
  54. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +0 -69
  55. package/src/rules/convert-props-syntax/index.tsx +0 -414
  56. package/src/rules/enforce-style-prop/README.md +0 -45
  57. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +0 -243
  58. package/src/rules/enforce-style-prop/index.tsx +0 -172
  59. package/src/rules/external-rules.tsx +0 -177
  60. package/src/rules/index.codegen.tsx +0 -42
  61. package/src/rules/local-cx-xcss/README.md +0 -51
  62. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +0 -102
  63. package/src/rules/local-cx-xcss/index.tsx +0 -62
  64. package/src/rules/no-array-arguments/README.md +0 -47
  65. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +0 -107
  66. package/src/rules/no-array-arguments/index.tsx +0 -86
  67. package/src/rules/no-classname-prop/README.md +0 -47
  68. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +0 -39
  69. package/src/rules/no-classname-prop/index.tsx +0 -34
  70. package/src/rules/no-container-queries/README.md +0 -99
  71. package/src/rules/no-container-queries/__tests__/rule.test.tsx +0 -139
  72. package/src/rules/no-container-queries/index.tsx +0 -94
  73. package/src/rules/no-dynamic-styles/README.md +0 -128
  74. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +0 -135
  75. package/src/rules/no-dynamic-styles/index.tsx +0 -60
  76. package/src/rules/no-exported-styles/README.md +0 -85
  77. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +0 -216
  78. package/src/rules/no-exported-styles/index.tsx +0 -52
  79. package/src/rules/no-global-styles/README.md +0 -58
  80. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +0 -33
  81. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +0 -46
  82. package/src/rules/no-global-styles/index.tsx +0 -82
  83. package/src/rules/no-important-styles/README.md +0 -31
  84. package/src/rules/no-important-styles/__tests__/rule.test.tsx +0 -165
  85. package/src/rules/no-important-styles/index.tsx +0 -70
  86. package/src/rules/no-imported-style-values/README.md +0 -155
  87. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +0 -491
  88. package/src/rules/no-imported-style-values/index.tsx +0 -188
  89. package/src/rules/no-nested-selectors/README.md +0 -93
  90. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +0 -335
  91. package/src/rules/no-nested-selectors/index.tsx +0 -99
  92. package/src/rules/no-styled/README.md +0 -90
  93. package/src/rules/no-styled/__tests__/rule.test.tsx +0 -73
  94. package/src/rules/no-styled/index.tsx +0 -45
  95. package/src/rules/no-unsafe-selectors/README.md +0 -368
  96. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +0 -368
  97. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +0 -57
  98. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +0 -73
  99. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +0 -40
  100. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +0 -101
  101. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +0 -131
  102. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +0 -132
  103. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +0 -25
  104. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +0 -35
  105. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +0 -257
  106. package/src/rules/no-unsafe-selectors/constants.tsx +0 -91
  107. package/src/rules/no-unsafe-selectors/index.tsx +0 -198
  108. package/src/rules/no-unsafe-selectors/lint-selector.tsx +0 -155
  109. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +0 -55
  110. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +0 -226
  111. package/src/rules/no-unsafe-values/README.md +0 -316
  112. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +0 -27
  113. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +0 -37
  114. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +0 -229
  115. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +0 -267
  116. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +0 -52
  117. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +0 -106
  118. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +0 -44
  119. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +0 -48
  120. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +0 -75
  121. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +0 -121
  122. package/src/rules/no-unsafe-values/index.tsx +0 -94
  123. package/src/rules/no-unsafe-values/messages.tsx +0 -86
  124. package/src/rules/no-unsafe-values/utils.tsx +0 -387
  125. package/src/rules/use-compiled/README.md +0 -52
  126. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +0 -73
  127. package/src/rules/use-compiled/__tests__/css.test.tsx +0 -126
  128. package/src/rules/use-compiled/__tests__/imports.test.tsx +0 -158
  129. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +0 -140
  130. package/src/rules/use-compiled/__tests__/pragma.test.tsx +0 -108
  131. package/src/rules/use-compiled/__tests__/styled.test.tsx +0 -114
  132. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +0 -15
  133. package/src/rules/use-compiled/index.tsx +0 -252
  134. package/src/rules/use-compiled/is-safe.tsx +0 -159
  135. package/src/rules/use-compiled/utils.tsx +0 -33
  136. package/src/rules/utils/create-rule-with-typed-config.tsx +0 -86
  137. package/src/rules/utils/create-rule.tsx +0 -13
  138. package/tsconfig.app.json +0 -47
  139. package/tsconfig.dev.json +0 -45
  140. package/tsconfig.json +0 -25
@@ -1,126 +0,0 @@
1
- import { tester } from '../../__tests__/utils/_tester';
2
- import rule from '../index';
3
-
4
- const importSources = ['@emotion/core', '@emotion/react', 'styled-components'];
5
-
6
- tester.run('css API - fixable', rule, {
7
- valid: [],
8
- invalid: importSources.flatMap((importSource) => [
9
- {
10
- name: `[${importSource}] styles are a plain object with literal values`,
11
- code: `
12
- import { css } from '${importSource}';
13
-
14
- const Component = css({
15
- color: 'red',
16
- });
17
- `,
18
- output: `
19
- import { css } from '@compiled/react';
20
-
21
- const Component = css({
22
- color: 'red',
23
- });
24
- `,
25
- errors: [{ messageId: 'use-compiled' }],
26
- options: [{ canAutoFix: true }],
27
- },
28
- ]),
29
- });
30
-
31
- /**
32
- * These test cases have no auto-fix because we are considering
33
- * them unsafe to automatically convert.
34
- */
35
- tester.run('css API - not fixable', rule, {
36
- valid: [],
37
- invalid: importSources.flatMap((importSource) => [
38
- {
39
- name: `[${importSource}] function as style argument`,
40
- code: `
41
- import { css } from '${importSource}';
42
-
43
- const Component = css(() => ({
44
- color: 'red',
45
- }));
46
- `,
47
- errors: [{ messageId: 'use-compiled' }],
48
- options: [{ canAutoFix: true }],
49
- },
50
- {
51
- name: `[${importSource}] function as style object value`,
52
- code: `
53
- import { css } from '${importSource}';
54
-
55
- const Component = css({
56
- color: () => 'red',
57
- });
58
- `,
59
- errors: [{ messageId: 'use-compiled' }],
60
- options: [{ canAutoFix: true }],
61
- },
62
- {
63
- name: `[${importSource}] identifier as style object value`,
64
- code: `
65
- import { css } from '${importSource}';
66
-
67
- const textColor = 'red';
68
- const Component = css({
69
- color: textColor,
70
- });
71
- `,
72
- errors: [{ messageId: 'use-compiled' }],
73
- options: [{ canAutoFix: true }],
74
- },
75
- {
76
- /**
77
- * We could auto-fix this safely but intentionally
78
- * keeping this rule very simple for now.
79
- */
80
- name: `[${importSource}] function call as style object value`,
81
- code: `
82
- import { css } from '${importSource}';
83
- import { token } from '@atlaskit/tokens';
84
-
85
- const Component = css({
86
- color: token('color.text'),
87
- });
88
- `,
89
- errors: [{ messageId: 'use-compiled' }],
90
- options: [{ canAutoFix: true }],
91
- },
92
- {
93
- name: `[${importSource}] with unsupported named import`,
94
- code: `
95
- import { css, type CSSObject } from '${importSource}';
96
-
97
- const Component = css({
98
- color: 'red',
99
- });
100
- `,
101
- errors: [{ messageId: 'use-compiled' }],
102
- options: [{ canAutoFix: true }],
103
- },
104
- {
105
- name: `[${importSource}] with unsafe usage of other import`,
106
- code: `
107
- import { css, keyframes } from '${importSource}';
108
-
109
- const Component = css({
110
- color: 'red',
111
- });
112
-
113
- const animation = keyframes({
114
- from: {
115
- opacity: () => 0
116
- },
117
- to: {
118
- opacity: 1
119
- }
120
- })
121
- `,
122
- errors: [{ messageId: 'use-compiled' }],
123
- options: [{ canAutoFix: true }],
124
- },
125
- ]),
126
- });
@@ -1,158 +0,0 @@
1
- import outdent from 'outdent';
2
-
3
- import { tester } from '../../__tests__/utils/_tester';
4
- import rule from '../index';
5
-
6
- const importSources = ['@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components'];
7
-
8
- tester.run('imports - ignored', rule, {
9
- valid: [
10
- {
11
- name: "[@atlaskit/primitives.xcss] - is ignored (it's okay to use, for now)",
12
- code: `
13
- import { xcss, Box } from '@atlaskit/primitives';
14
- `,
15
- },
16
- {
17
- name: "[@atlaskit/css] - is ignored (it's okay to use)",
18
- code: `
19
- import { cssMap, keyframes } from '@atlaskit/css';
20
- `,
21
- },
22
- {
23
- name: "[@stylexjs/stylex] - is ignored (we don't maintain a list of all CSS-in-JS libraries, but we could)",
24
- code: `
25
- import * as stylex from '@stylexjs/stylex';
26
- `,
27
- },
28
- ],
29
- invalid: [],
30
- });
31
-
32
- tester.run('imports - fixable', rule, {
33
- valid: [],
34
- invalid: [
35
- {
36
- name: '[@emotion/core] - supported imports with aliasing',
37
- code: `
38
- import { css as c, keyframes as kf } from '@emotion/core';
39
- `,
40
- output: `
41
- import { css as c, keyframes as kf } from '@compiled/react';
42
- `,
43
- errors: [{ messageId: 'use-compiled' }],
44
- options: [{ canAutoFix: true }],
45
- },
46
- {
47
- name: '[@emotion/react] - supported imports with aliasing',
48
- code: `
49
- import { css as c, keyframes as kf } from '@emotion/react';
50
- `,
51
- output: `
52
- import { css as c, keyframes as kf } from '@compiled/react';
53
- `,
54
- errors: [{ messageId: 'use-compiled' }],
55
- options: [{ canAutoFix: true }],
56
- },
57
- {
58
- name: '[@emotion/styled] - supported imports with aliasing',
59
- code: `
60
- import s from '@emotion/styled';
61
- `,
62
- output: `
63
- import { styled as s } from '@compiled/react';
64
- `,
65
- errors: [{ messageId: 'use-compiled' }],
66
- options: [{ canAutoFix: true }],
67
- },
68
- {
69
- name: '[styled-components] - supported imports with aliasing',
70
- code: `
71
- import s, { css as c, keyframes as kf } from 'styled-components';
72
- `,
73
- output: `
74
- import { css as c, keyframes as kf, styled as s } from '@compiled/react';
75
- `,
76
- errors: [{ messageId: 'use-compiled' }],
77
- options: [{ canAutoFix: true }],
78
- },
79
- {
80
- name: '[@emotion/core] - with existing compiled import',
81
- code: outdent`
82
- import { css } from '@emotion/core';
83
- import { styled } from '@compiled/react';
84
- `,
85
- output: outdent`
86
-
87
- import { styled, css } from '@compiled/react';
88
- `,
89
- errors: [{ messageId: 'use-compiled' }],
90
- options: [{ canAutoFix: true }],
91
- },
92
- {
93
- name: '[@emotion/react] - with existing compiled import',
94
- code: outdent`
95
- import { css } from '@emotion/react';
96
- import { styled } from '@compiled/react';
97
- `,
98
- output: outdent`
99
-
100
- import { styled, css } from '@compiled/react';
101
- `,
102
- errors: [{ messageId: 'use-compiled' }],
103
- options: [{ canAutoFix: true }],
104
- },
105
- {
106
- name: '[@emotion/styled] - with existing compiled import',
107
- code: outdent`
108
- import styled from '@emotion/styled';
109
- import { css } from '@compiled/react';
110
- `,
111
- output: outdent`
112
-
113
- import { css, styled } from '@compiled/react';
114
- `,
115
- errors: [{ messageId: 'use-compiled' }],
116
- options: [{ canAutoFix: true }],
117
- },
118
- {
119
- name: '[styled-components] - with existing compiled import',
120
- code: outdent`
121
- import styled from 'styled-components';
122
- import { css } from '@compiled/react';
123
- `,
124
- output: outdent`
125
-
126
- import { css, styled } from '@compiled/react';
127
- `,
128
- errors: [{ messageId: 'use-compiled' }],
129
- options: [{ canAutoFix: true }],
130
- },
131
- ],
132
- });
133
-
134
- /**
135
- * These test cases have no auto-fix because we are considering
136
- * them unsafe to automatically convert.
137
- */
138
- tester.run('imports - not fixable', rule, {
139
- valid: [],
140
- invalid: importSources.flatMap((importSource) => [
141
- {
142
- name: `[${importSource}] namespace import`,
143
- code: `
144
- import * as namespace from '${importSource}';
145
- `,
146
- errors: [{ messageId: 'use-compiled' }],
147
- options: [{ canAutoFix: true }],
148
- },
149
- {
150
- name: `[${importSource}] unsupported import`,
151
- code: `
152
- import { type CSSObject } from '${importSource}';
153
- `,
154
- errors: [{ messageId: 'use-compiled' }],
155
- options: [{ canAutoFix: true }],
156
- },
157
- ]),
158
- });
@@ -1,140 +0,0 @@
1
- import { tester } from '../../__tests__/utils/_tester';
2
- import rule from '../index';
3
-
4
- const importSources = ['@emotion/core', '@emotion/react', 'styled-components'];
5
-
6
- tester.run('keyframes API - fixable', rule, {
7
- valid: [],
8
- invalid: importSources.flatMap((importSource) => [
9
- {
10
- name: `[${importSource}] styles are a plain object with literal values`,
11
- code: `
12
- import { keyframes } from '${importSource}';
13
-
14
- const fadeIn = keyframes({
15
- from: {
16
- opacity: 0,
17
- },
18
- to: {
19
- opacity: 1,
20
- }
21
- });
22
- `,
23
- output: `
24
- import { keyframes } from '@compiled/react';
25
-
26
- const fadeIn = keyframes({
27
- from: {
28
- opacity: 0,
29
- },
30
- to: {
31
- opacity: 1,
32
- }
33
- });
34
- `,
35
- errors: [{ messageId: 'use-compiled' }],
36
- options: [{ canAutoFix: true }],
37
- },
38
- ]),
39
- });
40
-
41
- /**
42
- * These test cases have no auto-fix because we are considering
43
- * them unsafe to automatically convert.
44
- */
45
- tester.run('keyframes API - not fixable', rule, {
46
- valid: [],
47
- invalid: importSources.flatMap((importSource) => [
48
- {
49
- name: `[${importSource}] function as style argument`,
50
- code: `
51
- import { keyframes } from '${importSource}';
52
-
53
- const Component = keyframes(() => ({
54
- from: {
55
- opacity: 0,
56
- },
57
- to: {
58
- opacity: 1,
59
- }
60
- }));
61
- `,
62
- errors: [{ messageId: 'use-compiled' }],
63
- options: [{ canAutoFix: true }],
64
- },
65
- {
66
- name: `[${importSource}] function as style object value`,
67
- code: `
68
- import { keyframes } from '${importSource}';
69
-
70
- const Component = keyframes({
71
- from: {
72
- opacity: () => 0,
73
- },
74
- to: {
75
- opacity: 1,
76
- }
77
- });
78
- `,
79
- errors: [{ messageId: 'use-compiled' }],
80
- options: [{ canAutoFix: true }],
81
- },
82
- {
83
- name: `[${importSource}] identifier as style object value`,
84
- code: `
85
- import { keyframes } from '${importSource}';
86
-
87
- const startOpacity = 0;
88
- const fadeIn = keyframes({
89
- from: {
90
- opacity: startOpacity,
91
- },
92
- to: {
93
- opacity: 1,
94
- }
95
- });
96
- `,
97
- errors: [{ messageId: 'use-compiled' }],
98
- options: [{ canAutoFix: true }],
99
- },
100
- {
101
- /**
102
- * We could auto-fix this safely but intentionally
103
- * keeping this rule very simple for now.
104
- */
105
- name: `[${importSource}] function call as style object value`,
106
- code: `
107
- import { keyframes } from '${importSource}';
108
- import { token } from '@atlaskit/tokens';
109
-
110
- const hideBackground = keyframes({
111
- from: {
112
- backgroundColor: token('color.background.neutral'),
113
- },
114
- to: {
115
- backgroundColor: 'transparent',
116
- }
117
- });
118
- `,
119
- errors: [{ messageId: 'use-compiled' }],
120
- options: [{ canAutoFix: true }],
121
- },
122
- {
123
- name: `[${importSource}] with unsupported named import`,
124
- code: `
125
- import { keyframes, type CSSObject } from '${importSource}';
126
-
127
- const fadeIn = keyframes({
128
- from: {
129
- opacity: 0,
130
- },
131
- to: {
132
- opacity: 1,
133
- }
134
- })
135
- `,
136
- errors: [{ messageId: 'use-compiled' }],
137
- options: [{ canAutoFix: true }],
138
- },
139
- ]),
140
- });
@@ -1,108 +0,0 @@
1
- import { tester } from '../../__tests__/utils/_tester';
2
- import rule from '../index';
3
-
4
- tester.run('jsxImportSource pragma - fixable', rule, {
5
- valid: [],
6
- invalid: ['@emotion/core', '@emotion/react']
7
- .flatMap((importSource) => [
8
- {
9
- name: `[${importSource}] fixable import exists`,
10
- code: `
11
- /** @jsxImportSource @emotion/react */
12
-
13
- import { css } from '${importSource}';
14
- `,
15
- /**
16
- * This output does not have a fixed pragma because the rule tester
17
- * only does a single pass of the fixers.
18
- *
19
- * In reality up to 10 passes are done. We can see that from this state
20
- * the pragma does get fixed in the test below.
21
- */
22
- output: `
23
- /** @jsxImportSource @emotion/react */
24
-
25
- import { css } from '@compiled/react';
26
- `,
27
- errors: [{ messageId: 'use-compiled' }, { messageId: 'use-compiled' }],
28
- options: [{ canAutoFix: true }],
29
- },
30
- ])
31
- .concat([
32
- {
33
- name: `[@emotion/styled] fixable import exists`,
34
- code: `
35
- /** @jsxImportSource @emotion/react */
36
-
37
- import styled from '@emotion/styled';
38
- `,
39
- /**
40
- * This output does not have a fixed pragma because the rule tester
41
- * only does a single pass of the fixers.
42
- *
43
- * In reality up to 10 passes are done. We can see that from this state
44
- * the pragma does get fixed in the test below.
45
- */
46
- output: `
47
- /** @jsxImportSource @emotion/react */
48
-
49
- import { styled } from '@compiled/react';
50
- `,
51
- errors: [{ messageId: 'use-compiled' }, { messageId: 'use-compiled' }],
52
- options: [{ canAutoFix: true }],
53
- },
54
- {
55
- name: 'no @emotion imports and has @compiled/react import',
56
- code: `
57
- /** @jsxImportSource @emotion/react */
58
-
59
- import { css } from '@compiled/react';
60
- `,
61
- output: `
62
- /** @jsxImportSource @compiled/react */
63
-
64
- import { css } from '@compiled/react';
65
- `,
66
- errors: [{ messageId: 'use-compiled' }],
67
- options: [{ canAutoFix: true }],
68
- },
69
- ]),
70
- });
71
-
72
- tester.run('jsxImportSource pragma - not fixable', rule, {
73
- valid: [],
74
- invalid: [
75
- {
76
- name: 'no @compiled/react import',
77
- code: `/** @jsxImportSource @emotion/react */`,
78
- errors: [{ messageId: 'use-compiled' }],
79
- },
80
- {
81
- name: 'non-fixable @emotion/core import exists',
82
- code: `
83
- /** @jsxImportSource @emotion/react */
84
-
85
- import { type CSSObject } from '@emotion/core';
86
- `,
87
- errors: [{ messageId: 'use-compiled' }, { messageId: 'use-compiled' }],
88
- },
89
- {
90
- name: 'non-fixable @emotion/react import exists',
91
- code: `
92
- /** @jsxImportSource @emotion/react */
93
-
94
- import { type CSSObject } from '@emotion/react';
95
- `,
96
- errors: [{ messageId: 'use-compiled' }, { messageId: 'use-compiled' }],
97
- },
98
- {
99
- name: 'non-fixable @emotion/styled import exists',
100
- code: `
101
- /** @jsxImportSource @emotion/react */
102
-
103
- import { type CSSObject } from '@emotion/styled';
104
- `,
105
- errors: [{ messageId: 'use-compiled' }, { messageId: 'use-compiled' }],
106
- },
107
- ],
108
- });
@@ -1,114 +0,0 @@
1
- import { tester } from '../../__tests__/utils/_tester';
2
- import rule from '../index';
3
-
4
- tester.run('styled API - fixable', rule, {
5
- valid: [],
6
- invalid: ['@emotion/styled', 'styled-components'].flatMap((importSource) => [
7
- {
8
- name: `[${importSource}] styles are a plain object with literal values`,
9
- code: `
10
- import styled from '${importSource}';
11
-
12
- const Component = styled.div({
13
- color: 'red',
14
- });
15
- `,
16
- output: `
17
- import { styled } from '@compiled/react';
18
-
19
- const Component = styled.div({
20
- color: 'red',
21
- });
22
- `,
23
- errors: [{ messageId: 'use-compiled' }],
24
- options: [{ canAutoFix: true }],
25
- },
26
- ]),
27
- });
28
-
29
- /**
30
- * These test cases have no auto-fix because we are considering
31
- * them unsafe to automatically convert.
32
- */
33
- tester.run('styled API - not fixable', rule, {
34
- valid: [],
35
- invalid: ['@emotion/styled', 'styled-components'].flatMap((importSource) => [
36
- {
37
- name: `[${importSource}] function as style argument`,
38
- code: `
39
- import styled from '${importSource}';
40
-
41
- const Component = styled.div(() => ({
42
- color: 'red',
43
- }));
44
- `,
45
- errors: [{ messageId: 'use-compiled' }],
46
- options: [{ canAutoFix: true }],
47
- },
48
- {
49
- name: `[${importSource}] function as style object value`,
50
- code: `
51
- import styled from '${importSource}';
52
-
53
- const Component = styled.div({
54
- color: () => 'red',
55
- });
56
- `,
57
- errors: [{ messageId: 'use-compiled' }],
58
- options: [{ canAutoFix: true }],
59
- },
60
- {
61
- name: `[${importSource}] identifier as style object value`,
62
- code: `
63
- import styled from '${importSource}';
64
-
65
- const textColor = 'red';
66
- const Component = styled.div({
67
- color: textColor,
68
- });
69
- `,
70
- errors: [{ messageId: 'use-compiled' }],
71
- options: [{ canAutoFix: true }],
72
- },
73
- {
74
- /**
75
- * We could auto-fix this safely but intentionally
76
- * keeping this rule very simple for now.
77
- */
78
- name: `[${importSource}] function call as style object value`,
79
- code: `
80
- import styled from '${importSource}';
81
- import { token } from '@atlaskit/tokens';
82
-
83
- const Component = styled.div({
84
- color: token('color.text'),
85
- });
86
- `,
87
- errors: [{ messageId: 'use-compiled' }],
88
- options: [{ canAutoFix: true }],
89
- },
90
- {
91
- name: `[${importSource}] styled call extends component`,
92
- code: `
93
- import styled from '${importSource}';
94
- import { BaseComponent } from './base-component';
95
-
96
- const Component = styled(BaseComponent)({});
97
- `,
98
- errors: [{ messageId: 'use-compiled' }],
99
- options: [{ canAutoFix: true }],
100
- },
101
- {
102
- name: `[${importSource}] with unsupported named import`,
103
- code: `
104
- import styled, { type CSSObject } from '${importSource}';
105
-
106
- const Component = styled.div({
107
- color: 'red',
108
- });
109
- `,
110
- errors: [{ messageId: 'use-compiled' }],
111
- options: [{ canAutoFix: true }],
112
- },
113
- ]),
114
- });
@@ -1,15 +0,0 @@
1
- import { tester } from '../../__tests__/utils/_tester';
2
- import rule from '../index';
3
-
4
- tester.run('use-compiled', rule, {
5
- valid: [
6
- `import { styled } from '@compiled/react';`,
7
- `import { css } from '@compiled/react';`,
8
- `import { ClassNames } from '@compiled/react';`,
9
- `import { css, ClassNames, styled } from '@compiled/react';`,
10
- `import '@compiled/react'`,
11
- `/** @jsx jsx */`,
12
- `/** @jsxImportSource @compiled/react */`,
13
- ],
14
- invalid: [],
15
- });