@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,102 +0,0 @@
1
- import { tester } from '../../__tests__/utils/_tester';
2
- import rule from '../index';
3
-
4
- tester.run('local-cx-xcss', rule, {
5
- valid: [
6
- `
7
- import { cx } from '@compiled/react';
8
-
9
- <Component xcss={cx({})} />
10
- `,
11
- `
12
- import { cx } from '@compiled/react';
13
-
14
- <Component innerXcss={cx({})} />
15
- `,
16
- `
17
- import { cx, cssMap } from '@compiled/react';
18
-
19
- const styles = cssMap({
20
- text: { color: 'red' },
21
- bg: { background: 'blue' },
22
- });
23
-
24
- <Button innerXcss={cx(styles.text, styles.bg)} />;
25
- `,
26
- `
27
- // Ignore cx usage not from compiled
28
- const styles = cssMap({
29
- text: { color: 'red' },
30
- bg: { background: 'blue' },
31
- });
32
-
33
- const joinedStyles = cx(styles.text, styles.bg);
34
-
35
- <Button xcss={joinedStyles} />;
36
- `,
37
- `
38
- // Ignore cx usage not from compiled
39
- const styles = cx({});
40
-
41
- <Component xcss={styles} />
42
- `,
43
- `
44
- // Ignore cx usage where
45
- // the library is not specified in additionalCompiledLibraries
46
- import { cx } from 'custom-package';
47
- const styles = cx({});
48
-
49
- <Component xcss={styles} />
50
- `,
51
- ],
52
- invalid: [
53
- {
54
- code: `
55
- import { cx } from '@compiled/react';
56
- const styles = cx({});
57
-
58
- <Component xcss={styles} />
59
- `,
60
- errors: [{ messageId: 'local-cx-xcss' }],
61
- },
62
- {
63
- code: `
64
- import { cx, cssMap } from '@compiled/react';
65
-
66
- const styles = cssMap({
67
- text: { color: 'red' },
68
- bg: { background: 'blue' },
69
- });
70
-
71
- const joinedStyles = cx(styles.text, styles.bg);
72
-
73
- <Button xcss={joinedStyles} />;
74
- `,
75
- errors: [{ messageId: 'local-cx-xcss' }],
76
- },
77
- {
78
- code: `
79
- import { cx } from '@compiled/react';
80
- const styles = cx({});
81
-
82
- <Component innerXcss={styles} />
83
- `,
84
- errors: [{ messageId: 'local-cx-xcss' }],
85
- },
86
- {
87
- code: `
88
- import { cx, cssMap } from '@compiled/react';
89
-
90
- const styles = cssMap({
91
- text: { color: 'red' },
92
- bg: { background: 'blue' },
93
- });
94
-
95
- const joinedStyles = cx(styles.text, styles.bg);
96
-
97
- <Button innerXcss={joinedStyles} />;
98
- `,
99
- errors: [{ messageId: 'local-cx-xcss' }],
100
- },
101
- ],
102
- });
@@ -1,62 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- import type { JSXAttribute } from 'estree-jsx';
3
-
4
- import { createLintRule } from '../utils/create-rule';
5
- import { CSS_IN_JS_IMPORTS, isCxFunction } from '@atlaskit/eslint-utils/is-supported-import';
6
-
7
- const IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
8
-
9
- function getParentJSXAttribute(node: Rule.Node): JSXAttribute | null {
10
- let parent: Rule.Node | null = node.parent;
11
-
12
- while (parent && parent.type !== 'JSXAttribute') {
13
- parent = parent.parent;
14
- }
15
-
16
- if (parent && parent.type === 'JSXAttribute') {
17
- return parent;
18
- }
19
-
20
- return null;
21
- }
22
-
23
- export const rule = createLintRule({
24
- meta: {
25
- name: 'local-cx-xcss',
26
- docs: {
27
- description:
28
- 'Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element.',
29
- recommended: true,
30
- severity: 'error',
31
- },
32
- messages: {
33
- 'local-cx-xcss':
34
- 'The cx function should only be declared inside the xcss prop to simplify tracking styles that are applied to a jsx element.',
35
- },
36
- type: 'problem',
37
- },
38
- create(context) {
39
- return {
40
- 'CallExpression[callee.name="cx"]': (node: Rule.Node) => {
41
- if (
42
- node.type === 'CallExpression' &&
43
- isCxFunction(node.callee, context.getScope().references, IMPORT_SOURCES)
44
- ) {
45
- const parentJSXAttribute = getParentJSXAttribute(node);
46
- const propName = parentJSXAttribute?.name.name.toString();
47
-
48
- if (propName && /[xX]css$/.test(propName)) {
49
- return;
50
- }
51
-
52
- context.report({
53
- node,
54
- messageId: 'local-cx-xcss',
55
- });
56
- }
57
- },
58
- };
59
- },
60
- });
61
-
62
- export default rule;
@@ -1,47 +0,0 @@
1
- Blocks passing array arguments to style declaration functions.
2
-
3
- ## Examples
4
-
5
- ### Incorrect
6
-
7
- ```tsx
8
- import { css } from '@compiled/react';
9
-
10
- const styles = css([{ width: 100 }, { height: 100 }]);
11
- ```
12
-
13
- ```tsx
14
- import { styled } from '@compiled/react';
15
-
16
- const styles = css([{ width: 100 }, ...items]);
17
- ```
18
-
19
- ### Correct
20
-
21
- ```tsx
22
- import { css } from '@compiled/react';
23
-
24
- const styles = css({ width: 100 }, { height: 100 });
25
- ```
26
-
27
- ```tsx
28
- import { css } from '@compiled/react';
29
-
30
- const styles = css({ width: 100 }, ...items);
31
- ```
32
-
33
- ## Options
34
-
35
- ### `importSources: string[]`
36
-
37
- By default, this rule will check styles using:
38
-
39
- - `@atlaskit/css`
40
- - `@atlaskit/primitives`
41
- - `@compiled/react`
42
- - `@emotion/react`
43
- - `@emotion/core`
44
- - `@emotion/styled`
45
- - `styled-components`
46
-
47
- Override this list with the `importSources` option, which accepts an array of package names.
@@ -1,107 +0,0 @@
1
- import { typescriptEslintTester } from '../../__tests__/utils/_tester';
2
- import rule from '../index';
3
-
4
- typescriptEslintTester.run(
5
- 'no-nested-selectors',
6
- // @ts-expect-error
7
- rule,
8
- {
9
- valid: [],
10
- invalid: [
11
- {
12
- name: 'single array argument',
13
- code: `
14
- import { css } from '@compiled/react';
15
- const styles = css([
16
- { width: 100 },
17
- { height: 100 }
18
- ]);
19
- `,
20
- output: `
21
- import { css } from '@compiled/react';
22
- const styles = css({ width: 100 }, { height: 100 });
23
- `,
24
- errors: [{ messageId: 'no-array-arguments' }],
25
- },
26
- {
27
- name: 'multiple array arguments',
28
- code: `
29
- import { css } from '@compiled/react';
30
- const styles = css(
31
- [
32
- { width: 100 },
33
- { height: 100 }
34
- ],
35
- [
36
- { color: 'red' }
37
- ]
38
- );
39
- `,
40
- output: `
41
- import { css } from '@compiled/react';
42
- const styles = css(
43
- { width: 100 }, { height: 100 },
44
- { color: 'red' }
45
- );
46
- `,
47
- errors: [{ messageId: 'no-array-arguments' }, { messageId: 'no-array-arguments' }],
48
- },
49
- {
50
- name: 'interspersed array arguments',
51
- code: `
52
- import { css } from '@compiled/react';
53
- const styles = css(
54
- { a: 1 },
55
- [
56
- { width: 100 },
57
- { height: 100 }
58
- ],
59
- { b: 2 },
60
- [
61
- { color: 'red' },
62
- { opacity: 0.5 },
63
- ],
64
- { c: 3 }
65
- );
66
- `,
67
- output: `
68
- import { css } from '@compiled/react';
69
- const styles = css(
70
- { a: 1 },
71
- { width: 100 }, { height: 100 },
72
- { b: 2 },
73
- { color: 'red' }, { opacity: 0.5 },
74
- { c: 3 }
75
- );
76
- `,
77
- errors: [{ messageId: 'no-array-arguments' }, { messageId: 'no-array-arguments' }],
78
- },
79
- {
80
- name: 'empty array argument',
81
- code: `
82
- import { css } from '@compiled/react';
83
- const styles = css(
84
- [],
85
- { color: 'red' },
86
- []
87
- );
88
- `,
89
- errors: [{ messageId: 'no-array-arguments' }, { messageId: 'no-array-arguments' }],
90
- },
91
- {
92
- name: 'spread in array',
93
- code: `
94
- import { css } from '@compiled/react';
95
- const styles = css([
96
- ...items
97
- ]);
98
- `,
99
- output: `
100
- import { css } from '@compiled/react';
101
- const styles = css(...items);
102
- `,
103
- errors: [{ messageId: 'no-array-arguments' }],
104
- },
105
- ],
106
- },
107
- );
@@ -1,86 +0,0 @@
1
- import type { Expression, SpreadElement } from 'estree';
2
-
3
- import {
4
- getImportSources,
5
- hasStyleObjectArguments,
6
- } from '@atlaskit/eslint-utils/is-supported-import';
7
- import { createLintRule } from '../utils/create-rule';
8
- import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
9
-
10
- const schema: JSONSchema4 = [
11
- {
12
- type: 'object',
13
- properties: {
14
- importSources: {
15
- type: 'array',
16
- items: { type: 'string' },
17
- uniqueItems: true,
18
- },
19
- },
20
- },
21
- ];
22
-
23
- export const rule = createLintRule({
24
- meta: {
25
- name: 'no-array-arguments',
26
- docs: {
27
- description: 'Prevents usage of array arguments to style declaration functions',
28
- recommended: true,
29
- severity: 'error',
30
- },
31
- messages: {
32
- 'no-array-arguments':
33
- "Don't pass multiple value in an array. Pass them as multiple arguments instead.",
34
- },
35
- type: 'problem',
36
- fixable: 'code',
37
- schema,
38
- },
39
- create(context) {
40
- const importSources = getImportSources(context);
41
- return {
42
- CallExpression(node) {
43
- const { references } = context.getScope();
44
-
45
- if (!hasStyleObjectArguments(node.callee, references, importSources)) {
46
- return;
47
- }
48
-
49
- for (const argument of node.arguments) {
50
- if (argument.type === 'ArrayExpression') {
51
- context.report({
52
- node: argument,
53
- messageId: 'no-array-arguments',
54
- fix(fixer) {
55
- if (argument.elements.length === 0) {
56
- /**
57
- * Don't autofix if it's an empty array.
58
- *
59
- * I couldn't figure out how to get rid of the comma afterwards,
60
- * so the autofix was producing syntax problems.
61
- *
62
- * This is an edge case that shouldn't actually be happening,
63
- * but if it does it's not hard to just delete the empty array...
64
- */
65
- return null;
66
- }
67
-
68
- const items = argument.elements
69
- .filter(
70
- (
71
- value: SpreadElement | Expression | null,
72
- ): value is SpreadElement | Expression => value !== null,
73
- )
74
- .map((element) => context.getSourceCode().getText(element));
75
-
76
- return fixer.replaceText(argument, items.join(', '));
77
- },
78
- });
79
- }
80
- }
81
- },
82
- };
83
- },
84
- });
85
-
86
- export default rule;
@@ -1,47 +0,0 @@
1
- Blocks the `className` prop, which encourages unsafe global styles and cannot be statically
2
- resolved.
3
-
4
- Use the `css` prop for styling, with props for configuration and `xcss` for bounded overrides.
5
-
6
- ## Examples
7
-
8
- ### Incorrect
9
-
10
- ```tsx
11
- <div className="my-class">
12
- ```
13
-
14
- ```tsx
15
- <MyComponent className={isDisabled ? 'disabled' : undefined} />
16
- ```
17
-
18
- ### Correct
19
-
20
- ```tsx
21
- import { css } from '@compiled/react';
22
- import { token } from '@atlaskit/tokens';
23
-
24
- const myStyles = css({ padding: token('space.100') });
25
-
26
- <div css={myStyles} />;
27
- ```
28
-
29
- ```tsx
30
- <MyComponent isDisabled={isDisabled} />
31
- ```
32
-
33
- ```tsx
34
- import { Checkbox } from '@atlaskit/checkbox';
35
-
36
- <Checkbox xcss={{ alignItems: 'center' }} />;
37
- ```
38
-
39
- ## FAQ
40
-
41
- ### What if I'm using `className` to target elements with JavaScript?
42
-
43
- There are some cases where a selector is required to integrate with a 3rd party library, such as
44
- legacy code using jQuery.
45
-
46
- Use a `ref` if possible. Otherwise, if you _must_ have a selector, use a `data-*` attribute that
47
- gives enough context and is unique enough, for example `data-editor-table-target="true"`.
@@ -1,39 +0,0 @@
1
- import { tester } from '../../__tests__/utils/_tester';
2
- import rule from '../index';
3
-
4
- tester.run('no-classname-prop', rule, {
5
- valid: [
6
- {
7
- code: `
8
- <div />
9
- `,
10
- },
11
- ],
12
- invalid: [
13
- {
14
- // Basic test case
15
- code: `
16
- <div className={myStyles} />
17
- `,
18
- errors: [{ messageId: 'no-classname-prop' }],
19
- },
20
- {
21
- // String
22
- code: `
23
- <div className="my-class" />
24
- `,
25
- errors: [{ messageId: 'no-classname-prop' }],
26
- },
27
- {
28
- // With non-primitive elements
29
- code: `
30
- import { styled } from '@compiled/react';
31
-
32
- const Component = styled.div({});
33
-
34
- <Component className="my-class" />
35
- `,
36
- errors: [{ messageId: 'no-classname-prop' }],
37
- },
38
- ],
39
- });
@@ -1,34 +0,0 @@
1
- import { isNodeOfType, type Node } from 'eslint-codemod-utils';
2
-
3
- import { createLintRule } from '../utils/create-rule';
4
-
5
- export const rule = createLintRule({
6
- meta: {
7
- name: 'no-classname-prop',
8
- docs: {
9
- description: 'Disallows usage of the `className` prop in JSX',
10
- recommended: true,
11
- severity: 'error',
12
- },
13
- messages: {
14
- 'no-classname-prop':
15
- 'Avoid `className` because it invites the use of unsafe global styles and is impossible to determine via local tooling.',
16
- },
17
- type: 'problem',
18
- },
19
- create(context) {
20
- return {
21
- JSXAttribute(node: Node) {
22
- if (!isNodeOfType(node, 'JSXAttribute')) {
23
- return;
24
- }
25
-
26
- if (node.name.name === 'className') {
27
- context.report({ node, messageId: 'no-classname-prop' });
28
- }
29
- },
30
- };
31
- },
32
- });
33
-
34
- export default rule;
@@ -1,99 +0,0 @@
1
- Blocks `@container` at-rules
2
- ([container queries](https://developer.mozilla.org/en-US/docs/Web/CSS/@container)), which are
3
- unsafe.
4
-
5
- Container queries are unsafe because they:
6
-
7
- - break the rules of scope
8
- - aren't deterministic
9
- - aren't type-safe
10
- - aren't fully supported across our frontend tech stacks
11
-
12
- Use [media queries](https://atlassian.design/components/primitives/responsive/breakpoints/examples),
13
- a
14
- [WidthObserver](https://atlaskit.atlassian.com/packages/design-system/width-detector/docs/migration-guide),
15
- or a custom [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
16
- instead.
17
-
18
- ## Examples
19
-
20
- ### Incorrect
21
-
22
- ```tsx
23
- import { css } from '@compiled/react';
24
- import { token } from '@atlaskit/tokens';
25
-
26
- const headingStyles = css({
27
- '@container (width > 400px)': {
28
- font: token('font.heading.large'),
29
- },
30
- });
31
- ```
32
-
33
- ### Correct
34
-
35
- #### Media queries
36
-
37
- ```tsx
38
- import { css } from '@compiled/react';
39
- import { media } from '@atlaskit/primitives/responsive';
40
- import { token } from '@atlaskit/tokens';
41
-
42
- const headingStyles = css({
43
- [media.above.sm]: {
44
- font: token('font.heading.large'),
45
- },
46
- });
47
- ```
48
-
49
- #### WidthObserver
50
-
51
- ```tsx
52
- import { useState } from 'react';
53
- import { css, cssMap } from '@compiled/react';
54
- import throttle from 'lodash/throttle';
55
- import { WidthObserver } from '@atlaskit/width-detector';
56
- import { token } from '@atlaskit/tokens';
57
-
58
- const containerStyles = css({
59
- // Required for the `WidthObserver`, which is absolutely positioned
60
- position: 'relative',
61
- });
62
-
63
- const headingStyles = cssMap({
64
- small: {
65
- font: token('font.heading.small'),
66
- },
67
- large: {
68
- font: token('font.heading.large'),
69
- },
70
- });
71
-
72
- const ResponsiveH2 = () => {
73
- const [width = 0, setWidth] = useState<number | undefined>(undefined);
74
- const throttledSetWidth = throttle(setWidth, 50);
75
-
76
- return (
77
- <div css={containerStyles}>
78
- <WidthObserver setWidth={throttledSetWidth} />
79
- <h2 css={width < 400 ? headingStyles.small : headingStyles.large}>Title</h2>
80
- </div>
81
- );
82
- };
83
- ```
84
-
85
- ## Options
86
-
87
- ### `importSources: string[]`
88
-
89
- By default, this rule will check styles using:
90
-
91
- - `@atlaskit/css`
92
- - `@atlaskit/primitives`
93
- - `@compiled/react`
94
- - `@emotion/react`
95
- - `@emotion/core`
96
- - `@emotion/styled`
97
- - `styled-components`
98
-
99
- Override this list with the `importSources` option, which accepts an array of package names.