@atlaskit/eslint-plugin-ui-styling-standard 2.4.0 → 3.0.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 (45) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +0 -1
  3. package/dist/cjs/presets/all-flat.codegen.js +1 -2
  4. package/dist/cjs/presets/all.codegen.js +1 -2
  5. package/dist/cjs/rules/index.codegen.js +1 -3
  6. package/dist/cjs/rules/no-imported-style-values/index.js +8 -1
  7. package/dist/cjs/rules/no-nested-selectors/index.js +13 -1
  8. package/dist/cjs/rules/utils/walk-style-call-properties.js +24 -11
  9. package/dist/es2019/presets/all-flat.codegen.js +1 -2
  10. package/dist/es2019/presets/all.codegen.js +1 -2
  11. package/dist/es2019/rules/index.codegen.js +1 -3
  12. package/dist/es2019/rules/no-imported-style-values/index.js +8 -1
  13. package/dist/es2019/rules/no-nested-selectors/index.js +13 -1
  14. package/dist/es2019/rules/utils/walk-style-call-properties.js +15 -12
  15. package/dist/esm/presets/all-flat.codegen.js +1 -2
  16. package/dist/esm/presets/all.codegen.js +1 -2
  17. package/dist/esm/rules/index.codegen.js +1 -3
  18. package/dist/esm/rules/no-imported-style-values/index.js +8 -1
  19. package/dist/esm/rules/no-nested-selectors/index.js +13 -1
  20. package/dist/esm/rules/utils/walk-style-call-properties.js +24 -11
  21. package/dist/types/presets/all-flat.codegen.d.ts +1 -1
  22. package/dist/types/presets/all.codegen.d.ts +1 -1
  23. package/dist/types/rules/index.codegen.d.ts +1 -1
  24. package/dist/types/rules/utils/walk-style-call-properties.d.ts +0 -1
  25. package/package.json +1 -1
  26. package/dist/cjs/rules/no-top-layer-unsafe-selectors/find-template-selectors.js +0 -232
  27. package/dist/cjs/rules/no-top-layer-unsafe-selectors/index.js +0 -425
  28. package/dist/cjs/rules/no-top-layer-unsafe-selectors/preserve-list-layout.js +0 -63
  29. package/dist/cjs/rules/no-top-layer-unsafe-selectors/rewrite-selector.js +0 -2415
  30. package/dist/cjs/rules/utils/walk-style-object-properties.js +0 -47
  31. package/dist/es2019/rules/no-top-layer-unsafe-selectors/find-template-selectors.js +0 -226
  32. package/dist/es2019/rules/no-top-layer-unsafe-selectors/index.js +0 -382
  33. package/dist/es2019/rules/no-top-layer-unsafe-selectors/preserve-list-layout.js +0 -57
  34. package/dist/es2019/rules/no-top-layer-unsafe-selectors/rewrite-selector.js +0 -2131
  35. package/dist/es2019/rules/utils/walk-style-object-properties.js +0 -29
  36. package/dist/esm/rules/no-top-layer-unsafe-selectors/find-template-selectors.js +0 -226
  37. package/dist/esm/rules/no-top-layer-unsafe-selectors/index.js +0 -419
  38. package/dist/esm/rules/no-top-layer-unsafe-selectors/preserve-list-layout.js +0 -57
  39. package/dist/esm/rules/no-top-layer-unsafe-selectors/rewrite-selector.js +0 -2409
  40. package/dist/esm/rules/utils/walk-style-object-properties.js +0 -41
  41. package/dist/types/rules/no-top-layer-unsafe-selectors/find-template-selectors.d.ts +0 -29
  42. package/dist/types/rules/no-top-layer-unsafe-selectors/index.d.ts +0 -3
  43. package/dist/types/rules/no-top-layer-unsafe-selectors/preserve-list-layout.d.ts +0 -12
  44. package/dist/types/rules/no-top-layer-unsafe-selectors/rewrite-selector.d.ts +0 -164
  45. package/dist/types/rules/utils/walk-style-object-properties.d.ts +0 -18
@@ -1,57 +0,0 @@
1
- import selectorParser from 'postcss-selector-parser';
2
-
3
- /**
4
- * Split a selector list on its top-level commas only, keeping the whitespace and comments
5
- * around each branch exactly as written. Commas inside `(…)`, `[…]`, quotes, comments and
6
- * escapes belong to their branch, because the parser already knows which commas separate
7
- * branches and which do not.
8
- *
9
- * Returns `null` when the text does not parse, or when the branches do not join back into the
10
- * original text, so the caller falls back to the transform's own text rather than re-assembling
11
- * a list it cannot fully account for.
12
- */
13
- function splitTopLevel({
14
- text
15
- }) {
16
- try {
17
- const root = selectorParser().astSync(text);
18
- const parts = root.nodes.map(branch => branch.toString());
19
- if (parts.join(',') !== text) {
20
- return null;
21
- }
22
- return parts;
23
- } catch {
24
- return null;
25
- }
26
- }
27
-
28
- /**
29
- * Re-apply the author's layout of a selector list to the rewritten one.
30
- *
31
- * The transform joins its branches with `, `. A selector list written over several lines would
32
- * be collapsed onto one by the fixer, so each rewritten branch is put back between the
33
- * separators the author wrote. Falls back to the transform's text when either list does not
34
- * split cleanly, or when the two do not have the same number of branches.
35
- */
36
- export function preserveListLayout({
37
- original,
38
- rewritten
39
- }) {
40
- const originalParts = splitTopLevel({
41
- text: original
42
- });
43
- const rewrittenParts = splitTopLevel({
44
- text: rewritten
45
- });
46
- if (originalParts === null || rewrittenParts === null) {
47
- return rewritten;
48
- }
49
- if (originalParts.length < 2 || originalParts.length !== rewrittenParts.length) {
50
- return rewritten;
51
- }
52
- return originalParts.map((part, index) => {
53
- const leading = part.length - part.trimStart().length;
54
- const trailing = part.length - part.trimEnd().length;
55
- return `${part.slice(0, leading)}${rewrittenParts[index].trim()}${part.slice(part.length - trailing)}`;
56
- }).join(',');
57
- }