@atlaskit/eslint-plugin-ui-styling-standard 0.17.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 (152) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/presets/all.codegen.js +3 -2
  3. package/dist/cjs/presets/recommended.codegen.js +3 -2
  4. package/dist/cjs/rules/external-rules.js +3 -1
  5. package/dist/es2019/presets/all.codegen.js +3 -2
  6. package/dist/es2019/presets/recommended.codegen.js +3 -2
  7. package/dist/es2019/rules/external-rules.js +3 -1
  8. package/dist/esm/presets/all.codegen.js +3 -2
  9. package/dist/esm/presets/recommended.codegen.js +3 -2
  10. package/dist/esm/rules/external-rules.js +3 -1
  11. package/dist/types/index.codegen.d.ts +2 -0
  12. package/dist/types/presets/all.codegen.d.ts +2 -1
  13. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  14. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  15. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  16. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  17. package/package.json +2 -2
  18. package/afm-cc/tsconfig.json +0 -28
  19. package/afm-jira/tsconfig.json +0 -28
  20. package/build/tsconfig.json +0 -18
  21. package/constellation/atlaskit-theme/usage.mdx +0 -132
  22. package/constellation/consistent-css-prop-usage/usage.mdx +0 -7
  23. package/constellation/convert-props-syntax/usage.mdx +0 -130
  24. package/constellation/enforce-style-prop/usage.mdx +0 -47
  25. package/constellation/index/migration-guide.mdx +0 -309
  26. package/constellation/index/overview.mdx +0 -250
  27. package/constellation/index/props.mdx +0 -30
  28. package/constellation/local-cx-xcss/usage.mdx +0 -53
  29. package/constellation/no-array-arguments/usage.mdx +0 -49
  30. package/constellation/no-classname-prop/usage.mdx +0 -49
  31. package/constellation/no-container-queries/usage.mdx +0 -101
  32. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -8
  33. package/constellation/no-dynamic-styles/usage.mdx +0 -130
  34. package/constellation/no-empty-styled-expression/usage.mdx +0 -8
  35. package/constellation/no-exported-css/usage.mdx +0 -8
  36. package/constellation/no-exported-keyframes/usage.mdx +0 -8
  37. package/constellation/no-exported-styles/usage.mdx +0 -87
  38. package/constellation/no-global-styles/usage.mdx +0 -60
  39. package/constellation/no-important-styles/usage.mdx +0 -33
  40. package/constellation/no-imported-style-values/usage.mdx +0 -157
  41. package/constellation/no-invalid-css-map/usage.mdx +0 -8
  42. package/constellation/no-js-xcss/usage.mdx +0 -7
  43. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -8
  44. package/constellation/no-nested-selectors/usage.mdx +0 -95
  45. package/constellation/no-styled/usage.mdx +0 -92
  46. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -8
  47. package/constellation/no-suppress-xcss/usage.mdx +0 -28
  48. package/constellation/no-unsafe-selectors/usage.mdx +0 -370
  49. package/constellation/no-unsafe-values/usage.mdx +0 -318
  50. package/constellation/use-compiled/usage.mdx +0 -54
  51. package/index.js +0 -24
  52. package/scripts/codegen.tsx +0 -373
  53. package/src/index.codegen.tsx +0 -14
  54. package/src/index.tsx +0 -1
  55. package/src/presets/all.codegen.tsx +0 -79
  56. package/src/presets/recommended.codegen.tsx +0 -79
  57. package/src/rules/TEMPLATE.md +0 -29
  58. package/src/rules/__tests__/utils/_tester.tsx +0 -40
  59. package/src/rules/atlaskit-theme/README.md +0 -130
  60. package/src/rules/atlaskit-theme/__tests__/test.ts +0 -133
  61. package/src/rules/atlaskit-theme/index.ts +0 -134
  62. package/src/rules/convert-props-syntax/README.md +0 -128
  63. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +0 -76
  64. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +0 -584
  65. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +0 -140
  66. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +0 -69
  67. package/src/rules/convert-props-syntax/index.tsx +0 -414
  68. package/src/rules/enforce-style-prop/README.md +0 -45
  69. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +0 -243
  70. package/src/rules/enforce-style-prop/index.tsx +0 -172
  71. package/src/rules/external-rules.tsx +0 -175
  72. package/src/rules/index.codegen.tsx +0 -42
  73. package/src/rules/local-cx-xcss/README.md +0 -51
  74. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +0 -102
  75. package/src/rules/local-cx-xcss/index.tsx +0 -62
  76. package/src/rules/no-array-arguments/README.md +0 -47
  77. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +0 -107
  78. package/src/rules/no-array-arguments/index.tsx +0 -86
  79. package/src/rules/no-classname-prop/README.md +0 -47
  80. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +0 -39
  81. package/src/rules/no-classname-prop/index.tsx +0 -34
  82. package/src/rules/no-container-queries/README.md +0 -99
  83. package/src/rules/no-container-queries/__tests__/rule.test.tsx +0 -139
  84. package/src/rules/no-container-queries/index.tsx +0 -94
  85. package/src/rules/no-dynamic-styles/README.md +0 -128
  86. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +0 -135
  87. package/src/rules/no-dynamic-styles/index.tsx +0 -60
  88. package/src/rules/no-exported-styles/README.md +0 -85
  89. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +0 -216
  90. package/src/rules/no-exported-styles/index.tsx +0 -52
  91. package/src/rules/no-global-styles/README.md +0 -58
  92. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +0 -33
  93. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +0 -46
  94. package/src/rules/no-global-styles/index.tsx +0 -82
  95. package/src/rules/no-important-styles/README.md +0 -31
  96. package/src/rules/no-important-styles/__tests__/rule.test.tsx +0 -165
  97. package/src/rules/no-important-styles/index.tsx +0 -70
  98. package/src/rules/no-imported-style-values/README.md +0 -155
  99. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +0 -491
  100. package/src/rules/no-imported-style-values/index.tsx +0 -188
  101. package/src/rules/no-nested-selectors/README.md +0 -93
  102. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +0 -335
  103. package/src/rules/no-nested-selectors/index.tsx +0 -99
  104. package/src/rules/no-styled/README.md +0 -90
  105. package/src/rules/no-styled/__tests__/rule.test.tsx +0 -73
  106. package/src/rules/no-styled/index.tsx +0 -45
  107. package/src/rules/no-unsafe-selectors/README.md +0 -368
  108. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +0 -368
  109. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +0 -57
  110. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +0 -73
  111. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +0 -40
  112. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +0 -101
  113. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +0 -131
  114. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +0 -132
  115. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +0 -25
  116. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +0 -35
  117. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +0 -257
  118. package/src/rules/no-unsafe-selectors/constants.tsx +0 -91
  119. package/src/rules/no-unsafe-selectors/index.tsx +0 -198
  120. package/src/rules/no-unsafe-selectors/lint-selector.tsx +0 -155
  121. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +0 -55
  122. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +0 -226
  123. package/src/rules/no-unsafe-values/README.md +0 -316
  124. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +0 -27
  125. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +0 -37
  126. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +0 -229
  127. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +0 -267
  128. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +0 -52
  129. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +0 -106
  130. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +0 -44
  131. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +0 -48
  132. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +0 -75
  133. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +0 -121
  134. package/src/rules/no-unsafe-values/index.tsx +0 -94
  135. package/src/rules/no-unsafe-values/messages.tsx +0 -86
  136. package/src/rules/no-unsafe-values/utils.tsx +0 -387
  137. package/src/rules/use-compiled/README.md +0 -52
  138. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +0 -73
  139. package/src/rules/use-compiled/__tests__/css.test.tsx +0 -126
  140. package/src/rules/use-compiled/__tests__/imports.test.tsx +0 -158
  141. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +0 -140
  142. package/src/rules/use-compiled/__tests__/pragma.test.tsx +0 -108
  143. package/src/rules/use-compiled/__tests__/styled.test.tsx +0 -114
  144. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +0 -15
  145. package/src/rules/use-compiled/index.tsx +0 -252
  146. package/src/rules/use-compiled/is-safe.tsx +0 -159
  147. package/src/rules/use-compiled/utils.tsx +0 -33
  148. package/src/rules/utils/create-rule-with-typed-config.tsx +0 -86
  149. package/src/rules/utils/create-rule.tsx +0 -13
  150. package/tsconfig.app.json +0 -47
  151. package/tsconfig.dev.json +0 -45
  152. package/tsconfig.json +0 -25
@@ -1,243 +0,0 @@
1
- import { tester } from '../../__tests__/utils/_tester';
2
- import rule from '../index';
3
-
4
- tester.run('enforce-style-prop', rule, {
5
- valid: [
6
- {
7
- name: 'No style attribute used',
8
- code: `
9
- <div css={styles} />
10
- `,
11
- },
12
- {
13
- name: 'Values from props are acceptable',
14
- code: `
15
- function Component(props) {
16
- return <div
17
- style={{
18
- width: props.width,
19
- '--my-nested-width': props.width,
20
- }}
21
- css={css({ margin: 0, color: 'red' })}
22
- />
23
- }
24
- `,
25
- },
26
- {
27
- name: 'Values from deconstructed props are acceptable',
28
- code: `
29
- function DeconstructionComponent1({ myWidth }) {
30
- return <div style={{ width: myWidth }}>hello</div>;
31
- }
32
- `,
33
- },
34
- {
35
- name: 'Multiple values from deconstructed props are acceptable',
36
- code: `
37
- function DeconstructionComponent2({ myWidth, height, myColor = '#fff' }) {
38
- return <div style={{ width: myWidth, height, color: myColor }}>hello</div>;
39
- }
40
- `,
41
- },
42
- {
43
- name: 'Skips linting @media query as it is not supported by the style prop anyways',
44
- code: `
45
- function Component() {
46
- return <div
47
- style={{
48
- '@media …': { /* ... */ },
49
- }}
50
- />
51
- }
52
- `,
53
- },
54
- {
55
- name: 'Skips linting selector as it is not supported by the style prop anyways',
56
- code: `
57
- function Component() {
58
- return <div
59
- style={{
60
- 'button': { /* ... */ },
61
- }}
62
- />
63
- }
64
- `,
65
- },
66
- {
67
- name: 'Static styles are outside of style attribute',
68
- code: `
69
- function Component(props) {
70
- return (
71
- <div
72
- style={{
73
- width: props.width,
74
- }}
75
- css={css({ margin: 0, color: 'red' })}
76
- />
77
- );
78
- }
79
- `,
80
- },
81
- {
82
- name: 'Props destructured in function via object pattern',
83
- code: `
84
- function Component(props) {
85
- const { width } = props;
86
- return <div style={{ width: width }} />
87
- }
88
- `,
89
- },
90
- {
91
- name: 'Props destructured in function via member expression',
92
- code: `
93
- function Component(props) {
94
- const width = props.width;
95
- return <div style={{ width: width }} />
96
- }
97
- `,
98
- },
99
- {
100
- name: 'Ignore state variables',
101
- code: `
102
- const Component = () => {
103
- const [state, setState] = useState();
104
- return <div style={{ width: state.width }} />
105
- };
106
- `,
107
- },
108
- {
109
- name: 'Ignore variables initialised by call expression',
110
- code: `
111
- const Component = () => {
112
- const tableWidth = calcDefaultLayoutWidthByAppearance(
113
- rendererAppearance,
114
- tableNode,
115
- );
116
- return (
117
- <div style={{ width: tableWidth }} />
118
- )
119
- }
120
- `,
121
- },
122
- {
123
- name: 'Property from object initialisation is ok',
124
- code: `
125
- function Component(props) {
126
- const obj = { width: 0 };
127
- return <div
128
- style={{
129
- width: obj.width
130
- }}
131
- />
132
- }
133
- `,
134
- },
135
- {
136
- name: 'Let variables are ok',
137
- code: `
138
- function Component(props) {
139
- let width = 0;
140
- return <div
141
- style={{
142
- width
143
- }}
144
- />
145
- }
146
- `,
147
- },
148
- {
149
- name: 'Ignore function calls',
150
- code: `
151
- import { calcDefaultLayoutWidthByAppearance } from '../shared';
152
- const Component = () => {
153
- return (
154
- <div
155
- style={{
156
- width: calcDefaultLayoutWidthByAppearance(
157
- rendererAppearance,
158
- tableNode,
159
- ),
160
- }}
161
- />
162
- );
163
- };
164
- `,
165
- },
166
- ],
167
- invalid: [
168
- {
169
- name: 'Basic test for static css values',
170
- code: `
171
- function Component(props) {
172
- return <div
173
- style={{
174
- margin: 0,
175
- color: 'red',
176
- }}
177
- />
178
- }
179
- `,
180
- errors: [{ messageId: 'enforce-style-prop' }, { messageId: 'enforce-style-prop' }],
181
- },
182
- {
183
- name: 'No constants passed to style',
184
- code: `
185
- function Component(props) {
186
- const color = 'red';
187
- return <div
188
- style={{
189
- color, // should be static css
190
- }}
191
- />
192
- }
193
- `,
194
- errors: [{ messageId: 'enforce-style-prop' }],
195
- },
196
- {
197
- name: 'No spread operator within style',
198
- code: `
199
- import importedStyleObj from '../shared';
200
- function Component(props) {
201
- const color = 'red';
202
- return <div
203
- style={{
204
- ...importedStyleObj,
205
- ...props.style
206
- }}
207
- />
208
- }
209
- `,
210
- errors: [{ messageId: 'enforce-style-prop' }, { messageId: 'enforce-style-prop' }],
211
- },
212
- {
213
- name: 'No imported object passed to style',
214
- code: `
215
- import importedStyleObj from '../shared';
216
- function AnotherComponent() {
217
- return <div style={importedStyleObj} />;
218
- }
219
- `,
220
- errors: [{ messageId: 'enforce-style-prop' }],
221
- },
222
- {
223
- name: 'No rest prop',
224
- code: `
225
- function Component({ prop1, ...spreadElement }) {
226
- return <div style={{ 'button': spreadElement }}>hello</div>
227
- }
228
- `,
229
- errors: [{ messageId: 'enforce-style-prop' }],
230
- },
231
- {
232
- name: 'No token calls',
233
- code: `
234
- import { token } from '@atlaskit/tokens';
235
-
236
- function Component() {
237
- return <div style={{ paddingBottom: token('space.150', '12px') }} />;
238
- }
239
- `,
240
- errors: [{ messageId: 'enforce-style-prop' }],
241
- },
242
- ],
243
- });
@@ -1,172 +0,0 @@
1
- import { type Identifier, isNodeOfType, type Node } from 'eslint-codemod-utils';
2
- import type { SpreadElement, Property } from 'estree-jsx';
3
-
4
- import { createLintRule } from '../utils/create-rule';
5
- import type { Rule, Scope } from 'eslint';
6
- import {
7
- getAllowedFunctionCalls,
8
- isAllowListedVariable,
9
- } from '@atlaskit/eslint-utils/allowed-function-calls';
10
- import { findVariable } from '@atlaskit/eslint-utils/find-variable';
11
-
12
- type ObjPropertyType = Property | SpreadElement;
13
- type IdentifierWithParent = Scope.Reference['identifier'] & Rule.NodeParentExtension;
14
-
15
- const isParameter = (context: Rule.RuleContext, identifier: Identifier): boolean => {
16
- const definitions = findVariable({
17
- sourceCode: context.getSourceCode(),
18
- identifier: identifier,
19
- })?.defs;
20
- if (!definitions || !definitions.length) {
21
- return false;
22
- }
23
-
24
- const result = definitions[0];
25
- return result.type === 'Parameter';
26
- };
27
-
28
- const isIdentifierAllowed = (context: Rule.RuleContext, identifier: Identifier): boolean => {
29
- const variable = findVariable({
30
- sourceCode: context.getSourceCode(),
31
- identifier: identifier,
32
- });
33
-
34
- if (!variable) {
35
- return false;
36
- }
37
-
38
- const variableDefinition = variable.defs[0].node;
39
-
40
- // If identifier is a RestElement, report warning
41
- if ((variable.identifiers[0] as IdentifierWithParent).parent?.type === 'RestElement') {
42
- return false;
43
- }
44
-
45
- // Checking if identifier has been destructured from props within function
46
- if (variableDefinition.type === 'VariableDeclarator') {
47
- // If it's a let variable, ignore
48
- if (variableDefinition.parent.kind === 'let') {
49
- return true;
50
- }
51
- // If it's initialised by a call expression, ignore
52
- if (variableDefinition.init?.type === 'CallExpression') {
53
- return true;
54
- }
55
- // Destructured from member expression
56
- // e.g. const width = props.width
57
- if (variableDefinition.init?.type === 'MemberExpression') {
58
- return isParameter(context, variableDefinition.init.object);
59
- }
60
- // Destructured from object pattern
61
- // e.g. const { width } = props
62
- return isParameter(context, variableDefinition.init);
63
- }
64
- // If identifier has not been deconstructed from parameter or is a RestElement, report warning
65
- return isParameter(context, identifier);
66
- };
67
-
68
- function isPropertyValueAllowed(property: ObjPropertyType, context: Rule.RuleContext): boolean {
69
- if (property.type === 'SpreadElement') {
70
- return false;
71
- }
72
- // property.type === 'Property', moving on to check if value is static
73
- if (property.value.type === 'Literal') {
74
- return false;
75
- } else if (property.value.type === 'Identifier') {
76
- return isIdentifierAllowed(context, property.value);
77
- } else if (
78
- property.value.type === 'CallExpression' &&
79
- property.value.callee.type === 'Identifier'
80
- ) {
81
- const variable = findVariable({
82
- sourceCode: context.getSourceCode(),
83
- identifier: property.value.callee,
84
- });
85
- // Anything returned by getAllowedFunctionCalls should be used in css prop instead
86
- const functionAllowList = getAllowedFunctionCalls(context.options);
87
- if (
88
- !variable ||
89
- isAllowListedVariable({
90
- allowList: functionAllowList,
91
- variable,
92
- })
93
- ) {
94
- return false;
95
- }
96
- } else if (
97
- property.value.type === 'MemberExpression' &&
98
- property.value.object.type === 'Identifier'
99
- ) {
100
- const definitions = findVariable({
101
- sourceCode: context.getSourceCode(),
102
- identifier: property.value.object,
103
- })?.defs;
104
- if (!definitions || !definitions.length) {
105
- return false;
106
- }
107
- const variable = definitions[0];
108
- if (!variable) {
109
- return false;
110
- }
111
- const varType = variable.type;
112
-
113
- if (varType === 'Variable') {
114
- if (!variable.node.init) {
115
- return false;
116
- }
117
- const varSource = variable.node.init.type;
118
- // Variables initialised by a call expression or object expression are ok
119
- if (varSource === 'CallExpression' || varSource === 'ObjectExpression') {
120
- return true;
121
- }
122
- // Check if member expression matches with function argument
123
- } else if (varType !== 'Parameter') {
124
- return false;
125
- }
126
- }
127
- return true;
128
- }
129
-
130
- export const rule = createLintRule({
131
- meta: {
132
- name: 'enforce-style-prop',
133
- docs: {
134
- description: 'Disallows usage of static styles in the `style` attribute in components',
135
- recommended: true,
136
- severity: 'error',
137
- },
138
- messages: {
139
- 'enforce-style-prop':
140
- 'Avoid adding static values to the style prop. Use the css prop for static styles instead.',
141
- },
142
- type: 'problem',
143
- },
144
- create(context) {
145
- return {
146
- 'JSXAttribute[name.name="style"] > JSXExpressionContainer': (node: Node) => {
147
- if (!isNodeOfType(node, 'JSXExpressionContainer')) {
148
- return;
149
- }
150
- // we've reached an attribute named style
151
-
152
- if (node.expression.type === 'ObjectExpression') {
153
- node.expression.properties.forEach((value) => {
154
- if (!isPropertyValueAllowed(value, context)) {
155
- context.report({
156
- node: value,
157
- messageId: 'enforce-style-prop',
158
- });
159
- }
160
- });
161
- } else {
162
- context.report({
163
- node: node,
164
- messageId: 'enforce-style-prop',
165
- });
166
- }
167
- },
168
- };
169
- },
170
- });
171
-
172
- export default rule;
@@ -1,175 +0,0 @@
1
- import type { LintRuleMeta } from '@atlaskit/eslint-utils/create-rule';
2
- import { getRuleUrl } from './utils/create-rule';
3
-
4
- /** External rules must be scoped, have a display name, and external urls. */
5
- export type ExternalRuleMeta = LintRuleMeta & {
6
- isExternal: true;
7
- name: `@${string}/${string}`;
8
- displayName: string;
9
- docs: { externalUrl: `https://${string}` };
10
- };
11
-
12
- const importSources: readonly string[] = [
13
- '@compiled/react',
14
- '@atlaskit/css',
15
- '@emotion/core',
16
- '@emotion/react',
17
- '@emotion/styled',
18
- 'styled-components',
19
- ];
20
-
21
- export const externalRules: ExternalRuleMeta[] = [
22
- {
23
- name: '@atlaskit/design-system/consistent-css-prop-usage',
24
- displayName: 'consistent-css-prop-usage',
25
- isExternal: true,
26
- fixable: 'code',
27
- docs: {
28
- description: 'Ensures consistency with `css` and `xcss` prop usages',
29
- url: getRuleUrl('consistent-css-prop-usage'),
30
- externalUrl:
31
- 'https://atlassian.design/components/eslint-plugin-design-system/consistent-css-prop-usage/usage',
32
- recommended: true,
33
- severity: 'error',
34
- pluginConfig: {
35
- // When passing a css prop to a React component, we don't know whether the component
36
- // is Emotion or Compiled. Hence it is not safe to run autofixes like wrapping it in
37
- // a `css` function call.
38
- excludeReactComponents: true,
39
- },
40
- },
41
- },
42
- {
43
- name: '@atlaskit/design-system/no-css-tagged-template-expression',
44
- displayName: 'no-css-tagged-template-expression',
45
- isExternal: true,
46
- fixable: 'code',
47
- docs: {
48
- description:
49
- 'Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled',
50
- url: getRuleUrl('no-css-tagged-template-expression'),
51
- externalUrl:
52
- 'https://atlassian.design/components/eslint-plugin-design-system/no-css-tagged-template-expression/usage',
53
- recommended: true,
54
- severity: 'error',
55
- },
56
- },
57
- {
58
- name: '@atlaskit/design-system/no-keyframes-tagged-template-expression',
59
- displayName: 'no-keyframes-tagged-template-expression',
60
- isExternal: true,
61
- fixable: 'code',
62
- docs: {
63
- description:
64
- 'Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled',
65
- url: getRuleUrl('no-keyframes-tagged-template-expression'),
66
- externalUrl:
67
- 'https://atlassian.design/components/eslint-plugin-design-system/no-keyframes-tagged-template-expression/usage',
68
- recommended: true,
69
- severity: 'error',
70
- },
71
- },
72
- {
73
- name: '@atlaskit/design-system/no-styled-tagged-template-expression',
74
- displayName: 'no-styled-tagged-template-expression',
75
- isExternal: true,
76
- fixable: 'code',
77
- docs: {
78
- description:
79
- 'Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled',
80
- url: getRuleUrl('no-styled-tagged-template-expression'),
81
- externalUrl:
82
- 'https://atlassian.design/components/eslint-plugin-design-system/no-styled-tagged-template-expression/usage',
83
- recommended: true,
84
- severity: 'error',
85
- },
86
- },
87
- {
88
- name: '@compiled/no-suppress-xcss',
89
- displayName: 'no-suppress-xcss',
90
- isExternal: true,
91
- docs: {
92
- description: 'Disallows supressing type violations when using the xcss prop.',
93
- url: getRuleUrl('no-suppress-xcss'),
94
- externalUrl:
95
- 'https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-suppress-xcss',
96
- recommended: true,
97
- severity: 'error',
98
- },
99
- },
100
- {
101
- name: '@compiled/no-js-xcss',
102
- displayName: 'no-js-xcss',
103
- isExternal: true,
104
- docs: {
105
- description: 'Disallows using xcss prop inside JavaScript files.',
106
- url: getRuleUrl('no-js-xcss'),
107
- externalUrl:
108
- 'https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-js-xcss',
109
- recommended: true,
110
- severity: 'error',
111
- },
112
- },
113
- {
114
- name: '@atlaskit/design-system/no-empty-styled-expression',
115
- displayName: 'no-empty-styled-expression',
116
- isExternal: true,
117
- docs: {
118
- description:
119
- 'Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements).',
120
- url: getRuleUrl('no-empty-styled-expression'),
121
- externalUrl:
122
- 'https://atlassian.design/components/eslint-plugin-design-system/no-empty-styled-expression/usage',
123
- recommended: true,
124
- severity: 'error',
125
- pluginConfig: { importSources },
126
- },
127
- },
128
- {
129
- name: '@atlaskit/design-system/no-exported-css',
130
- displayName: 'no-exported-css',
131
- isExternal: true,
132
- docs: {
133
- description:
134
- 'Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable.',
135
- url: getRuleUrl('no-exported-css'),
136
- externalUrl:
137
- 'https://atlassian.design/components/eslint-plugin-design-system/no-exported-css/usage',
138
- recommended: true,
139
- severity: 'error',
140
- pluginConfig: { importSources },
141
- },
142
- },
143
- {
144
- name: '@atlaskit/design-system/no-exported-keyframes',
145
- displayName: 'no-exported-keyframes',
146
- isExternal: true,
147
- docs: {
148
- description:
149
- 'Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable.',
150
- url: getRuleUrl('no-exported-keyframes'),
151
- externalUrl:
152
- 'https://atlassian.design/components/eslint-plugin-design-system/no-exported-keyframes/usage',
153
- recommended: true,
154
- severity: 'error',
155
- pluginConfig: { importSources },
156
- },
157
- },
158
- {
159
- name: '@atlaskit/design-system/no-invalid-css-map',
160
- displayName: 'no-invalid-css-map',
161
- isExternal: true,
162
- docs: {
163
- description:
164
- "Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking.",
165
- url: getRuleUrl('no-invalid-css-map'),
166
- externalUrl:
167
- 'https://atlassian.design/components/eslint-plugin-design-system/no-invalid-css-map/usage',
168
- recommended: true,
169
- severity: 'error',
170
- pluginConfig: {
171
- allowedFunctionCalls: [['@atlaskit/tokens', 'token']],
172
- },
173
- },
174
- },
175
- ];
@@ -1,42 +0,0 @@
1
- /**
2
- * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::6ad0de2d4bdac726387f27681ad9fcf4>>
4
- * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
- */
6
- import atlaskitTheme from './atlaskit-theme';
7
- import convertPropsSyntax from './convert-props-syntax';
8
- import enforceStyleProp from './enforce-style-prop';
9
- import localCxXcss from './local-cx-xcss';
10
- import noArrayArguments from './no-array-arguments';
11
- import noClassnameProp from './no-classname-prop';
12
- import noContainerQueries from './no-container-queries';
13
- import noDynamicStyles from './no-dynamic-styles';
14
- import noExportedStyles from './no-exported-styles';
15
- import noGlobalStyles from './no-global-styles';
16
- import noImportantStyles from './no-important-styles';
17
- import noImportedStyleValues from './no-imported-style-values';
18
- import noNestedSelectors from './no-nested-selectors';
19
- import noStyled from './no-styled';
20
- import noUnsafeSelectors from './no-unsafe-selectors';
21
- import noUnsafeValues from './no-unsafe-values';
22
- import useCompiled from './use-compiled';
23
-
24
- export default {
25
- 'atlaskit-theme': atlaskitTheme,
26
- 'convert-props-syntax': convertPropsSyntax,
27
- 'enforce-style-prop': enforceStyleProp,
28
- 'local-cx-xcss': localCxXcss,
29
- 'no-array-arguments': noArrayArguments,
30
- 'no-classname-prop': noClassnameProp,
31
- 'no-container-queries': noContainerQueries,
32
- 'no-dynamic-styles': noDynamicStyles,
33
- 'no-exported-styles': noExportedStyles,
34
- 'no-global-styles': noGlobalStyles,
35
- 'no-important-styles': noImportantStyles,
36
- 'no-imported-style-values': noImportedStyleValues,
37
- 'no-nested-selectors': noNestedSelectors,
38
- 'no-styled': noStyled,
39
- 'no-unsafe-selectors': noUnsafeSelectors,
40
- 'no-unsafe-values': noUnsafeValues,
41
- 'use-compiled': useCompiled,
42
- };
@@ -1,51 +0,0 @@
1
- Blocks the `cx()` function from being used outside of the `xcss` prop. This aids tracking which
2
- styles are applied.
3
-
4
- Use the `cx()` function when passing multiple styles to the `xcss` prop. This provides more robust
5
- type checking than the conventional array syntax:
6
-
7
- ```tsx
8
- import { cssMap, cx } from '@compiled/react';
9
- import { token } from '@atlaskit/tokens';
10
- import { Component } from 'some-package';
11
-
12
- const styles = cssMap({
13
- text: { color: token('color.text') },
14
- primary: { color: token('color.text.brand') },
15
- });
16
-
17
- <Component xcss={cx(isPrimary && styles.text, !isPrimary && styles.primary)} />;
18
- ```
19
-
20
- The `cx()` function is only checked when imported from `@compiled/react` or `@atlaskit/css`.
21
-
22
- ## Examples
23
-
24
- ### Incorrect
25
-
26
- ```tsx
27
- import { cssMap, cx } from '@compiled/react';
28
- import { token } from '@atlaskit/tokens';
29
-
30
- const styles = cssMap({
31
- text: { color: token('color.text') },
32
- bg: { background: token('color.background.neutral') },
33
- });
34
-
35
- const joinedStyles = cx(styles.text, styles.bg);
36
-
37
- <Button xcss={joinedStyles} />;
38
- ```
39
-
40
- ### Correct
41
-
42
- ```tsx
43
- import { cssMap, cx } from '@compiled/react';
44
-
45
- const styles = cssMap({
46
- text: { color: token('color.text') },
47
- bg: { background: token('color.background.neutral') },
48
- });
49
-
50
- <Button xcss={cx(styles.text, styles.bg)} />;
51
- ```