@atlaskit/eslint-plugin-ui-styling-standard 2.4.1 → 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 (39) hide show
  1. package/CHANGELOG.md +10 -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/utils/walk-style-call-properties.js +24 -11
  7. package/dist/es2019/presets/all-flat.codegen.js +1 -2
  8. package/dist/es2019/presets/all.codegen.js +1 -2
  9. package/dist/es2019/rules/index.codegen.js +1 -3
  10. package/dist/es2019/rules/utils/walk-style-call-properties.js +15 -12
  11. package/dist/esm/presets/all-flat.codegen.js +1 -2
  12. package/dist/esm/presets/all.codegen.js +1 -2
  13. package/dist/esm/rules/index.codegen.js +1 -3
  14. package/dist/esm/rules/utils/walk-style-call-properties.js +24 -11
  15. package/dist/types/presets/all-flat.codegen.d.ts +1 -1
  16. package/dist/types/presets/all.codegen.d.ts +1 -1
  17. package/dist/types/rules/index.codegen.d.ts +1 -1
  18. package/dist/types/rules/utils/walk-style-call-properties.d.ts +0 -1
  19. package/package.json +1 -1
  20. package/dist/cjs/rules/no-top-layer-unsafe-selectors/find-template-selectors.js +0 -232
  21. package/dist/cjs/rules/no-top-layer-unsafe-selectors/index.js +0 -425
  22. package/dist/cjs/rules/no-top-layer-unsafe-selectors/preserve-list-layout.js +0 -63
  23. package/dist/cjs/rules/no-top-layer-unsafe-selectors/rewrite-selector.js +0 -2415
  24. package/dist/cjs/rules/utils/walk-style-object-properties.js +0 -47
  25. package/dist/es2019/rules/no-top-layer-unsafe-selectors/find-template-selectors.js +0 -226
  26. package/dist/es2019/rules/no-top-layer-unsafe-selectors/index.js +0 -382
  27. package/dist/es2019/rules/no-top-layer-unsafe-selectors/preserve-list-layout.js +0 -57
  28. package/dist/es2019/rules/no-top-layer-unsafe-selectors/rewrite-selector.js +0 -2131
  29. package/dist/es2019/rules/utils/walk-style-object-properties.js +0 -29
  30. package/dist/esm/rules/no-top-layer-unsafe-selectors/find-template-selectors.js +0 -226
  31. package/dist/esm/rules/no-top-layer-unsafe-selectors/index.js +0 -419
  32. package/dist/esm/rules/no-top-layer-unsafe-selectors/preserve-list-layout.js +0 -57
  33. package/dist/esm/rules/no-top-layer-unsafe-selectors/rewrite-selector.js +0 -2409
  34. package/dist/esm/rules/utils/walk-style-object-properties.js +0 -41
  35. package/dist/types/rules/no-top-layer-unsafe-selectors/find-template-selectors.d.ts +0 -29
  36. package/dist/types/rules/no-top-layer-unsafe-selectors/index.d.ts +0 -3
  37. package/dist/types/rules/no-top-layer-unsafe-selectors/preserve-list-layout.d.ts +0 -12
  38. package/dist/types/rules/no-top-layer-unsafe-selectors/rewrite-selector.d.ts +0 -164
  39. package/dist/types/rules/utils/walk-style-object-properties.d.ts +0 -18
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/eslint-plugin-ui-styling-standard
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`947cd9330812c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/947cd9330812c) -
8
+ Remove the `no-top-layer-unsafe-selectors` rule from the plugin. It was in the `all` and
9
+ `all-flat` presets only, not in `recommended`. ESLint reports an unknown rule for any config entry
10
+ or `eslint-disable` comment that names
11
+ `@atlaskit/ui-styling-standard/no-top-layer-unsafe-selectors`, so delete those references.
12
+
3
13
  ## 2.4.1
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -57,7 +57,6 @@ module.exports = {
57
57
  | <a href="./src/rules/no-imported-style-values/README.md">no-imported-style-values</a> | Disallows imports of style values | Yes | | |
58
58
  | <a href="./src/rules/no-nested-selectors/README.md">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
59
59
  | <a href="./src/rules/no-styled/README.md">no-styled</a> | Disallows usage of the `styled` imports | Yes | | |
60
- | <a href="./src/rules/no-top-layer-unsafe-selectors/README.md">no-top-layer-unsafe-selectors</a> | Disallows selectors that a Design System layering surface rendered in the browser top layer can wrongly match, or wrongly displace. | | Yes | |
61
60
  | <a href="./src/rules/no-unsafe-selectors/README.md">no-unsafe-selectors</a> | Disallows use of nested styles in `css` functions. | Yes | Yes | Yes |
62
61
  | <a href="./src/rules/no-unsafe-values/README.md">no-unsafe-values</a> | Disallows styles that are difficult/impossible to statically anaylze. | Yes | | |
63
62
  | <a href="./src/rules/no-unused-cssmap-properties/README.md">no-unused-cssmap-properties</a> | Detects unused properties in cssMap style objects that are not exported. Helps maintain clean code by identifying style variants that are defined but never used. | Yes | | |
@@ -9,7 +9,7 @@ var atlaskitDesignSystemPlugin = _interopRequireWildcard(require("@atlaskit/esli
9
9
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
10
10
  /**
11
11
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
12
- * @codegen <<SignedSource::75b18fe1e3e0e0eeeb87a8dd4ed975ae>>
12
+ * @codegen <<SignedSource::4d0de15d2213df65666693ea490b4cce>>
13
13
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
14
14
  */
15
15
 
@@ -34,7 +34,6 @@ var config = {
34
34
  '@atlaskit/ui-styling-standard/no-imported-style-values': 'error',
35
35
  '@atlaskit/ui-styling-standard/no-nested-selectors': 'error',
36
36
  '@atlaskit/ui-styling-standard/no-styled': 'error',
37
- '@atlaskit/ui-styling-standard/no-top-layer-unsafe-selectors': 'error',
38
37
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
39
38
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
40
39
  '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::ff2cac75bedd9b12fc1c17bc6cf66c5c>>
9
+ * @codegen <<SignedSource::56ecb290562bdf88a8a5b5388a39e5f9>>
10
10
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
11
11
  */
12
12
 
@@ -28,7 +28,6 @@ var config = {
28
28
  '@atlaskit/ui-styling-standard/no-imported-style-values': 'error',
29
29
  '@atlaskit/ui-styling-standard/no-nested-selectors': 'error',
30
30
  '@atlaskit/ui-styling-standard/no-styled': 'error',
31
- '@atlaskit/ui-styling-standard/no-top-layer-unsafe-selectors': 'error',
32
31
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
33
32
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
34
33
  '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
@@ -20,14 +20,13 @@ var _noImportantStyles = _interopRequireDefault(require("./no-important-styles")
20
20
  var _noImportedStyleValues = _interopRequireDefault(require("./no-imported-style-values"));
21
21
  var _noNestedSelectors = _interopRequireDefault(require("./no-nested-selectors"));
22
22
  var _noStyled = _interopRequireDefault(require("./no-styled"));
23
- var _noTopLayerUnsafeSelectors = _interopRequireDefault(require("./no-top-layer-unsafe-selectors"));
24
23
  var _noUnsafeSelectors = _interopRequireDefault(require("./no-unsafe-selectors"));
25
24
  var _noUnsafeValues = _interopRequireDefault(require("./no-unsafe-values"));
26
25
  var _noUnusedCssmapProperties = _interopRequireDefault(require("./no-unused-cssmap-properties"));
27
26
  var _useCompiled = _interopRequireDefault(require("./use-compiled"));
28
27
  /**
29
28
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
30
- * @codegen <<SignedSource::7b2b0662d0eeb0e3a3e4c844a505d27e>>
29
+ * @codegen <<SignedSource::094f8a058153c7e839c5d98d2718ca4e>>
31
30
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
32
31
  */
33
32
 
@@ -47,7 +46,6 @@ var rules = exports.rules = {
47
46
  'no-imported-style-values': _noImportedStyleValues.default,
48
47
  'no-nested-selectors': _noNestedSelectors.default,
49
48
  'no-styled': _noStyled.default,
50
- 'no-top-layer-unsafe-selectors': _noTopLayerUnsafeSelectors.default,
51
49
  'no-unsafe-selectors': _noUnsafeSelectors.default,
52
50
  'no-unsafe-values': _noUnsafeValues.default,
53
51
  'no-unused-cssmap-properties': _noUnusedCssmapProperties.default,
@@ -4,29 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.walkStyleCallProperties = walkStyleCallProperties;
7
- var _walkStyleObjectProperties = require("./walk-style-object-properties");
8
7
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
9
8
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
9
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
10
  function walkStyleCallProperties(styleCall, visitor, options) {
12
11
  var skipTopLevel = !(options !== null && options !== void 0 && options.includeTopLevel) && (styleCall.styleFunction === 'cssMap' || styleCall.styleFunction === 'keyframes');
13
- var _ref = options !== null && options !== void 0 ? options : {},
14
- skipSubtree = _ref.skipSubtree;
15
12
  var _iterator = _createForOfIteratorHelper(styleCall.node.arguments),
16
13
  _step;
17
14
  try {
18
15
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
19
16
  var argument = _step.value;
20
17
  if (argument.type === 'ObjectExpression') {
21
- (0, _walkStyleObjectProperties.walkStyleObjectProperties)(argument, visitor, {
22
- skipTopLevel: skipTopLevel,
23
- skipSubtree: skipSubtree
24
- });
18
+ walkStyleObject(argument, visitor, skipTopLevel);
25
19
  } else if (argument.type === 'ArrowFunctionExpression' && argument.expression && argument.body.type === 'ObjectExpression') {
26
- (0, _walkStyleObjectProperties.walkStyleObjectProperties)(argument.body, visitor, {
27
- skipTopLevel: skipTopLevel,
28
- skipSubtree: skipSubtree
29
- });
20
+ walkStyleObject(argument.body, visitor, skipTopLevel);
30
21
  }
31
22
  }
32
23
  } catch (err) {
@@ -34,4 +25,26 @@ function walkStyleCallProperties(styleCall, visitor, options) {
34
25
  } finally {
35
26
  _iterator.f();
36
27
  }
28
+ }
29
+ function walkStyleObject(object, visitor, skipVisitor) {
30
+ var _iterator2 = _createForOfIteratorHelper(object.properties),
31
+ _step2;
32
+ try {
33
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
34
+ var property = _step2.value;
35
+ if (property.type !== 'Property') {
36
+ continue;
37
+ }
38
+ if (!skipVisitor) {
39
+ visitor(property);
40
+ }
41
+ if (property.value.type === 'ObjectExpression') {
42
+ walkStyleObject(property.value, visitor, false);
43
+ }
44
+ }
45
+ } catch (err) {
46
+ _iterator2.e(err);
47
+ } finally {
48
+ _iterator2.f();
49
+ }
37
50
  }
@@ -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::75b18fe1e3e0e0eeeb87a8dd4ed975ae>>
3
+ * @codegen <<SignedSource::4d0de15d2213df65666693ea490b4cce>>
4
4
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
 
@@ -26,7 +26,6 @@ const config = {
26
26
  '@atlaskit/ui-styling-standard/no-imported-style-values': 'error',
27
27
  '@atlaskit/ui-styling-standard/no-nested-selectors': 'error',
28
28
  '@atlaskit/ui-styling-standard/no-styled': 'error',
29
- '@atlaskit/ui-styling-standard/no-top-layer-unsafe-selectors': 'error',
30
29
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
31
30
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
32
31
  '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': '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::ff2cac75bedd9b12fc1c17bc6cf66c5c>>
3
+ * @codegen <<SignedSource::56ecb290562bdf88a8a5b5388a39e5f9>>
4
4
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
 
@@ -22,7 +22,6 @@ const config = {
22
22
  '@atlaskit/ui-styling-standard/no-imported-style-values': 'error',
23
23
  '@atlaskit/ui-styling-standard/no-nested-selectors': 'error',
24
24
  '@atlaskit/ui-styling-standard/no-styled': 'error',
25
- '@atlaskit/ui-styling-standard/no-top-layer-unsafe-selectors': 'error',
26
25
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
27
26
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
28
27
  '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': '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::7b2b0662d0eeb0e3a3e4c844a505d27e>>
3
+ * @codegen <<SignedSource::094f8a058153c7e839c5d98d2718ca4e>>
4
4
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
 
@@ -19,7 +19,6 @@ import noImportantStyles from './no-important-styles';
19
19
  import noImportedStyleValues from './no-imported-style-values';
20
20
  import noNestedSelectors from './no-nested-selectors';
21
21
  import noStyled from './no-styled';
22
- import noTopLayerUnsafeSelectors from './no-top-layer-unsafe-selectors';
23
22
  import noUnsafeSelectors from './no-unsafe-selectors';
24
23
  import noUnsafeValues from './no-unsafe-values';
25
24
  import noUnusedCssmapProperties from './no-unused-cssmap-properties';
@@ -40,7 +39,6 @@ export const rules = {
40
39
  'no-imported-style-values': noImportedStyleValues,
41
40
  'no-nested-selectors': noNestedSelectors,
42
41
  'no-styled': noStyled,
43
- 'no-top-layer-unsafe-selectors': noTopLayerUnsafeSelectors,
44
42
  'no-unsafe-selectors': noUnsafeSelectors,
45
43
  'no-unsafe-values': noUnsafeValues,
46
44
  'no-unused-cssmap-properties': noUnusedCssmapProperties,
@@ -1,20 +1,23 @@
1
- import { walkStyleObjectProperties } from './walk-style-object-properties';
2
1
  export function walkStyleCallProperties(styleCall, visitor, options) {
3
2
  const skipTopLevel = !(options !== null && options !== void 0 && options.includeTopLevel) && (styleCall.styleFunction === 'cssMap' || styleCall.styleFunction === 'keyframes');
4
- const {
5
- skipSubtree
6
- } = options !== null && options !== void 0 ? options : {};
7
3
  for (const argument of styleCall.node.arguments) {
8
4
  if (argument.type === 'ObjectExpression') {
9
- walkStyleObjectProperties(argument, visitor, {
10
- skipTopLevel,
11
- skipSubtree
12
- });
5
+ walkStyleObject(argument, visitor, skipTopLevel);
13
6
  } else if (argument.type === 'ArrowFunctionExpression' && argument.expression && argument.body.type === 'ObjectExpression') {
14
- walkStyleObjectProperties(argument.body, visitor, {
15
- skipTopLevel,
16
- skipSubtree
17
- });
7
+ walkStyleObject(argument.body, visitor, skipTopLevel);
8
+ }
9
+ }
10
+ }
11
+ function walkStyleObject(object, visitor, skipVisitor) {
12
+ for (const property of object.properties) {
13
+ if (property.type !== 'Property') {
14
+ continue;
15
+ }
16
+ if (!skipVisitor) {
17
+ visitor(property);
18
+ }
19
+ if (property.value.type === 'ObjectExpression') {
20
+ walkStyleObject(property.value, visitor, false);
18
21
  }
19
22
  }
20
23
  }
@@ -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::75b18fe1e3e0e0eeeb87a8dd4ed975ae>>
3
+ * @codegen <<SignedSource::4d0de15d2213df65666693ea490b4cce>>
4
4
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
 
@@ -26,7 +26,6 @@ var config = {
26
26
  '@atlaskit/ui-styling-standard/no-imported-style-values': 'error',
27
27
  '@atlaskit/ui-styling-standard/no-nested-selectors': 'error',
28
28
  '@atlaskit/ui-styling-standard/no-styled': 'error',
29
- '@atlaskit/ui-styling-standard/no-top-layer-unsafe-selectors': 'error',
30
29
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
31
30
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
32
31
  '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': '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::ff2cac75bedd9b12fc1c17bc6cf66c5c>>
3
+ * @codegen <<SignedSource::56ecb290562bdf88a8a5b5388a39e5f9>>
4
4
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
 
@@ -22,7 +22,6 @@ var config = {
22
22
  '@atlaskit/ui-styling-standard/no-imported-style-values': 'error',
23
23
  '@atlaskit/ui-styling-standard/no-nested-selectors': 'error',
24
24
  '@atlaskit/ui-styling-standard/no-styled': 'error',
25
- '@atlaskit/ui-styling-standard/no-top-layer-unsafe-selectors': 'error',
26
25
  '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
27
26
  '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
28
27
  '@atlaskit/ui-styling-standard/no-unused-cssmap-properties': '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::7b2b0662d0eeb0e3a3e4c844a505d27e>>
3
+ * @codegen <<SignedSource::094f8a058153c7e839c5d98d2718ca4e>>
4
4
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
 
@@ -19,7 +19,6 @@ import noImportantStyles from './no-important-styles';
19
19
  import noImportedStyleValues from './no-imported-style-values';
20
20
  import noNestedSelectors from './no-nested-selectors';
21
21
  import noStyled from './no-styled';
22
- import noTopLayerUnsafeSelectors from './no-top-layer-unsafe-selectors';
23
22
  import noUnsafeSelectors from './no-unsafe-selectors';
24
23
  import noUnsafeValues from './no-unsafe-values';
25
24
  import noUnusedCssmapProperties from './no-unused-cssmap-properties';
@@ -40,7 +39,6 @@ export var rules = {
40
39
  'no-imported-style-values': noImportedStyleValues,
41
40
  'no-nested-selectors': noNestedSelectors,
42
41
  'no-styled': noStyled,
43
- 'no-top-layer-unsafe-selectors': noTopLayerUnsafeSelectors,
44
42
  'no-unsafe-selectors': noUnsafeSelectors,
45
43
  'no-unsafe-values': noUnsafeValues,
46
44
  'no-unused-cssmap-properties': noUnusedCssmapProperties,
@@ -1,26 +1,17 @@
1
1
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
2
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
3
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
- import { walkStyleObjectProperties } from './walk-style-object-properties';
5
4
  export function walkStyleCallProperties(styleCall, visitor, options) {
6
5
  var skipTopLevel = !(options !== null && options !== void 0 && options.includeTopLevel) && (styleCall.styleFunction === 'cssMap' || styleCall.styleFunction === 'keyframes');
7
- var _ref = options !== null && options !== void 0 ? options : {},
8
- skipSubtree = _ref.skipSubtree;
9
6
  var _iterator = _createForOfIteratorHelper(styleCall.node.arguments),
10
7
  _step;
11
8
  try {
12
9
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
13
10
  var argument = _step.value;
14
11
  if (argument.type === 'ObjectExpression') {
15
- walkStyleObjectProperties(argument, visitor, {
16
- skipTopLevel: skipTopLevel,
17
- skipSubtree: skipSubtree
18
- });
12
+ walkStyleObject(argument, visitor, skipTopLevel);
19
13
  } else if (argument.type === 'ArrowFunctionExpression' && argument.expression && argument.body.type === 'ObjectExpression') {
20
- walkStyleObjectProperties(argument.body, visitor, {
21
- skipTopLevel: skipTopLevel,
22
- skipSubtree: skipSubtree
23
- });
14
+ walkStyleObject(argument.body, visitor, skipTopLevel);
24
15
  }
25
16
  }
26
17
  } catch (err) {
@@ -28,4 +19,26 @@ export function walkStyleCallProperties(styleCall, visitor, options) {
28
19
  } finally {
29
20
  _iterator.f();
30
21
  }
22
+ }
23
+ function walkStyleObject(object, visitor, skipVisitor) {
24
+ var _iterator2 = _createForOfIteratorHelper(object.properties),
25
+ _step2;
26
+ try {
27
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
28
+ var property = _step2.value;
29
+ if (property.type !== 'Property') {
30
+ continue;
31
+ }
32
+ if (!skipVisitor) {
33
+ visitor(property);
34
+ }
35
+ if (property.value.type === 'ObjectExpression') {
36
+ walkStyleObject(property.value, visitor, false);
37
+ }
38
+ }
39
+ } catch (err) {
40
+ _iterator2.e(err);
41
+ } finally {
42
+ _iterator2.f();
43
+ }
31
44
  }
@@ -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::75b18fe1e3e0e0eeeb87a8dd4ed975ae>>
3
+ * @codegen <<SignedSource::4d0de15d2213df65666693ea490b4cce>>
4
4
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  import type { Linter } from 'eslint';
@@ -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::ff2cac75bedd9b12fc1c17bc6cf66c5c>>
3
+ * @codegen <<SignedSource::56ecb290562bdf88a8a5b5388a39e5f9>>
4
4
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  import type { ESLint } from 'eslint';
@@ -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::7b2b0662d0eeb0e3a3e4c844a505d27e>>
3
+ * @codegen <<SignedSource::094f8a058153c7e839c5d98d2718ca4e>>
4
4
  * @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  import type { Rule } from 'eslint';
@@ -2,5 +2,4 @@ import type * as ESTree from 'eslint-codemod-utils';
2
2
  import type { StyleCall } from './style-calls';
3
3
  export declare function walkStyleCallProperties(styleCall: StyleCall, visitor: (property: ESTree.Property) => void, options?: {
4
4
  includeTopLevel?: boolean;
5
- skipSubtree?: (property: ESTree.Property) => boolean;
6
5
  }): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
- "version": "2.4.1",
3
+ "version": "3.0.0",
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",
@@ -1,232 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.findTemplateSelectors = findTemplateSelectors;
7
- /**
8
- * Locate the selectors inside a tagged template literal's raw source text.
9
- *
10
- * The style-call index only sees call expressions, so `styled.div\`…\`` and `css\`…\`` are
11
- * invisible to it. This scanner fills that gap: it walks the text between the template's
12
- * backticks and returns the byte range of every selector, so ranges map 1:1 onto the file and
13
- * can be handed straight to an ESLint fixer.
14
- *
15
- * It deliberately does not try to be a CSS parser. A selector is the text between the last
16
- * `;`, `{` or `}` and the next `{`. Anything it mis-reads will either fail to parse as a
17
- * selector — in which case `rewriteSelector` skips it — or be reported for review. What it
18
- * must not do is mistake a `${…}` interpolation, a quoted string or a comment for CSS
19
- * structure, so it steps over all three.
20
- */
21
-
22
- function findTemplateSelectors(source, offset) {
23
- var found = [];
24
- var segmentStart = 0;
25
- /**
26
- * Set when a comment appears after the segment's first non-whitespace character. A selector
27
- * with a comment inside it — `& /* x *​/ > div` — cannot be replaced as one contiguous range
28
- * without eating the comment, so it is skipped rather than mangled. A comment *before* the
29
- * selector just moves `segmentStart` past it.
30
- */
31
- var commentInsideSegment = false;
32
- /**
33
- * How many `(` are open. Inside a function's parentheses `//` is data, not a comment:
34
- * `url(//cdn.example.com/a.png)` and an unquoted data URI both carry one.
35
- */
36
- var parenthesisDepth = 0;
37
- /**
38
- * How many CSS `{` are open. `${…}` braces and parentheses do not count.
39
- */
40
- var braceDepth = 0;
41
- /**
42
- * The brace depth at which a `@keyframes` block opened, or `null` outside one. Everything
43
- * nested inside is an offset (`from`, `50%`), not a selector — each parses as a tag selector,
44
- * so without this the guard is written onto a keyframe and the animation stops. Skipping the
45
- * at-rule's own prelude is not enough, because the block's contents open their own segments.
46
- */
47
- var keyframesDepth = null;
48
- var startSegment = function startSegment(at) {
49
- segmentStart = at;
50
- commentInsideSegment = false;
51
- };
52
-
53
- /**
54
- * Step over a comment spanning `[start, end)`. A comment before the segment's first
55
- * non-whitespace character just moves the segment past it; a comment inside the segment
56
- * marks it unfixable. Returns the index to resume scanning at.
57
- */
58
- var skipComment = function skipComment(start, end) {
59
- var isLeading = source.slice(segmentStart, start).trim() === '';
60
- if (isLeading) {
61
- segmentStart = end;
62
- } else {
63
- commentInsideSegment = true;
64
- }
65
- return end;
66
- };
67
- for (var index = 0; index < source.length; index++) {
68
- var character = source[index];
69
-
70
- /* Step over a quoted string — `content: "{"` must not open a block. */
71
- if (character === '"' || character === "'") {
72
- index = skipQuoted(source, index);
73
- continue;
74
- }
75
- if (character === '/' && source[index + 1] === '*') {
76
- var close = source.indexOf('*/', index + 2);
77
- var end = close === -1 ? source.length : close + 2;
78
- index = skipComment(index, end) - 1;
79
- continue;
80
- }
81
-
82
- /**
83
- * A `//` line comment. Emotion and styled-components strip these before the CSS is
84
- * parsed, so a selector written after one on the next line is real. Inside parentheses
85
- * the same two characters are part of a URL, so the depth check keeps them.
86
- */
87
- if (character === '/' && source[index + 1] === '/' && parenthesisDepth === 0) {
88
- var newline = source.indexOf('\n', index + 2);
89
- var _end = newline === -1 ? source.length : newline + 1;
90
- index = skipComment(index, _end) - 1;
91
- continue;
92
- }
93
- if (character === '(') {
94
- parenthesisDepth++;
95
- continue;
96
- }
97
- if (character === ')') {
98
- parenthesisDepth = Math.max(0, parenthesisDepth - 1);
99
- continue;
100
- }
101
-
102
- /* Step over a `${…}` interpolation. Its braces are not CSS braces, but the `${…}` text
103
- * itself stays in the segment so the transform can recognise the selector as dynamic. */
104
- if (character === '{' && index > 0 && source[index - 1] === '$') {
105
- var isLeading = source.slice(segmentStart, index - 1).trim() === '';
106
- index = skipInterpolation(source, index);
107
- /**
108
- * A `${mixin}` alone on its line, with no `;` after it, is a statement of its own:
109
- * the selector on the next line starts a fresh segment rather than inheriting the
110
- * interpolation and being read as dynamic.
111
- */
112
- if (isLeading && isRestOfLineBlank(source, index + 1)) {
113
- startSegment(index + 1);
114
- }
115
- continue;
116
- }
117
- if (character === '{') {
118
- var raw = source.slice(segmentStart, index);
119
- var leading = raw.length - raw.trimStart().length;
120
- var text = raw.trim();
121
-
122
- /* At-rules are blocks but not selectors; the transform has nothing to say about them. */
123
- if (text !== '' && !text.startsWith('@') && !commentInsideSegment && keyframesDepth === null) {
124
- found.push({
125
- text: text,
126
- start: offset + segmentStart + leading,
127
- end: offset + segmentStart + leading + text.length
128
- });
129
- }
130
- if (keyframesDepth === null && /^@(-[a-z]+-)?keyframes\b/i.test(text)) {
131
- keyframesDepth = braceDepth;
132
- }
133
- braceDepth++;
134
- startSegment(index + 1);
135
- continue;
136
- }
137
- if (character === '}') {
138
- braceDepth = Math.max(0, braceDepth - 1);
139
- if (keyframesDepth !== null && braceDepth <= keyframesDepth) {
140
- keyframesDepth = null;
141
- }
142
- }
143
- if (character === '}' || character === ';') {
144
- startSegment(index + 1);
145
- }
146
- }
147
- return found;
148
- }
149
-
150
- /**
151
- * Is everything from `start` to the next newline whitespace? A missing newline does not count:
152
- * `${selector}` at the very end has nothing after it to separate from.
153
- */
154
- function isRestOfLineBlank(source, start) {
155
- var newline = source.indexOf('\n', start);
156
- return newline !== -1 && source.slice(start, newline).trim() === '';
157
- }
158
-
159
- /**
160
- * Index of the quote closing the string that opens at `start`, or the end of the source when
161
- * the string is unterminated.
162
- */
163
- function skipQuoted(source, start) {
164
- var quote = source[start];
165
- var index = start + 1;
166
- while (index < source.length) {
167
- if (source[index] === '\\') {
168
- index += 2;
169
- continue;
170
- }
171
- if (source[index] === quote) {
172
- return index;
173
- }
174
- index++;
175
- }
176
- return source.length;
177
- }
178
-
179
- /**
180
- * Index of the `}` closing the interpolation whose `{` is at `start`, or the end of the source
181
- * when it is unterminated.
182
- *
183
- * The interpolation holds JavaScript, so a brace inside one of its string literals is not a
184
- * brace: `${cond ? '}' : ''}` closes at the last character, not at the quoted one. Quoted
185
- * strings and template literals are stepped over; a template literal may in turn hold its own
186
- * interpolations, so the two skips call each other.
187
- */
188
- function skipInterpolation(source, start) {
189
- var depth = 1;
190
- var index = start + 1;
191
- while (index < source.length && depth > 0) {
192
- var character = source[index];
193
- if (character === '"' || character === "'") {
194
- index = skipQuoted(source, index) + 1;
195
- continue;
196
- }
197
- if (character === '`') {
198
- index = skipTemplateLiteral(source, index) + 1;
199
- continue;
200
- }
201
- if (character === '{') {
202
- depth++;
203
- } else if (character === '}') {
204
- depth--;
205
- }
206
- index++;
207
- }
208
- return index - 1;
209
- }
210
-
211
- /**
212
- * Index of the backtick closing the template literal that opens at `start`, or the end of the
213
- * source when it is unterminated.
214
- */
215
- function skipTemplateLiteral(source, start) {
216
- var index = start + 1;
217
- while (index < source.length) {
218
- if (source[index] === '\\') {
219
- index += 2;
220
- continue;
221
- }
222
- if (source[index] === '`') {
223
- return index;
224
- }
225
- if (source[index] === '$' && source[index + 1] === '{') {
226
- index = skipInterpolation(source, index + 1) + 1;
227
- continue;
228
- }
229
- index++;
230
- }
231
- return source.length;
232
- }