@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
@@ -0,0 +1,179 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ /**
3
+ * This util is intentionally not in `@atlaskit/eslint-utils` at this time.
4
+ *
5
+ * This is because the API is likely to change and should not be considered stable.
6
+ */
7
+
8
+ export function walkCssMap(_ref) {
9
+ var context = _ref.context,
10
+ importSources = _ref.importSources,
11
+ visitor = _ref.visitor;
12
+ var program = context.getSourceCode().ast;
13
+ var importDeclaration = program.body.find(function (node) {
14
+ return node.type === 'ImportDeclaration' && importSources.includes(node.source.value);
15
+ });
16
+ var specifier = importDeclaration === null || importDeclaration === void 0 ? void 0 : importDeclaration.specifiers.find(function (specifier) {
17
+ return specifier.type === 'ImportSpecifier' && specifier.imported.name === 'cssMap';
18
+ });
19
+ if (!specifier) {
20
+ return;
21
+ }
22
+ var _context$getSourceCod = context.getSourceCode().scopeManager.getDeclaredVariables(specifier),
23
+ _context$getSourceCod2 = _slicedToArray(_context$getSourceCod, 1),
24
+ variable = _context$getSourceCod2[0];
25
+ if (!variable) {
26
+ return;
27
+ }
28
+ variable.references.forEach(function (reference) {
29
+ var identifier = reference.identifier;
30
+ var parent = identifier.parent;
31
+ if (parent.type !== 'CallExpression') {
32
+ return;
33
+ }
34
+ var variantMap = parent.arguments[0];
35
+ if (variantMap.type !== 'ObjectExpression') {
36
+ return;
37
+ }
38
+ walkCssMapVariantMap({
39
+ variantMap: variantMap,
40
+ visitor: visitor
41
+ });
42
+ });
43
+ }
44
+ function walkCssMapVariantMap(_ref2) {
45
+ var variantMap = _ref2.variantMap,
46
+ visitor = _ref2.visitor;
47
+ variantMap.properties.forEach(function (property) {
48
+ if (property.type !== 'Property') {
49
+ return;
50
+ }
51
+ walkCssMapVariant({
52
+ variant: property,
53
+ visitor: visitor
54
+ });
55
+ });
56
+ }
57
+ function walkCssMapVariant(_ref3) {
58
+ var variant = _ref3.variant,
59
+ visitor = _ref3.visitor;
60
+ visitor({
61
+ type: 'variant',
62
+ node: variant
63
+ });
64
+ if (variant.value.type !== 'ObjectExpression') {
65
+ return;
66
+ }
67
+ variant.value.properties.forEach(function (property) {
68
+ if (property.type !== 'Property') {
69
+ return;
70
+ }
71
+ if (property.value.type !== 'ObjectExpression') {
72
+ visitor({
73
+ type: 'declaration',
74
+ node: property
75
+ });
76
+ return;
77
+ }
78
+ var keyValue = getKeyValue(property.key);
79
+ if (keyValue && /^@[A-z-]+$/.test(keyValue)) {
80
+ walkCssMapAtRuleGrouping({
81
+ atRuleGrouping: property,
82
+ visitor: visitor
83
+ });
84
+ return;
85
+ }
86
+ if (keyValue === 'selectors') {
87
+ walkCssMapSelectors({
88
+ selectors: property,
89
+ visitor: visitor
90
+ });
91
+ }
92
+ walkStyleRuleset({
93
+ ruleset: property,
94
+ visitor: visitor
95
+ });
96
+ });
97
+ }
98
+ function walkCssMapAtRuleGrouping(_ref4) {
99
+ var atRuleGrouping = _ref4.atRuleGrouping,
100
+ visitor = _ref4.visitor;
101
+ var atRule = getKeyValue(atRuleGrouping.key);
102
+ if (!atRule) {
103
+ return;
104
+ }
105
+ visitor({
106
+ type: 'grouped-at-rules',
107
+ node: atRuleGrouping,
108
+ atRule: atRule
109
+ });
110
+ if (atRuleGrouping.value.type !== 'ObjectExpression') {
111
+ return;
112
+ }
113
+ atRuleGrouping.value.properties.forEach(function (property) {
114
+ if (property.type !== 'Property') {
115
+ return;
116
+ }
117
+ walkStyleRuleset({
118
+ ruleset: property,
119
+ visitor: visitor
120
+ });
121
+ });
122
+ }
123
+ function walkCssMapSelectors(_ref5) {
124
+ var selectors = _ref5.selectors,
125
+ visitor = _ref5.visitor;
126
+ visitor({
127
+ type: 'selectors',
128
+ node: selectors
129
+ });
130
+ if (selectors.value.type !== 'ObjectExpression') {
131
+ return;
132
+ }
133
+ selectors.value.properties.forEach(function (property) {
134
+ if (property.type !== 'Property') {
135
+ return;
136
+ }
137
+ walkStyleRuleset({
138
+ ruleset: property,
139
+ visitor: visitor
140
+ });
141
+ });
142
+ }
143
+ function walkStyleRuleset(_ref6) {
144
+ var ruleset = _ref6.ruleset,
145
+ visitor = _ref6.visitor;
146
+ visitor({
147
+ type: 'ruleset',
148
+ node: ruleset
149
+ });
150
+ if (ruleset.value.type !== 'ObjectExpression') {
151
+ return;
152
+ }
153
+ ruleset.value.properties.forEach(function (property) {
154
+ if (property.type !== 'Property') {
155
+ return;
156
+ }
157
+ if (property.value.type === 'ObjectExpression') {
158
+ walkStyleRuleset({
159
+ ruleset: property,
160
+ visitor: visitor
161
+ });
162
+ return;
163
+ }
164
+ visitor({
165
+ type: 'declaration',
166
+ node: property
167
+ });
168
+ });
169
+ }
170
+ function getKeyValue(key) {
171
+ if (key.type === 'Identifier') {
172
+ return key.name;
173
+ }
174
+ if (key.type === 'Literal') {
175
+ var _key$value$toString, _key$value;
176
+ return (_key$value$toString = (_key$value = key.value) === null || _key$value === void 0 ? void 0 : _key$value.toString()) !== null && _key$value$toString !== void 0 ? _key$value$toString : null;
177
+ }
178
+ return null;
179
+ }
@@ -17,6 +17,7 @@ export declare const configs: {
17
17
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
18
18
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
19
19
  '@atlaskit/ui-styling-standard/no-styled': string;
20
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': string;
20
21
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
21
22
  '@atlaskit/ui-styling-standard/use-compiled': string;
22
23
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -58,6 +59,7 @@ export declare const configs: {
58
59
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
59
60
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
60
61
  '@atlaskit/ui-styling-standard/no-styled': string;
62
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': string;
61
63
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
62
64
  '@atlaskit/ui-styling-standard/use-compiled': string;
63
65
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -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::40bdd5a27731185ba04e0b279fc81ac9>>
3
+ * @codegen <<SignedSource::f240d1cd5b93827327b66c28ad47e698>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -20,6 +20,7 @@ declare const _default: {
20
20
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
21
21
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
22
22
  '@atlaskit/ui-styling-standard/no-styled': string;
23
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': string;
23
24
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
24
25
  '@atlaskit/ui-styling-standard/use-compiled': string;
25
26
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -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::40bdd5a27731185ba04e0b279fc81ac9>>
3
+ * @codegen <<SignedSource::f240d1cd5b93827327b66c28ad47e698>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -20,6 +20,7 @@ declare const _default: {
20
20
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
21
21
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
22
22
  '@atlaskit/ui-styling-standard/no-styled': string;
23
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': string;
23
24
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
24
25
  '@atlaskit/ui-styling-standard/use-compiled': string;
25
26
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -13,6 +13,7 @@ declare const _default: {
13
13
  'no-imported-style-values': import("eslint").Rule.RuleModule;
14
14
  'no-nested-selectors': import("eslint").Rule.RuleModule;
15
15
  'no-styled': import("eslint").Rule.RuleModule;
16
+ 'no-unsafe-selectors': import("eslint").Rule.RuleModule;
16
17
  'no-unsafe-values': import("eslint").Rule.RuleModule;
17
18
  'use-compiled': import("eslint").Rule.RuleModule;
18
19
  };
@@ -0,0 +1,23 @@
1
+ import type { CSSPseudos } from '@compiled/react';
2
+ /**
3
+ * Validation approach from
4
+ * https://stackoverflow.com/a/71236280
5
+ */
6
+ type Validate<T extends true> = T;
7
+ type HasAllUnique<Tuple, Union, Seen = never> = Tuple extends readonly [
8
+ infer Head,
9
+ ...infer Tail
10
+ ] ? Head extends Seen ? {
11
+ ERROR: ['The following key appears more than once in the tuple:', Head];
12
+ } : HasAllUnique<Tail, Exclude<Union, Head>, Head | Seen> : [Union] extends [never] ? true : {
13
+ ERROR: ['Some keys are missing from the tuple:', Union];
14
+ };
15
+ /**
16
+ * Exporting this so it isn't considered unused.
17
+ */
18
+ export type _ = Validate<HasAllUnique<typeof cssPseudos, CSSPseudos>>;
19
+ declare const cssPseudos: readonly ["&:active", "&:autofill", "&:blank", "&:checked", "&:default", "&:defined", "&:disabled", "&:empty", "&:enabled", "&:first", "&:focus", "&:focus-visible", "&:focus-within", "&:fullscreen", "&:hover", "&:in-range", "&:indeterminate", "&:invalid", "&:left", "&:link", "&:local-link", "&:optional", "&:out-of-range", "&:paused", "&:picture-in-picture", "&:placeholder-shown", "&:playing", "&:read-only", "&:read-write", "&:required", "&:right", "&:target", "&:user-invalid", "&:user-valid", "&:valid", "&:visited", "&::after", "&::backdrop", "&::before", "&::cue", "&::cue-region", "&::first-letter", "&::first-line", "&::grammar-error", "&::marker", "&::placeholder", "&::selection", "&::spelling-error", "&::target-text", "&::view-transition"];
20
+ export declare const allowedPseudos: Set<string>;
21
+ export declare const legacyPseudoElements: Set<string>;
22
+ export declare const ignoredAtRules: Set<string>;
23
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,14 @@
1
+ import type { Rule } from 'eslint';
2
+ import type * as ESTree from 'eslint-codemod-utils';
3
+ import { type Selector } from 'postcss-selector-parser';
4
+ type CheckArgs = {
5
+ context: Rule.RuleContext;
6
+ sourceNode: ESTree.Node;
7
+ selector: Selector;
8
+ config: {
9
+ shouldAlwaysInsertNestingSelectorForAmbiguousPseudos: boolean;
10
+ };
11
+ isXcssCall: boolean;
12
+ };
13
+ export declare function lintSelector(args: CheckArgs): void;
14
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { AST, Rule } from 'eslint';
2
+ import type * as ESTree from 'eslint-codemod-utils';
3
+ import { type Node as SelectorNode } from 'postcss-selector-parser';
4
+ type Range = [number, number];
5
+ export declare function getRangeFromNode({ node, sourceNode, }: {
6
+ /**
7
+ * The selector AST node to get the range of.
8
+ */
9
+ node: SelectorNode & {
10
+ value: string;
11
+ };
12
+ /**
13
+ * The source ESTree node whose value was parsed to obtain the selector AST.
14
+ *
15
+ * The range is calculated relative to this node's range.
16
+ */
17
+ sourceNode: ESTree.Node;
18
+ }): Range;
19
+ export declare function getSourceLocationFromRange(context: Rule.RuleContext, [start, end]: Range): AST.SourceLocation;
20
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * This util is intentionally not in `@atlaskit/eslint-utils` at this time.
3
+ *
4
+ * This is because the API is likely to change and should not be considered stable.
5
+ */
6
+ import type { Rule } from 'eslint';
7
+ import type * as ESTree from 'eslint-codemod-utils';
8
+ type CssMapVisitorArgs = {
9
+ type: 'variant' | 'declaration' | 'ruleset' | 'selectors';
10
+ node: ESTree.Property;
11
+ } | {
12
+ type: 'grouped-at-rules';
13
+ node: ESTree.Property;
14
+ atRule: string;
15
+ };
16
+ type CssMapVisitor = (args: CssMapVisitorArgs) => void;
17
+ export declare function walkCssMap({ context, importSources, visitor, }: {
18
+ context: Rule.RuleContext;
19
+ program: ESTree.Program;
20
+ importSources: string[];
21
+ visitor: CssMapVisitor;
22
+ }): void;
23
+ export {};
@@ -17,6 +17,7 @@ export declare const configs: {
17
17
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
18
18
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
19
19
  '@atlaskit/ui-styling-standard/no-styled': string;
20
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': string;
20
21
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
21
22
  '@atlaskit/ui-styling-standard/use-compiled': string;
22
23
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -58,6 +59,7 @@ export declare const configs: {
58
59
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
59
60
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
60
61
  '@atlaskit/ui-styling-standard/no-styled': string;
62
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': string;
61
63
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
62
64
  '@atlaskit/ui-styling-standard/use-compiled': string;
63
65
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -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::40bdd5a27731185ba04e0b279fc81ac9>>
3
+ * @codegen <<SignedSource::f240d1cd5b93827327b66c28ad47e698>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -20,6 +20,7 @@ declare const _default: {
20
20
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
21
21
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
22
22
  '@atlaskit/ui-styling-standard/no-styled': string;
23
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': string;
23
24
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
24
25
  '@atlaskit/ui-styling-standard/use-compiled': string;
25
26
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -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::40bdd5a27731185ba04e0b279fc81ac9>>
3
+ * @codegen <<SignedSource::f240d1cd5b93827327b66c28ad47e698>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -20,6 +20,7 @@ declare const _default: {
20
20
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
21
21
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
22
22
  '@atlaskit/ui-styling-standard/no-styled': string;
23
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': string;
23
24
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
24
25
  '@atlaskit/ui-styling-standard/use-compiled': string;
25
26
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
@@ -13,6 +13,7 @@ declare const _default: {
13
13
  'no-imported-style-values': import("eslint").Rule.RuleModule;
14
14
  'no-nested-selectors': import("eslint").Rule.RuleModule;
15
15
  'no-styled': import("eslint").Rule.RuleModule;
16
+ 'no-unsafe-selectors': import("eslint").Rule.RuleModule;
16
17
  'no-unsafe-values': import("eslint").Rule.RuleModule;
17
18
  'use-compiled': import("eslint").Rule.RuleModule;
18
19
  };
@@ -0,0 +1,84 @@
1
+ import type { CSSPseudos } from '@compiled/react';
2
+ /**
3
+ * Validation approach from
4
+ * https://stackoverflow.com/a/71236280
5
+ */
6
+ type Validate<T extends true> = T;
7
+ type HasAllUnique<Tuple, Union, Seen = never> = Tuple extends readonly [
8
+ infer Head,
9
+ ...infer Tail
10
+ ] ? Head extends Seen ? {
11
+ ERROR: [
12
+ 'The following key appears more than once in the tuple:',
13
+ Head
14
+ ];
15
+ } : HasAllUnique<Tail, Exclude<Union, Head>, Head | Seen> : [
16
+ Union
17
+ ] extends [
18
+ never
19
+ ] ? true : {
20
+ ERROR: [
21
+ 'Some keys are missing from the tuple:',
22
+ Union
23
+ ];
24
+ };
25
+ /**
26
+ * Exporting this so it isn't considered unused.
27
+ */
28
+ export type _ = Validate<HasAllUnique<typeof cssPseudos, CSSPseudos>>;
29
+ declare const cssPseudos: readonly [
30
+ "&:active",
31
+ "&:autofill",
32
+ "&:blank",
33
+ "&:checked",
34
+ "&:default",
35
+ "&:defined",
36
+ "&:disabled",
37
+ "&:empty",
38
+ "&:enabled",
39
+ "&:first",
40
+ "&:focus",
41
+ "&:focus-visible",
42
+ "&:focus-within",
43
+ "&:fullscreen",
44
+ "&:hover",
45
+ "&:in-range",
46
+ "&:indeterminate",
47
+ "&:invalid",
48
+ "&:left",
49
+ "&:link",
50
+ "&:local-link",
51
+ "&:optional",
52
+ "&:out-of-range",
53
+ "&:paused",
54
+ "&:picture-in-picture",
55
+ "&:placeholder-shown",
56
+ "&:playing",
57
+ "&:read-only",
58
+ "&:read-write",
59
+ "&:required",
60
+ "&:right",
61
+ "&:target",
62
+ "&:user-invalid",
63
+ "&:user-valid",
64
+ "&:valid",
65
+ "&:visited",
66
+ "&::after",
67
+ "&::backdrop",
68
+ "&::before",
69
+ "&::cue",
70
+ "&::cue-region",
71
+ "&::first-letter",
72
+ "&::first-line",
73
+ "&::grammar-error",
74
+ "&::marker",
75
+ "&::placeholder",
76
+ "&::selection",
77
+ "&::spelling-error",
78
+ "&::target-text",
79
+ "&::view-transition"
80
+ ];
81
+ export declare const allowedPseudos: Set<string>;
82
+ export declare const legacyPseudoElements: Set<string>;
83
+ export declare const ignoredAtRules: Set<string>;
84
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,14 @@
1
+ import type { Rule } from 'eslint';
2
+ import type * as ESTree from 'eslint-codemod-utils';
3
+ import { type Selector } from 'postcss-selector-parser';
4
+ type CheckArgs = {
5
+ context: Rule.RuleContext;
6
+ sourceNode: ESTree.Node;
7
+ selector: Selector;
8
+ config: {
9
+ shouldAlwaysInsertNestingSelectorForAmbiguousPseudos: boolean;
10
+ };
11
+ isXcssCall: boolean;
12
+ };
13
+ export declare function lintSelector(args: CheckArgs): void;
14
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { AST, Rule } from 'eslint';
2
+ import type * as ESTree from 'eslint-codemod-utils';
3
+ import { type Node as SelectorNode } from 'postcss-selector-parser';
4
+ type Range = [
5
+ number,
6
+ number
7
+ ];
8
+ export declare function getRangeFromNode({ node, sourceNode, }: {
9
+ /**
10
+ * The selector AST node to get the range of.
11
+ */
12
+ node: SelectorNode & {
13
+ value: string;
14
+ };
15
+ /**
16
+ * The source ESTree node whose value was parsed to obtain the selector AST.
17
+ *
18
+ * The range is calculated relative to this node's range.
19
+ */
20
+ sourceNode: ESTree.Node;
21
+ }): Range;
22
+ export declare function getSourceLocationFromRange(context: Rule.RuleContext, [start, end]: Range): AST.SourceLocation;
23
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * This util is intentionally not in `@atlaskit/eslint-utils` at this time.
3
+ *
4
+ * This is because the API is likely to change and should not be considered stable.
5
+ */
6
+ import type { Rule } from 'eslint';
7
+ import type * as ESTree from 'eslint-codemod-utils';
8
+ type CssMapVisitorArgs = {
9
+ type: 'variant' | 'declaration' | 'ruleset' | 'selectors';
10
+ node: ESTree.Property;
11
+ } | {
12
+ type: 'grouped-at-rules';
13
+ node: ESTree.Property;
14
+ atRule: string;
15
+ };
16
+ type CssMapVisitor = (args: CssMapVisitorArgs) => void;
17
+ export declare function walkCssMap({ context, importSources, visitor, }: {
18
+ context: Rule.RuleContext;
19
+ program: ESTree.Program;
20
+ importSources: string[];
21
+ visitor: CssMapVisitor;
22
+ }): void;
23
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
- "version": "0.14.2",
3
+ "version": "0.15.1",
4
4
  "author": "Atlassian Pty Ltd",
5
5
  "description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
6
6
  "license": "Apache-2.0",
@@ -39,7 +39,7 @@
39
39
  ".": "./src/index.tsx"
40
40
  },
41
41
  "dependencies": {
42
- "@atlaskit/eslint-utils": "^1.4.0",
42
+ "@atlaskit/eslint-utils": "^1.5.0",
43
43
  "@babel/runtime": "^7.0.0",
44
44
  "@typescript-eslint/utils": "^5.48.1",
45
45
  "ajv": "^6.12.6",
@@ -47,19 +47,19 @@
47
47
  "eslint-scope": "^8.0.0",
48
48
  "esquery": "^1.5.0",
49
49
  "estraverse": "^5.3.0",
50
- "outdent": "^0.5.0"
50
+ "json-schema-to-ts": "^3.1.0",
51
+ "outdent": "^0.5.0",
52
+ "postcss-selector-parser": "^6.0.16"
51
53
  },
52
54
  "devDependencies": {
53
55
  "@af/formatting": "*",
54
56
  "@atlaskit/ds-lib": "^2.3.0",
55
- "@atlaskit/eslint-plugin-design-system": "^10.2.0",
56
- "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
57
+ "@atlaskit/eslint-plugin-design-system": "^10.4.0",
57
58
  "@atlassian/codegen": "*",
58
59
  "@compiled/eslint-plugin": "^0.13.6",
59
60
  "@types/eslint": "^8.56.6",
60
61
  "@types/estraverse": "^5.1.7",
61
62
  "eslint": "^8.49.0",
62
- "json-schema-to-ts": "^3.1.0",
63
63
  "lodash": "^4.17.21",
64
64
  "ts-node": "^10.9.1",
65
65
  "tsconfig-paths": "^4.2.0",
@@ -67,6 +67,5 @@
67
67
  },
68
68
  "scripts": {
69
69
  "codegen": "ts-node -r tsconfig-paths/register ./scripts/codegen.tsx"
70
- },
71
- "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
70
+ }
72
71
  }
@@ -18,7 +18,8 @@ import {
18
18
  } from '../src/rules/external-rules';
19
19
 
20
20
  const packagePluginName = '@atlaskit/eslint-plugin-ui-styling-standard';
21
- const pluginName = packagePluginName.replace('/eslint-plugin-', '/');
21
+ const pluginName = '@atlaskit/ui-styling-standard';
22
+ const pluginPath = 'eslint-plugin-ui-styling-standard';
22
23
  const codegenCommand = `yarn workspace ${packagePluginName} codegen`;
23
24
 
24
25
  interface FoundRule {
@@ -298,9 +299,7 @@ async function generateRuleTable(
298
299
  let docsPath: string | undefined;
299
300
 
300
301
  if (linkTo === 'docs') {
301
- // We want `<a href="consistent-css-prop-usage/usage">consistent-css-prop-usage</a>` for the link
302
- // to resolve to `/components/eslint-plugin-design-system/consistent-css-prop-usage/usage`
303
- docsPath = `${rule.pathSafeName}/usage`;
302
+ docsPath = `/components/${pluginPath}/${rule.pathSafeName}/usage`;
304
303
  } else if (ruleIsInternal(rule)) {
305
304
  const result = await ruleDocsPath(rule.pathSafeName);
306
305
  docsPath = result.path;
@@ -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::16a3441765e5a97f9f32de7fd0de17f0>>
3
+ * @codegen <<SignedSource::aff3fad2b8534fad07ba5f0f1b981a55>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  import all from './presets/all.codegen';
@@ -9,6 +9,6 @@ import recommended from './presets/recommended.codegen';
9
9
  export { default as rules } from './rules/index.codegen';
10
10
 
11
11
  export const configs = {
12
- all,
13
- recommended,
12
+ all,
13
+ recommended,
14
14
  };