@atlaskit/eslint-plugin-ui-styling-standard 0.14.2 → 0.15.0

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 (71) hide show
  1. package/CHANGELOG.md +13 -0
  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/index/overview.mdx +29 -28
  6. package/constellation/no-unsafe-selectors/usage.mdx +244 -0
  7. package/dist/cjs/presets/all.codegen.js +2 -1
  8. package/dist/cjs/presets/recommended.codegen.js +2 -1
  9. package/dist/cjs/rules/index.codegen.js +3 -1
  10. package/dist/cjs/rules/no-unsafe-selectors/constants.js +30 -0
  11. package/dist/cjs/rules/no-unsafe-selectors/index.js +185 -0
  12. package/dist/cjs/rules/no-unsafe-selectors/lint-selector.js +189 -0
  13. package/dist/cjs/rules/no-unsafe-selectors/source-position-utils.js +42 -0
  14. package/dist/cjs/rules/no-unsafe-selectors/walk-css-map.js +186 -0
  15. package/dist/es2019/presets/all.codegen.js +2 -1
  16. package/dist/es2019/presets/recommended.codegen.js +2 -1
  17. package/dist/es2019/rules/index.codegen.js +3 -1
  18. package/dist/es2019/rules/no-unsafe-selectors/constants.js +22 -0
  19. package/dist/es2019/rules/no-unsafe-selectors/index.js +173 -0
  20. package/dist/es2019/rules/no-unsafe-selectors/lint-selector.js +152 -0
  21. package/dist/es2019/rules/no-unsafe-selectors/source-position-utils.js +31 -0
  22. package/dist/es2019/rules/no-unsafe-selectors/walk-css-map.js +180 -0
  23. package/dist/esm/presets/all.codegen.js +2 -1
  24. package/dist/esm/presets/recommended.codegen.js +2 -1
  25. package/dist/esm/rules/index.codegen.js +3 -1
  26. package/dist/esm/rules/no-unsafe-selectors/constants.js +24 -0
  27. package/dist/esm/rules/no-unsafe-selectors/index.js +178 -0
  28. package/dist/esm/rules/no-unsafe-selectors/lint-selector.js +182 -0
  29. package/dist/esm/rules/no-unsafe-selectors/source-position-utils.js +34 -0
  30. package/dist/esm/rules/no-unsafe-selectors/walk-css-map.js +179 -0
  31. package/dist/types/index.codegen.d.ts +2 -0
  32. package/dist/types/presets/all.codegen.d.ts +2 -1
  33. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  34. package/dist/types/rules/index.codegen.d.ts +1 -0
  35. package/dist/types/rules/no-unsafe-selectors/constants.d.ts +23 -0
  36. package/dist/types/rules/no-unsafe-selectors/index.d.ts +3 -0
  37. package/dist/types/rules/no-unsafe-selectors/lint-selector.d.ts +13 -0
  38. package/dist/types/rules/no-unsafe-selectors/source-position-utils.d.ts +20 -0
  39. package/dist/types/rules/no-unsafe-selectors/walk-css-map.d.ts +23 -0
  40. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  41. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  42. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  43. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  44. package/dist/types-ts4.5/rules/no-unsafe-selectors/constants.d.ts +84 -0
  45. package/dist/types-ts4.5/rules/no-unsafe-selectors/index.d.ts +3 -0
  46. package/dist/types-ts4.5/rules/no-unsafe-selectors/lint-selector.d.ts +13 -0
  47. package/dist/types-ts4.5/rules/no-unsafe-selectors/source-position-utils.d.ts +23 -0
  48. package/dist/types-ts4.5/rules/no-unsafe-selectors/walk-css-map.d.ts +23 -0
  49. package/package.json +6 -5
  50. package/scripts/codegen.tsx +3 -4
  51. package/src/presets/all.codegen.tsx +2 -1
  52. package/src/presets/recommended.codegen.tsx +2 -1
  53. package/src/rules/index.codegen.tsx +3 -1
  54. package/src/rules/no-classname-prop/index.tsx +1 -1
  55. package/src/rules/no-nested-selectors/index.tsx +1 -1
  56. package/src/rules/no-unsafe-selectors/README.md +232 -0
  57. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +358 -0
  58. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +60 -0
  59. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +73 -0
  60. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +40 -0
  61. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +101 -0
  62. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +131 -0
  63. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +132 -0
  64. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +25 -0
  65. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +35 -0
  66. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +238 -0
  67. package/src/rules/no-unsafe-selectors/constants.tsx +99 -0
  68. package/src/rules/no-unsafe-selectors/index.tsx +201 -0
  69. package/src/rules/no-unsafe-selectors/lint-selector.tsx +168 -0
  70. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +55 -0
  71. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +232 -0
@@ -0,0 +1,173 @@
1
+ import cssSelectorParser from 'postcss-selector-parser';
2
+ import { importSources } from '@atlaskit/eslint-utils/schema';
3
+ import { walkStyleProperties } from '@atlaskit/eslint-utils/walk-style-properties';
4
+ import { createLintRuleWithTypedConfig } from '../utils/create-rule-with-typed-config';
5
+ import { ignoredAtRules } from './constants';
6
+ import { lintSelector } from './lint-selector';
7
+ import { walkCssMap } from './walk-css-map';
8
+ const cssSelectorProcessor = cssSelectorParser();
9
+ const rule = createLintRuleWithTypedConfig({
10
+ meta: {
11
+ name: 'no-unsafe-selectors',
12
+ docs: {
13
+ description: 'Disallows use of nested styles in `css` functions.',
14
+ recommended: true,
15
+ severity: 'warn'
16
+ },
17
+ fixable: 'code',
18
+ hasSuggestions: true,
19
+ messages: {
20
+ /**
21
+ * Selector messages
22
+ */
23
+ 'no-ambiguous-pseudos': 'Pseudo-classes and pseudo-elements without a leading selector are ambiguous. Use a more explicit selector.',
24
+ 'no-increased-specificity': 'Do not chain the nesting selector.',
25
+ 'no-restricted-pseudos': 'The {{pseudo}} pseudo is not allowed.',
26
+ 'no-legacy-pseudo-element-syntax': 'Use a double colon for pseudo-elements. The single colon syntax is not supported for all pseudo-elements.',
27
+ 'no-unparsable-selectors': "The selector '{{selectorText}}' could not be parsed and is likely an authoring mistake. If you think this is an error reach out in #help-ui-styling-standard.",
28
+ 'no-selectors-object': 'Do not use the selectors object. Both nested and advanced selectors should be avoided.',
29
+ /**
30
+ * At-rule messages
31
+ */
32
+ 'no-keyframes-at-rules': 'Use the CSS-in-JS `keyframes` API instead of `@keyframes` at-rules.',
33
+ 'no-restricted-at-rules': '{{atRule}} at-rule is not allowed.',
34
+ 'no-grouped-at-rules': 'Do not group at-rules. Write flattened at-rules instead.',
35
+ /**
36
+ * Suggestion messages
37
+ */
38
+ 'insert-nesting-selector': 'Insert a nesting selector `&` to target the element itself. This is usually the intended behavior.'
39
+ },
40
+ schema: {
41
+ type: 'object',
42
+ properties: {
43
+ importSources,
44
+ shouldAlwaysInsertNestingSelectorForAmbiguousPseudos: {
45
+ type: 'boolean',
46
+ default: true
47
+ }
48
+ },
49
+ additionalProperties: false
50
+ }
51
+ },
52
+ create(context, config) {
53
+ return {
54
+ Program(program) {
55
+ walkCssMap({
56
+ context,
57
+ program,
58
+ importSources: config.importSources,
59
+ visitor(property) {
60
+ const {
61
+ type,
62
+ node
63
+ } = property;
64
+ if (type === 'grouped-at-rules') {
65
+ context.report({
66
+ node: node.key,
67
+ messageId: 'no-grouped-at-rules'
68
+ });
69
+ return;
70
+ }
71
+ if (type === 'selectors') {
72
+ context.report({
73
+ node: node.key,
74
+ messageId: 'no-selectors-object'
75
+ });
76
+ return;
77
+ }
78
+ }
79
+ });
80
+ },
81
+ CallExpression(node) {
82
+ const {
83
+ references
84
+ } = context.getScope();
85
+ walkStyleProperties(node, references, config.importSources, ({
86
+ key,
87
+ value
88
+ }) => {
89
+ /**
90
+ * If the value isn't an object expression then the key can't be a selector.
91
+ *
92
+ * This assumes all styles have to be inline, which is enforced by `no-unsafe-values`
93
+ */
94
+ if (value.type !== 'ObjectExpression') {
95
+ return;
96
+ }
97
+
98
+ /**
99
+ * Technically the key could be an identifier too, e.g.
100
+ *
101
+ * ```ts
102
+ * css({
103
+ * // This key is an identifier, not a literal
104
+ * selector: {}
105
+ * });
106
+ * ```
107
+ *
108
+ * But an identifier couldn't violate anything in this rule,
109
+ * because it can't contain '@' or ':' characters.
110
+ */
111
+ if (key.type !== 'Literal' || typeof key.value !== 'string') {
112
+ return;
113
+ }
114
+ const selectorText = key.value;
115
+ if (selectorText.includes('@')) {
116
+ lintAtRule({
117
+ context,
118
+ sourceNode: key,
119
+ atRule: selectorText
120
+ });
121
+ return;
122
+ }
123
+ try {
124
+ const selectorList = cssSelectorProcessor.astSync(selectorText);
125
+ selectorList.nodes.forEach(selector => lintSelector({
126
+ context,
127
+ sourceNode: key,
128
+ selector,
129
+ config
130
+ }));
131
+ } catch (e) {
132
+ context.report({
133
+ node: key,
134
+ messageId: 'no-unparsable-selectors',
135
+ data: {
136
+ selectorText
137
+ }
138
+ });
139
+ }
140
+ });
141
+ }
142
+ };
143
+ }
144
+ });
145
+ export default rule;
146
+ function lintAtRule({
147
+ context,
148
+ sourceNode,
149
+ atRule
150
+ }) {
151
+ const matches = atRule.trim().match(/^@[A-z-]+/);
152
+ if (!matches) {
153
+ return;
154
+ }
155
+ const ruleName = matches[0];
156
+ if (ignoredAtRules.has(ruleName)) {
157
+ return;
158
+ }
159
+ if (ruleName === '@keyframes') {
160
+ context.report({
161
+ node: sourceNode,
162
+ messageId: 'no-keyframes-at-rules'
163
+ });
164
+ } else {
165
+ context.report({
166
+ node: sourceNode,
167
+ messageId: 'no-restricted-at-rules',
168
+ data: {
169
+ atRule: ruleName
170
+ }
171
+ });
172
+ }
173
+ }
@@ -0,0 +1,152 @@
1
+ import { allowedPseudos, legacyPseudoElements } from './constants';
2
+ import { isNesting } from 'postcss-selector-parser';
3
+ import { getRangeFromNode, getSourceLocationFromRange } from './source-position-utils';
4
+ export function lintSelector(args) {
5
+ checkNoAmbiguousPseudos(args);
6
+ checkNoRestrictedPseudos(args);
7
+ checkNoLegacyPseudoElementSyntax(args);
8
+ checkNoIncreasedSpecificity(args);
9
+ }
10
+
11
+ /**
12
+ * Ensures the use of a nesting selector `&` with pseudo-selectors.
13
+ */
14
+ function checkNoAmbiguousPseudos({
15
+ context,
16
+ sourceNode,
17
+ selector,
18
+ config
19
+ }) {
20
+ if (selector.first.type !== 'pseudo') {
21
+ return;
22
+ }
23
+ const range = getRangeFromNode({
24
+ node: selector.first,
25
+ sourceNode
26
+ });
27
+ const loc = getSourceLocationFromRange(context, range);
28
+ if (config.shouldAlwaysInsertNestingSelectorForAmbiguousPseudos) {
29
+ context.report({
30
+ loc,
31
+ messageId: 'no-ambiguous-pseudos',
32
+ *fix(fixer) {
33
+ yield fixer.insertTextBeforeRange(range, '&');
34
+ }
35
+ });
36
+ } else {
37
+ context.report({
38
+ loc,
39
+ messageId: 'no-ambiguous-pseudos',
40
+ suggest: [{
41
+ messageId: 'insert-nesting-selector',
42
+ *fix(fixer) {
43
+ yield fixer.insertTextBeforeRange(range, '&');
44
+ }
45
+ }]
46
+ });
47
+ }
48
+ }
49
+ function checkNoRestrictedPseudos({
50
+ context,
51
+ sourceNode,
52
+ selector
53
+ }) {
54
+ selector.walkPseudos(pseudo => {
55
+ if (allowedPseudos.has(pseudo.value)) {
56
+ return;
57
+ }
58
+
59
+ /**
60
+ * If someone has written `:after` it is allowed,
61
+ * they've just used the legacy syntax.
62
+ *
63
+ * This will be caught by the `no-legacy-pseudo-element-syntax` check.
64
+ */
65
+ if (legacyPseudoElements.has(pseudo.value) && allowedPseudos.has(`:${pseudo.value}`)) {
66
+ return;
67
+ }
68
+ if (!allowedPseudos.has(pseudo.value)) {
69
+ const range = getRangeFromNode({
70
+ node: pseudo,
71
+ sourceNode
72
+ });
73
+ const loc = getSourceLocationFromRange(context, range);
74
+ context.report({
75
+ loc,
76
+ messageId: 'no-restricted-pseudos',
77
+ data: {
78
+ pseudo: pseudo.value
79
+ }
80
+ });
81
+ }
82
+ });
83
+ }
84
+
85
+ /**
86
+ * The original four pseudo-elements have a legacy single colon syntax.
87
+ *
88
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
89
+ */
90
+ function checkNoLegacyPseudoElementSyntax({
91
+ context,
92
+ sourceNode,
93
+ selector
94
+ }) {
95
+ selector.walkPseudos(pseudo => {
96
+ if (legacyPseudoElements.has(pseudo.value)) {
97
+ const range = getRangeFromNode({
98
+ node: pseudo,
99
+ sourceNode
100
+ });
101
+ const loc = getSourceLocationFromRange(context, range);
102
+ context.report({
103
+ loc,
104
+ messageId: 'no-legacy-pseudo-element-syntax',
105
+ *fix(fixer) {
106
+ yield fixer.insertTextBeforeRange(range, ':');
107
+ }
108
+ });
109
+ }
110
+ });
111
+ }
112
+ function checkNoIncreasedSpecificity({
113
+ context,
114
+ sourceNode,
115
+ selector
116
+ }) {
117
+ selector.walkNesting(nesting => {
118
+ /**
119
+ * If it's not the start of a chain, then it's already been reported.
120
+ */
121
+ if (isNesting(nesting.prev())) {
122
+ return;
123
+ }
124
+ let next = nesting.next();
125
+
126
+ /**
127
+ * If it is followed by something other than another nesting selector,
128
+ * then it isn't just there to increase specificity — it is actually necessary.
129
+ */
130
+ if (next && !isNesting(next)) {
131
+ return;
132
+ }
133
+ let lastNesting = nesting;
134
+ while (isNesting(next)) {
135
+ lastNesting = next;
136
+ next = next.next();
137
+ }
138
+ const [start] = getRangeFromNode({
139
+ node: nesting,
140
+ sourceNode
141
+ });
142
+ const [_, end] = getRangeFromNode({
143
+ node: lastNesting,
144
+ sourceNode
145
+ });
146
+ const loc = getSourceLocationFromRange(context, [start, end]);
147
+ context.report({
148
+ loc,
149
+ messageId: 'no-increased-specificity'
150
+ });
151
+ });
152
+ }
@@ -0,0 +1,31 @@
1
+ export function getRangeFromNode({
2
+ node,
3
+ sourceNode
4
+ }) {
5
+ /**
6
+ * The adjustment required to align the selector AST source position
7
+ * with the ESTree source position.
8
+ */
9
+ const adjustment =
10
+ /**
11
+ * Using a non-null `!` is safe here because ESLint requires the parser to
12
+ * include a range value on nodes.
13
+ *
14
+ * https://eslint.org/docs/latest/extend/custom-parsers#all-nodes
15
+ */
16
+ sourceNode.range[0] + (
17
+ /**
18
+ * We add +1 if it's a literal to account for the opening `'` or `"` character.
19
+ */
20
+ sourceNode.type === 'Literal' ? 1 : 0);
21
+ const start = adjustment + node.sourceIndex;
22
+ const end = start + node.value.length;
23
+ return [start, end];
24
+ }
25
+ export function getSourceLocationFromRange(context, [start, end]) {
26
+ const sourceCode = context.getSourceCode();
27
+ return {
28
+ start: sourceCode.getLocFromIndex(start),
29
+ end: sourceCode.getLocFromIndex(end)
30
+ };
31
+ }
@@ -0,0 +1,180 @@
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
+
7
+ export function walkCssMap({
8
+ context,
9
+ importSources,
10
+ visitor
11
+ }) {
12
+ const program = context.getSourceCode().ast;
13
+ const importDeclaration = program.body.find(node => node.type === 'ImportDeclaration' && importSources.includes(node.source.value));
14
+ const specifier = importDeclaration === null || importDeclaration === void 0 ? void 0 : importDeclaration.specifiers.find(specifier => specifier.type === 'ImportSpecifier' && specifier.imported.name === 'cssMap');
15
+ if (!specifier) {
16
+ return;
17
+ }
18
+ const [variable] = context.getSourceCode().scopeManager.getDeclaredVariables(specifier);
19
+ if (!variable) {
20
+ return;
21
+ }
22
+ variable.references.forEach(reference => {
23
+ const identifier = reference.identifier;
24
+ const {
25
+ parent
26
+ } = identifier;
27
+ if (parent.type !== 'CallExpression') {
28
+ return;
29
+ }
30
+ const variantMap = parent.arguments[0];
31
+ if (variantMap.type !== 'ObjectExpression') {
32
+ return;
33
+ }
34
+ walkCssMapVariantMap({
35
+ variantMap,
36
+ visitor
37
+ });
38
+ });
39
+ }
40
+ function walkCssMapVariantMap({
41
+ variantMap,
42
+ visitor
43
+ }) {
44
+ variantMap.properties.forEach(property => {
45
+ if (property.type !== 'Property') {
46
+ return;
47
+ }
48
+ walkCssMapVariant({
49
+ variant: property,
50
+ visitor
51
+ });
52
+ });
53
+ }
54
+ function walkCssMapVariant({
55
+ variant,
56
+ visitor
57
+ }) {
58
+ visitor({
59
+ type: 'variant',
60
+ node: variant
61
+ });
62
+ if (variant.value.type !== 'ObjectExpression') {
63
+ return;
64
+ }
65
+ variant.value.properties.forEach(property => {
66
+ if (property.type !== 'Property') {
67
+ return;
68
+ }
69
+ if (property.value.type !== 'ObjectExpression') {
70
+ visitor({
71
+ type: 'declaration',
72
+ node: property
73
+ });
74
+ return;
75
+ }
76
+ const keyValue = getKeyValue(property.key);
77
+ if (keyValue && /^@[A-z-]+$/.test(keyValue)) {
78
+ walkCssMapAtRuleGrouping({
79
+ atRuleGrouping: property,
80
+ visitor
81
+ });
82
+ return;
83
+ }
84
+ if (keyValue === 'selectors') {
85
+ walkCssMapSelectors({
86
+ selectors: property,
87
+ visitor
88
+ });
89
+ }
90
+ walkStyleRuleset({
91
+ ruleset: property,
92
+ visitor
93
+ });
94
+ });
95
+ }
96
+ function walkCssMapAtRuleGrouping({
97
+ atRuleGrouping,
98
+ visitor
99
+ }) {
100
+ const atRule = getKeyValue(atRuleGrouping.key);
101
+ if (!atRule) {
102
+ return;
103
+ }
104
+ visitor({
105
+ type: 'grouped-at-rules',
106
+ node: atRuleGrouping,
107
+ atRule
108
+ });
109
+ if (atRuleGrouping.value.type !== 'ObjectExpression') {
110
+ return;
111
+ }
112
+ atRuleGrouping.value.properties.forEach(property => {
113
+ if (property.type !== 'Property') {
114
+ return;
115
+ }
116
+ walkStyleRuleset({
117
+ ruleset: property,
118
+ visitor
119
+ });
120
+ });
121
+ }
122
+ function walkCssMapSelectors({
123
+ selectors,
124
+ visitor
125
+ }) {
126
+ visitor({
127
+ type: 'selectors',
128
+ node: selectors
129
+ });
130
+ if (selectors.value.type !== 'ObjectExpression') {
131
+ return;
132
+ }
133
+ selectors.value.properties.forEach(property => {
134
+ if (property.type !== 'Property') {
135
+ return;
136
+ }
137
+ walkStyleRuleset({
138
+ ruleset: property,
139
+ visitor
140
+ });
141
+ });
142
+ }
143
+ function walkStyleRuleset({
144
+ ruleset,
145
+ visitor
146
+ }) {
147
+ visitor({
148
+ type: 'ruleset',
149
+ node: ruleset
150
+ });
151
+ if (ruleset.value.type !== 'ObjectExpression') {
152
+ return;
153
+ }
154
+ ruleset.value.properties.forEach(property => {
155
+ if (property.type !== 'Property') {
156
+ return;
157
+ }
158
+ if (property.value.type === 'ObjectExpression') {
159
+ walkStyleRuleset({
160
+ ruleset: property,
161
+ visitor
162
+ });
163
+ return;
164
+ }
165
+ visitor({
166
+ type: 'declaration',
167
+ node: property
168
+ });
169
+ });
170
+ }
171
+ function getKeyValue(key) {
172
+ if (key.type === 'Identifier') {
173
+ return key.name;
174
+ }
175
+ if (key.type === 'Literal') {
176
+ var _key$value$toString, _key$value;
177
+ 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;
178
+ }
179
+ return null;
180
+ }
@@ -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::a4ab25dd4ce24b183125bfbc709e3943>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
@@ -20,6 +20,7 @@ export default {
20
20
  '@atlaskit/ui-styling-standard/no-imported-style-values': 'warn',
21
21
  '@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
22
22
  '@atlaskit/ui-styling-standard/no-styled': 'warn',
23
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'warn',
23
24
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'warn',
24
25
  '@atlaskit/ui-styling-standard/use-compiled': 'warn',
25
26
  '@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
@@ -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::a4ab25dd4ce24b183125bfbc709e3943>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
@@ -20,6 +20,7 @@ export default {
20
20
  '@atlaskit/ui-styling-standard/no-imported-style-values': 'warn',
21
21
  '@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
22
22
  '@atlaskit/ui-styling-standard/no-styled': 'warn',
23
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'warn',
23
24
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'warn',
24
25
  '@atlaskit/ui-styling-standard/use-compiled': 'warn',
25
26
  '@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
@@ -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::c907cf4b4e11348239dadaefebe80fca>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  import atlaskitTheme from './atlaskit-theme';
@@ -17,6 +17,7 @@ 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
  export default {
@@ -34,6 +35,7 @@ export default {
34
35
  'no-imported-style-values': noImportedStyleValues,
35
36
  'no-nested-selectors': noNestedSelectors,
36
37
  'no-styled': noStyled,
38
+ 'no-unsafe-selectors': noUnsafeSelectors,
37
39
  'no-unsafe-values': noUnsafeValues,
38
40
  'use-compiled': useCompiled
39
41
  };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Validation approach from
3
+ * https://stackoverflow.com/a/71236280
4
+ */
5
+
6
+ /**
7
+ * Exporting this so it isn't considered unused.
8
+ */
9
+
10
+ var cssPseudos = ['&: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'];
11
+ export var allowedPseudos = new Set(
12
+ /**
13
+ * The `&` is included above for type checking reasons,
14
+ * but we don't actually want it when consuming the values.
15
+ */
16
+ cssPseudos.map(function (pseudo) {
17
+ return pseudo.slice(1);
18
+ }));
19
+ export var legacyPseudoElements = new Set([':after', ':before', ':first-letter', ':first-line']);
20
+ export var ignoredAtRules = new Set(['@container',
21
+ // ignored because it's covered by `no-container-queries`
22
+ '@media',
23
+ // ignored because it's covered by `no-nested-styles`
24
+ '@supports', '@property']);