@atlaskit/eslint-plugin-ui-styling-standard 0.14.2 → 0.15.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 (91) hide show
  1. package/CHANGELOG.md +188 -167
  2. package/README.md +1 -0
  3. package/afm-cc/tsconfig.json +10 -3
  4. package/afm-jira/tsconfig.json +28 -0
  5. package/constellation/atlaskit-theme/usage.mdx +17 -17
  6. package/constellation/convert-props-syntax/usage.mdx +14 -14
  7. package/constellation/enforce-style-prop/usage.mdx +17 -17
  8. package/constellation/index/overview.mdx +99 -98
  9. package/constellation/local-cx-xcss/usage.mdx +4 -4
  10. package/constellation/no-array-arguments/usage.mdx +7 -7
  11. package/constellation/no-container-queries/usage.mdx +14 -14
  12. package/constellation/no-dynamic-styles/usage.mdx +19 -19
  13. package/constellation/no-exported-styles/usage.mdx +15 -15
  14. package/constellation/no-global-styles/usage.mdx +13 -13
  15. package/constellation/no-important-styles/usage.mdx +2 -2
  16. package/constellation/no-imported-style-values/usage.mdx +16 -16
  17. package/constellation/no-nested-selectors/usage.mdx +18 -18
  18. package/constellation/no-styled/usage.mdx +6 -6
  19. package/constellation/no-unsafe-selectors/usage.mdx +244 -0
  20. package/constellation/no-unsafe-values/usage.mdx +33 -33
  21. package/dist/cjs/index.codegen.js +1 -1
  22. package/dist/cjs/presets/all.codegen.js +2 -1
  23. package/dist/cjs/presets/recommended.codegen.js +2 -1
  24. package/dist/cjs/rules/index.codegen.js +3 -1
  25. package/dist/cjs/rules/no-unsafe-selectors/constants.js +30 -0
  26. package/dist/cjs/rules/no-unsafe-selectors/index.js +188 -0
  27. package/dist/cjs/rules/no-unsafe-selectors/lint-selector.js +198 -0
  28. package/dist/cjs/rules/no-unsafe-selectors/source-position-utils.js +42 -0
  29. package/dist/cjs/rules/no-unsafe-selectors/walk-css-map.js +186 -0
  30. package/dist/es2019/index.codegen.js +1 -1
  31. package/dist/es2019/presets/all.codegen.js +2 -1
  32. package/dist/es2019/presets/recommended.codegen.js +2 -1
  33. package/dist/es2019/rules/index.codegen.js +3 -1
  34. package/dist/es2019/rules/no-unsafe-selectors/constants.js +22 -0
  35. package/dist/es2019/rules/no-unsafe-selectors/index.js +176 -0
  36. package/dist/es2019/rules/no-unsafe-selectors/lint-selector.js +161 -0
  37. package/dist/es2019/rules/no-unsafe-selectors/source-position-utils.js +31 -0
  38. package/dist/es2019/rules/no-unsafe-selectors/walk-css-map.js +180 -0
  39. package/dist/esm/index.codegen.js +1 -1
  40. package/dist/esm/presets/all.codegen.js +2 -1
  41. package/dist/esm/presets/recommended.codegen.js +2 -1
  42. package/dist/esm/rules/index.codegen.js +3 -1
  43. package/dist/esm/rules/no-unsafe-selectors/constants.js +24 -0
  44. package/dist/esm/rules/no-unsafe-selectors/index.js +181 -0
  45. package/dist/esm/rules/no-unsafe-selectors/lint-selector.js +191 -0
  46. package/dist/esm/rules/no-unsafe-selectors/source-position-utils.js +34 -0
  47. package/dist/esm/rules/no-unsafe-selectors/walk-css-map.js +179 -0
  48. package/dist/types/index.codegen.d.ts +2 -0
  49. package/dist/types/presets/all.codegen.d.ts +2 -1
  50. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  51. package/dist/types/rules/index.codegen.d.ts +1 -0
  52. package/dist/types/rules/no-unsafe-selectors/constants.d.ts +23 -0
  53. package/dist/types/rules/no-unsafe-selectors/index.d.ts +3 -0
  54. package/dist/types/rules/no-unsafe-selectors/lint-selector.d.ts +14 -0
  55. package/dist/types/rules/no-unsafe-selectors/source-position-utils.d.ts +20 -0
  56. package/dist/types/rules/no-unsafe-selectors/walk-css-map.d.ts +23 -0
  57. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  58. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  59. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  60. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  61. package/dist/types-ts4.5/rules/no-unsafe-selectors/constants.d.ts +84 -0
  62. package/dist/types-ts4.5/rules/no-unsafe-selectors/index.d.ts +3 -0
  63. package/dist/types-ts4.5/rules/no-unsafe-selectors/lint-selector.d.ts +14 -0
  64. package/dist/types-ts4.5/rules/no-unsafe-selectors/source-position-utils.d.ts +23 -0
  65. package/dist/types-ts4.5/rules/no-unsafe-selectors/walk-css-map.d.ts +23 -0
  66. package/package.json +7 -8
  67. package/scripts/codegen.tsx +3 -4
  68. package/src/index.codegen.tsx +3 -3
  69. package/src/presets/all.codegen.tsx +70 -72
  70. package/src/presets/recommended.codegen.tsx +70 -72
  71. package/src/rules/index.codegen.tsx +19 -17
  72. package/src/rules/no-classname-prop/index.tsx +1 -1
  73. package/src/rules/no-nested-selectors/index.tsx +1 -1
  74. package/src/rules/no-unsafe-selectors/README.md +232 -0
  75. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +368 -0
  76. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +60 -0
  77. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +73 -0
  78. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +40 -0
  79. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +101 -0
  80. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +131 -0
  81. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +132 -0
  82. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +25 -0
  83. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +35 -0
  84. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +238 -0
  85. package/src/rules/no-unsafe-selectors/constants.tsx +99 -0
  86. package/src/rules/no-unsafe-selectors/index.tsx +198 -0
  87. package/src/rules/no-unsafe-selectors/lint-selector.tsx +155 -0
  88. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +55 -0
  89. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +232 -0
  90. package/tsconfig.app.json +45 -45
  91. package/tsconfig.dev.json +43 -43
@@ -1,78 +1,76 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::40bdd5a27731185ba04e0b279fc81ac9>>
3
+ * @codegen <<SignedSource::f240d1cd5b93827327b66c28ad47e698>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
7
- plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
- rules: {
9
- '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
10
- '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
11
- '@atlaskit/ui-styling-standard/enforce-style-prop': 'warn',
12
- '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
13
- '@atlaskit/ui-styling-standard/no-array-arguments': 'warn',
14
- '@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
15
- '@atlaskit/ui-styling-standard/no-container-queries': 'warn',
16
- '@atlaskit/ui-styling-standard/no-dynamic-styles': 'warn',
17
- '@atlaskit/ui-styling-standard/no-exported-styles': 'warn',
18
- '@atlaskit/ui-styling-standard/no-global-styles': 'warn',
19
- '@atlaskit/ui-styling-standard/no-important-styles': 'warn',
20
- '@atlaskit/ui-styling-standard/no-imported-style-values': 'warn',
21
- '@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
22
- '@atlaskit/ui-styling-standard/no-styled': 'warn',
23
- '@atlaskit/ui-styling-standard/no-unsafe-values': 'warn',
24
- '@atlaskit/ui-styling-standard/use-compiled': 'warn',
25
- '@atlaskit/design-system/consistent-css-prop-usage': [
26
- 'warn',
27
- { excludeReactComponents: true },
28
- ],
29
- '@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
30
- '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
31
- '@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
32
- '@compiled/no-suppress-xcss': 'warn',
33
- '@compiled/no-js-xcss': 'warn',
34
- '@atlaskit/design-system/no-empty-styled-expression': [
35
- 'warn',
36
- {
37
- importSources: [
38
- '@compiled/react',
39
- '@atlaskit/css',
40
- '@emotion/core',
41
- '@emotion/react',
42
- '@emotion/styled',
43
- 'styled-components',
44
- ],
45
- },
46
- ],
47
- '@atlaskit/design-system/no-exported-css': [
48
- 'warn',
49
- {
50
- importSources: [
51
- '@compiled/react',
52
- '@atlaskit/css',
53
- '@emotion/core',
54
- '@emotion/react',
55
- '@emotion/styled',
56
- 'styled-components',
57
- ],
58
- },
59
- ],
60
- '@atlaskit/design-system/no-exported-keyframes': [
61
- 'warn',
62
- {
63
- importSources: [
64
- '@compiled/react',
65
- '@atlaskit/css',
66
- '@emotion/core',
67
- '@emotion/react',
68
- '@emotion/styled',
69
- 'styled-components',
70
- ],
71
- },
72
- ],
73
- '@atlaskit/design-system/no-invalid-css-map': [
74
- 'warn',
75
- { allowedFunctionCalls: [['@atlaskit/tokens', 'token']] },
76
- ],
77
- },
7
+ plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
+ rules: {
9
+ '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
10
+ '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
11
+ '@atlaskit/ui-styling-standard/enforce-style-prop': 'warn',
12
+ '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
13
+ '@atlaskit/ui-styling-standard/no-array-arguments': 'warn',
14
+ '@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
15
+ '@atlaskit/ui-styling-standard/no-container-queries': 'warn',
16
+ '@atlaskit/ui-styling-standard/no-dynamic-styles': 'warn',
17
+ '@atlaskit/ui-styling-standard/no-exported-styles': 'warn',
18
+ '@atlaskit/ui-styling-standard/no-global-styles': 'warn',
19
+ '@atlaskit/ui-styling-standard/no-important-styles': 'warn',
20
+ '@atlaskit/ui-styling-standard/no-imported-style-values': 'warn',
21
+ '@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
22
+ '@atlaskit/ui-styling-standard/no-styled': 'warn',
23
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'warn',
24
+ '@atlaskit/ui-styling-standard/no-unsafe-values': 'warn',
25
+ '@atlaskit/ui-styling-standard/use-compiled': 'warn',
26
+ '@atlaskit/design-system/consistent-css-prop-usage': ['warn', { excludeReactComponents: true }],
27
+ '@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
28
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
29
+ '@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
30
+ '@compiled/no-suppress-xcss': 'warn',
31
+ '@compiled/no-js-xcss': 'warn',
32
+ '@atlaskit/design-system/no-empty-styled-expression': [
33
+ 'warn',
34
+ {
35
+ importSources: [
36
+ '@compiled/react',
37
+ '@atlaskit/css',
38
+ '@emotion/core',
39
+ '@emotion/react',
40
+ '@emotion/styled',
41
+ 'styled-components',
42
+ ],
43
+ },
44
+ ],
45
+ '@atlaskit/design-system/no-exported-css': [
46
+ 'warn',
47
+ {
48
+ importSources: [
49
+ '@compiled/react',
50
+ '@atlaskit/css',
51
+ '@emotion/core',
52
+ '@emotion/react',
53
+ '@emotion/styled',
54
+ 'styled-components',
55
+ ],
56
+ },
57
+ ],
58
+ '@atlaskit/design-system/no-exported-keyframes': [
59
+ 'warn',
60
+ {
61
+ importSources: [
62
+ '@compiled/react',
63
+ '@atlaskit/css',
64
+ '@emotion/core',
65
+ '@emotion/react',
66
+ '@emotion/styled',
67
+ 'styled-components',
68
+ ],
69
+ },
70
+ ],
71
+ '@atlaskit/design-system/no-invalid-css-map': [
72
+ 'warn',
73
+ { allowedFunctionCalls: [['@atlaskit/tokens', 'token']] },
74
+ ],
75
+ },
78
76
  };
@@ -1,78 +1,76 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::40bdd5a27731185ba04e0b279fc81ac9>>
3
+ * @codegen <<SignedSource::f240d1cd5b93827327b66c28ad47e698>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
7
- plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
- rules: {
9
- '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
10
- '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
11
- '@atlaskit/ui-styling-standard/enforce-style-prop': 'warn',
12
- '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
13
- '@atlaskit/ui-styling-standard/no-array-arguments': 'warn',
14
- '@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
15
- '@atlaskit/ui-styling-standard/no-container-queries': 'warn',
16
- '@atlaskit/ui-styling-standard/no-dynamic-styles': 'warn',
17
- '@atlaskit/ui-styling-standard/no-exported-styles': 'warn',
18
- '@atlaskit/ui-styling-standard/no-global-styles': 'warn',
19
- '@atlaskit/ui-styling-standard/no-important-styles': 'warn',
20
- '@atlaskit/ui-styling-standard/no-imported-style-values': 'warn',
21
- '@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
22
- '@atlaskit/ui-styling-standard/no-styled': 'warn',
23
- '@atlaskit/ui-styling-standard/no-unsafe-values': 'warn',
24
- '@atlaskit/ui-styling-standard/use-compiled': 'warn',
25
- '@atlaskit/design-system/consistent-css-prop-usage': [
26
- 'warn',
27
- { excludeReactComponents: true },
28
- ],
29
- '@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
30
- '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
31
- '@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
32
- '@compiled/no-suppress-xcss': 'warn',
33
- '@compiled/no-js-xcss': 'warn',
34
- '@atlaskit/design-system/no-empty-styled-expression': [
35
- 'warn',
36
- {
37
- importSources: [
38
- '@compiled/react',
39
- '@atlaskit/css',
40
- '@emotion/core',
41
- '@emotion/react',
42
- '@emotion/styled',
43
- 'styled-components',
44
- ],
45
- },
46
- ],
47
- '@atlaskit/design-system/no-exported-css': [
48
- 'warn',
49
- {
50
- importSources: [
51
- '@compiled/react',
52
- '@atlaskit/css',
53
- '@emotion/core',
54
- '@emotion/react',
55
- '@emotion/styled',
56
- 'styled-components',
57
- ],
58
- },
59
- ],
60
- '@atlaskit/design-system/no-exported-keyframes': [
61
- 'warn',
62
- {
63
- importSources: [
64
- '@compiled/react',
65
- '@atlaskit/css',
66
- '@emotion/core',
67
- '@emotion/react',
68
- '@emotion/styled',
69
- 'styled-components',
70
- ],
71
- },
72
- ],
73
- '@atlaskit/design-system/no-invalid-css-map': [
74
- 'warn',
75
- { allowedFunctionCalls: [['@atlaskit/tokens', 'token']] },
76
- ],
77
- },
7
+ plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
+ rules: {
9
+ '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
10
+ '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
11
+ '@atlaskit/ui-styling-standard/enforce-style-prop': 'warn',
12
+ '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
13
+ '@atlaskit/ui-styling-standard/no-array-arguments': 'warn',
14
+ '@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
15
+ '@atlaskit/ui-styling-standard/no-container-queries': 'warn',
16
+ '@atlaskit/ui-styling-standard/no-dynamic-styles': 'warn',
17
+ '@atlaskit/ui-styling-standard/no-exported-styles': 'warn',
18
+ '@atlaskit/ui-styling-standard/no-global-styles': 'warn',
19
+ '@atlaskit/ui-styling-standard/no-important-styles': 'warn',
20
+ '@atlaskit/ui-styling-standard/no-imported-style-values': 'warn',
21
+ '@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
22
+ '@atlaskit/ui-styling-standard/no-styled': 'warn',
23
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'warn',
24
+ '@atlaskit/ui-styling-standard/no-unsafe-values': 'warn',
25
+ '@atlaskit/ui-styling-standard/use-compiled': 'warn',
26
+ '@atlaskit/design-system/consistent-css-prop-usage': ['warn', { excludeReactComponents: true }],
27
+ '@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
28
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
29
+ '@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
30
+ '@compiled/no-suppress-xcss': 'warn',
31
+ '@compiled/no-js-xcss': 'warn',
32
+ '@atlaskit/design-system/no-empty-styled-expression': [
33
+ 'warn',
34
+ {
35
+ importSources: [
36
+ '@compiled/react',
37
+ '@atlaskit/css',
38
+ '@emotion/core',
39
+ '@emotion/react',
40
+ '@emotion/styled',
41
+ 'styled-components',
42
+ ],
43
+ },
44
+ ],
45
+ '@atlaskit/design-system/no-exported-css': [
46
+ 'warn',
47
+ {
48
+ importSources: [
49
+ '@compiled/react',
50
+ '@atlaskit/css',
51
+ '@emotion/core',
52
+ '@emotion/react',
53
+ '@emotion/styled',
54
+ 'styled-components',
55
+ ],
56
+ },
57
+ ],
58
+ '@atlaskit/design-system/no-exported-keyframes': [
59
+ 'warn',
60
+ {
61
+ importSources: [
62
+ '@compiled/react',
63
+ '@atlaskit/css',
64
+ '@emotion/core',
65
+ '@emotion/react',
66
+ '@emotion/styled',
67
+ 'styled-components',
68
+ ],
69
+ },
70
+ ],
71
+ '@atlaskit/design-system/no-invalid-css-map': [
72
+ 'warn',
73
+ { allowedFunctionCalls: [['@atlaskit/tokens', 'token']] },
74
+ ],
75
+ },
78
76
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::417762b5fc4a56c3b69c22b8ac0d12e7>>
3
+ * @codegen <<SignedSource::6ad0de2d4bdac726387f27681ad9fcf4>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  import atlaskitTheme from './atlaskit-theme';
@@ -17,24 +17,26 @@ import noImportantStyles from './no-important-styles';
17
17
  import noImportedStyleValues from './no-imported-style-values';
18
18
  import noNestedSelectors from './no-nested-selectors';
19
19
  import noStyled from './no-styled';
20
+ import noUnsafeSelectors from './no-unsafe-selectors';
20
21
  import noUnsafeValues from './no-unsafe-values';
21
22
  import useCompiled from './use-compiled';
22
23
 
23
24
  export default {
24
- 'atlaskit-theme': atlaskitTheme,
25
- 'convert-props-syntax': convertPropsSyntax,
26
- 'enforce-style-prop': enforceStyleProp,
27
- 'local-cx-xcss': localCxXcss,
28
- 'no-array-arguments': noArrayArguments,
29
- 'no-classname-prop': noClassnameProp,
30
- 'no-container-queries': noContainerQueries,
31
- 'no-dynamic-styles': noDynamicStyles,
32
- 'no-exported-styles': noExportedStyles,
33
- 'no-global-styles': noGlobalStyles,
34
- 'no-important-styles': noImportantStyles,
35
- 'no-imported-style-values': noImportedStyleValues,
36
- 'no-nested-selectors': noNestedSelectors,
37
- 'no-styled': noStyled,
38
- 'no-unsafe-values': noUnsafeValues,
39
- 'use-compiled': useCompiled,
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,
40
42
  };
@@ -1,4 +1,4 @@
1
- import { isNodeOfType, Node } from 'eslint-codemod-utils';
1
+ import { isNodeOfType, type Node } from 'eslint-codemod-utils';
2
2
 
3
3
  import { createLintRule } from '../utils/create-rule';
4
4
 
@@ -7,7 +7,7 @@ import {
7
7
  getImportSources,
8
8
  } from '@atlaskit/eslint-utils/is-supported-import';
9
9
  import { createLintRule } from '../utils/create-rule';
10
- import { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
10
+ import { type JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
11
11
 
12
12
  const schema: JSONSchema4 = [
13
13
  {
@@ -0,0 +1,232 @@
1
+ Disallows unsafe selectors in CSS-in-JS style objects.
2
+
3
+ This enables static analysis and prevents regressions and incidents when migrating between styling APIs.
4
+
5
+ Use this rule alongside [no-nested-selectors](https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-nested-selectors/usage) as the rules are complementary.
6
+
7
+ ## Examples
8
+
9
+ ### Incorrect
10
+
11
+ **No @keyframes at-rules**
12
+
13
+ Use the `keyframes` CSS-in-JS API instead.
14
+
15
+ ```ts
16
+ css({
17
+ '@keyframes fadeIn': {
18
+ from: {
19
+ opacity: 0,
20
+ },
21
+ to: {
22
+ opacity: 1,
23
+ },
24
+ },
25
+ });
26
+ ```
27
+
28
+ **No legacy pseudo-element syntax**
29
+
30
+ Use the `::` double colon syntax for pseudo-elements.
31
+
32
+ _Auto-fixer is available for this violation._
33
+
34
+ ```ts
35
+ css({
36
+ ':after': {
37
+ content: '""',
38
+ width: 100,
39
+ height: 100,
40
+ backgroundColor: 'red',
41
+ },
42
+ });
43
+ ```
44
+
45
+ **No increased specificity selectors**
46
+
47
+ Use styles that do not require increased specificity.
48
+
49
+ ```ts
50
+ css({
51
+ '&&': {
52
+ color: 'red',
53
+ },
54
+ });
55
+ ```
56
+
57
+ **No restricted at-rules**
58
+
59
+ ```ts
60
+ css({
61
+ '@scope (.article-body) to (figure)': {
62
+ img: {
63
+ display: 'block',
64
+ },
65
+ },
66
+ });
67
+ ```
68
+
69
+ **No restricted pseudos**
70
+
71
+ ```ts
72
+ css({
73
+ '&:first-child': {
74
+ width: 100,
75
+ },
76
+ });
77
+ ```
78
+
79
+ **No ambiguous pseudos**
80
+
81
+ A pseudo-selector without a leading selector is ambiguous and is interpreted differently between contexts.
82
+
83
+ Most CSS-in-JS libraries will implicitly add the nesting selector `&` before ambiguous pseudo-selectors. This is often the desired behavior.
84
+
85
+ The CSS nesting specification, CSS pre-processors, newer versions of `styled-components` (version 6+) and potentially future versions of `@emotion/*` will treat ambiguous pseudo-selectors as descendant selectors.
86
+
87
+ Use explicit selectors. Do not rely on implicit behavior for pseudo-selectors.
88
+
89
+ _Auto-fixer is available for this violation. By default a nesting selector `&` is added unless the `shouldAlwaysInsertNestingSelectorForAmbiguousPseudos` option is disabled._
90
+
91
+ ```ts
92
+ css({
93
+ /**
94
+ * This pseudo-class has no leading selector and is ambiguous.
95
+ */
96
+ ':hover': {},
97
+
98
+ /**
99
+ * In some contexts the above is treated as implicitly containing a nesting selector.
100
+ */
101
+ '&:hover': {},
102
+
103
+ /**
104
+ * In other contexts it is treated as a descendant selector.
105
+ *
106
+ * (The selectors below are equivalent.)
107
+ */
108
+ '*:hover': {},
109
+ '& :hover': {},
110
+ '& *:hover': {},
111
+ });
112
+ ```
113
+
114
+ **No grouped at-rules**
115
+
116
+ Do not group at-rules with the `cssMap` API.
117
+
118
+ Write flattened at-rules instead.
119
+
120
+ ```ts
121
+ cssMap({
122
+ success: {
123
+ '@media': {
124
+ '(min-width: 900px)': {},
125
+ '(min-width: 1200px)': {},
126
+ },
127
+ },
128
+ });
129
+ ```
130
+
131
+ **No selectors object**
132
+
133
+ Do not use a selectors object with the `cssMap` API.
134
+
135
+ Refactor your styles so it is not required.
136
+
137
+ ```ts
138
+ cssMap({
139
+ success: {
140
+ selectors: {
141
+ '&:not(:active)': {
142
+ backgroundColor: 'white',
143
+ },
144
+ },
145
+ },
146
+ });
147
+ ```
148
+
149
+ ### Correct
150
+
151
+ ```ts
152
+ const fadeIn = keyframes({
153
+ from: {
154
+ opacity: 0,
155
+ },
156
+ to: {
157
+ opacity: 1,
158
+ },
159
+ });
160
+
161
+ css({
162
+ animationName: fadeIn,
163
+ });
164
+ ```
165
+
166
+ ```ts
167
+ css({
168
+ '::after': {
169
+ content: '""',
170
+ width: 100,
171
+ height: 100,
172
+ backgroundColor: 'red',
173
+ },
174
+ });
175
+ ```
176
+
177
+ ```ts
178
+ css({
179
+ '&:first-of-type': {
180
+ width: 100,
181
+ },
182
+ });
183
+ ```
184
+
185
+ ```ts
186
+ css({
187
+ '&:hover': {},
188
+ });
189
+ ```
190
+
191
+ ```ts
192
+ cssMap({
193
+ success: {
194
+ '@media (min-width: 900px)': {},
195
+ '@media (min-width: 1200px)': {},
196
+ },
197
+ });
198
+ ```
199
+
200
+ ```ts
201
+ cssMap({
202
+ success: {
203
+ backgroundColor: 'white',
204
+ '&:active': {
205
+ backgroundColor: 'green',
206
+ },
207
+ },
208
+ });
209
+ ```
210
+
211
+ ## Options
212
+
213
+ ### `importSources: string[]`
214
+
215
+ By default, this rule will check `css` usages from:
216
+
217
+ - `@atlaskit/css`
218
+ - `@atlaskit/primitives`
219
+ - `@compiled/react`
220
+ - `@emotion/react`
221
+ - `@emotion/core`
222
+ - `@emotion/styled`
223
+ - `styled-components`
224
+
225
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
226
+ This will override the built-in allow-list.
227
+
228
+ ### `shouldAlwaysInsertNestingSelectorForAmbiguousPseudos: boolean`
229
+
230
+ By default this rule will always fix ambiguous pseudo-selectors by inserting a leading `&` (nesting selector).
231
+
232
+ Set `shouldAlwaysInsertNestingSelectorForAmbiguousPseudos` to `false` to disable this auto-fix. When disabled, a suggestion will be provided instead of an auto-fix.