@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.
- package/CHANGELOG.md +23 -0
- package/README.md +0 -1
- package/dist/cjs/presets/all-flat.codegen.js +1 -2
- package/dist/cjs/presets/all.codegen.js +1 -2
- package/dist/cjs/rules/index.codegen.js +1 -3
- package/dist/cjs/rules/no-imported-style-values/index.js +8 -1
- package/dist/cjs/rules/no-nested-selectors/index.js +13 -1
- package/dist/cjs/rules/utils/walk-style-call-properties.js +24 -11
- package/dist/es2019/presets/all-flat.codegen.js +1 -2
- package/dist/es2019/presets/all.codegen.js +1 -2
- package/dist/es2019/rules/index.codegen.js +1 -3
- package/dist/es2019/rules/no-imported-style-values/index.js +8 -1
- package/dist/es2019/rules/no-nested-selectors/index.js +13 -1
- package/dist/es2019/rules/utils/walk-style-call-properties.js +15 -12
- package/dist/esm/presets/all-flat.codegen.js +1 -2
- package/dist/esm/presets/all.codegen.js +1 -2
- package/dist/esm/rules/index.codegen.js +1 -3
- package/dist/esm/rules/no-imported-style-values/index.js +8 -1
- package/dist/esm/rules/no-nested-selectors/index.js +13 -1
- package/dist/esm/rules/utils/walk-style-call-properties.js +24 -11
- package/dist/types/presets/all-flat.codegen.d.ts +1 -1
- package/dist/types/presets/all.codegen.d.ts +1 -1
- package/dist/types/rules/index.codegen.d.ts +1 -1
- package/dist/types/rules/utils/walk-style-call-properties.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/rules/no-top-layer-unsafe-selectors/find-template-selectors.js +0 -232
- package/dist/cjs/rules/no-top-layer-unsafe-selectors/index.js +0 -425
- package/dist/cjs/rules/no-top-layer-unsafe-selectors/preserve-list-layout.js +0 -63
- package/dist/cjs/rules/no-top-layer-unsafe-selectors/rewrite-selector.js +0 -2415
- package/dist/cjs/rules/utils/walk-style-object-properties.js +0 -47
- package/dist/es2019/rules/no-top-layer-unsafe-selectors/find-template-selectors.js +0 -226
- package/dist/es2019/rules/no-top-layer-unsafe-selectors/index.js +0 -382
- package/dist/es2019/rules/no-top-layer-unsafe-selectors/preserve-list-layout.js +0 -57
- package/dist/es2019/rules/no-top-layer-unsafe-selectors/rewrite-selector.js +0 -2131
- package/dist/es2019/rules/utils/walk-style-object-properties.js +0 -29
- package/dist/esm/rules/no-top-layer-unsafe-selectors/find-template-selectors.js +0 -226
- package/dist/esm/rules/no-top-layer-unsafe-selectors/index.js +0 -419
- package/dist/esm/rules/no-top-layer-unsafe-selectors/preserve-list-layout.js +0 -57
- package/dist/esm/rules/no-top-layer-unsafe-selectors/rewrite-selector.js +0 -2409
- package/dist/esm/rules/utils/walk-style-object-properties.js +0 -41
- package/dist/types/rules/no-top-layer-unsafe-selectors/find-template-selectors.d.ts +0 -29
- package/dist/types/rules/no-top-layer-unsafe-selectors/index.d.ts +0 -3
- package/dist/types/rules/no-top-layer-unsafe-selectors/preserve-list-layout.d.ts +0 -12
- package/dist/types/rules/no-top-layer-unsafe-selectors/rewrite-selector.d.ts +0 -164
- package/dist/types/rules/utils/walk-style-object-properties.d.ts +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
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
|
+
|
|
13
|
+
## 2.4.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`3e2e34bcc2601`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3e2e34bcc2601) -
|
|
18
|
+
`no-imported-style-values`: no longer reports imported identifiers used in qualified type
|
|
19
|
+
positions, such as `'value' satisfies typeof Tokens.COLOR_TEXT` or
|
|
20
|
+
`'value' satisfies Theme.Color`. These are erased at runtime and are not imported style values.
|
|
21
|
+
- [`a5979af0b9045`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a5979af0b9045) -
|
|
22
|
+
`no-nested-selectors` now lints computed keys wrapped in TypeScript expressions (`satisfies`,
|
|
23
|
+
`as`, type assertions, non-null), e.g. `['.foo' satisfies \`.${typeof FOO_CLASS}\`]`. Previously
|
|
24
|
+
these keys were silently skipped.
|
|
25
|
+
|
|
3
26
|
## 2.4.0
|
|
4
27
|
|
|
5
28
|
### Minor 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::
|
|
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::
|
|
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::
|
|
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,
|
|
@@ -83,7 +83,14 @@ var checkIdentifier = function checkIdentifier(identifier, context, functionAllo
|
|
|
83
83
|
// Type references and `typeof` queries are erased at runtime and are not
|
|
84
84
|
// imported style values. Runtime expressions wrapped by `as` or `satisfies`
|
|
85
85
|
// must still be checked.
|
|
86
|
-
|
|
86
|
+
// Qualified names (e.g. `typeof Tokens.COLOR_TEXT` or `Theme.Colors`) nest the
|
|
87
|
+
// identifier inside one or more `TSQualifiedName` nodes, so walk up through them
|
|
88
|
+
// to find the enclosing type node.
|
|
89
|
+
var typeContext = parent;
|
|
90
|
+
while (typeContext && typeContext.type === 'TSQualifiedName') {
|
|
91
|
+
typeContext = typeContext.parent;
|
|
92
|
+
}
|
|
93
|
+
if (typeContext && (typeContext.type === 'TSTypeReference' || typeContext.type === 'TSTypeQuery')) {
|
|
87
94
|
return;
|
|
88
95
|
}
|
|
89
96
|
|
|
@@ -16,7 +16,19 @@ var _walkStyleCallProperties = require("../utils/walk-style-call-properties");
|
|
|
16
16
|
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; } } }; }
|
|
17
17
|
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; } }
|
|
18
18
|
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; }
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Strip TypeScript-only wrappers from a computed key so the selector inside is still linted,
|
|
21
|
+
* for example `['.foo' satisfies `.${typeof FOO_CLASS}`]` is checked as `'.foo'`.
|
|
22
|
+
*/
|
|
23
|
+
var unwrapTypeScriptExpression = function unwrapTypeScriptExpression(key) {
|
|
24
|
+
var expression = key;
|
|
25
|
+
while ((expression.type === 'TSAsExpression' || expression.type === 'TSTypeAssertion' || expression.type === 'TSNonNullExpression' || expression.type === 'TSSatisfiesExpression') && expression.expression) {
|
|
26
|
+
expression = expression.expression;
|
|
27
|
+
}
|
|
28
|
+
return expression;
|
|
29
|
+
};
|
|
30
|
+
var getCssSelector = function getCssSelector(rawKey) {
|
|
31
|
+
var key = unwrapTypeScriptExpression(rawKey);
|
|
20
32
|
if (key.type === 'Literal' && typeof key.value === 'string') {
|
|
21
33
|
return key.value;
|
|
22
34
|
}
|
|
@@ -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
|
-
(
|
|
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
|
-
(
|
|
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::
|
|
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::
|
|
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::
|
|
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,
|
|
@@ -72,7 +72,14 @@ const checkIdentifier = (identifier, context, functionAllowList, keysAllowList)
|
|
|
72
72
|
// Type references and `typeof` queries are erased at runtime and are not
|
|
73
73
|
// imported style values. Runtime expressions wrapped by `as` or `satisfies`
|
|
74
74
|
// must still be checked.
|
|
75
|
-
|
|
75
|
+
// Qualified names (e.g. `typeof Tokens.COLOR_TEXT` or `Theme.Colors`) nest the
|
|
76
|
+
// identifier inside one or more `TSQualifiedName` nodes, so walk up through them
|
|
77
|
+
// to find the enclosing type node.
|
|
78
|
+
let typeContext = parent;
|
|
79
|
+
while (typeContext && typeContext.type === 'TSQualifiedName') {
|
|
80
|
+
typeContext = typeContext.parent;
|
|
81
|
+
}
|
|
82
|
+
if (typeContext && (typeContext.type === 'TSTypeReference' || typeContext.type === 'TSTypeQuery')) {
|
|
76
83
|
return;
|
|
77
84
|
}
|
|
78
85
|
|
|
@@ -5,7 +5,19 @@ import { isSimpleSelector } from '../utils/is-simple-selector';
|
|
|
5
5
|
import { parseSelector } from '../utils/parse-selector';
|
|
6
6
|
import { getStyleCalls } from '../utils/style-calls';
|
|
7
7
|
import { walkStyleCallProperties } from '../utils/walk-style-call-properties';
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Strip TypeScript-only wrappers from a computed key so the selector inside is still linted,
|
|
10
|
+
* for example `['.foo' satisfies `.${typeof FOO_CLASS}`]` is checked as `'.foo'`.
|
|
11
|
+
*/
|
|
12
|
+
const unwrapTypeScriptExpression = key => {
|
|
13
|
+
let expression = key;
|
|
14
|
+
while ((expression.type === 'TSAsExpression' || expression.type === 'TSTypeAssertion' || expression.type === 'TSNonNullExpression' || expression.type === 'TSSatisfiesExpression') && expression.expression) {
|
|
15
|
+
expression = expression.expression;
|
|
16
|
+
}
|
|
17
|
+
return expression;
|
|
18
|
+
};
|
|
19
|
+
const getCssSelector = rawKey => {
|
|
20
|
+
const key = unwrapTypeScriptExpression(rawKey);
|
|
9
21
|
if (key.type === 'Literal' && typeof key.value === 'string') {
|
|
10
22
|
return key.value;
|
|
11
23
|
}
|
|
@@ -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
|
-
|
|
10
|
-
skipTopLevel,
|
|
11
|
-
skipSubtree
|
|
12
|
-
});
|
|
5
|
+
walkStyleObject(argument, visitor, skipTopLevel);
|
|
13
6
|
} else if (argument.type === 'ArrowFunctionExpression' && argument.expression && argument.body.type === 'ObjectExpression') {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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::
|
|
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::
|
|
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::
|
|
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,
|
|
@@ -76,7 +76,14 @@ var checkIdentifier = function checkIdentifier(identifier, context, functionAllo
|
|
|
76
76
|
// Type references and `typeof` queries are erased at runtime and are not
|
|
77
77
|
// imported style values. Runtime expressions wrapped by `as` or `satisfies`
|
|
78
78
|
// must still be checked.
|
|
79
|
-
|
|
79
|
+
// Qualified names (e.g. `typeof Tokens.COLOR_TEXT` or `Theme.Colors`) nest the
|
|
80
|
+
// identifier inside one or more `TSQualifiedName` nodes, so walk up through them
|
|
81
|
+
// to find the enclosing type node.
|
|
82
|
+
var typeContext = parent;
|
|
83
|
+
while (typeContext && typeContext.type === 'TSQualifiedName') {
|
|
84
|
+
typeContext = typeContext.parent;
|
|
85
|
+
}
|
|
86
|
+
if (typeContext && (typeContext.type === 'TSTypeReference' || typeContext.type === 'TSTypeQuery')) {
|
|
80
87
|
return;
|
|
81
88
|
}
|
|
82
89
|
|
|
@@ -9,7 +9,19 @@ import { isSimpleSelector } from '../utils/is-simple-selector';
|
|
|
9
9
|
import { parseSelector } from '../utils/parse-selector';
|
|
10
10
|
import { getStyleCalls } from '../utils/style-calls';
|
|
11
11
|
import { walkStyleCallProperties } from '../utils/walk-style-call-properties';
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Strip TypeScript-only wrappers from a computed key so the selector inside is still linted,
|
|
14
|
+
* for example `['.foo' satisfies `.${typeof FOO_CLASS}`]` is checked as `'.foo'`.
|
|
15
|
+
*/
|
|
16
|
+
var unwrapTypeScriptExpression = function unwrapTypeScriptExpression(key) {
|
|
17
|
+
var expression = key;
|
|
18
|
+
while ((expression.type === 'TSAsExpression' || expression.type === 'TSTypeAssertion' || expression.type === 'TSNonNullExpression' || expression.type === 'TSSatisfiesExpression') && expression.expression) {
|
|
19
|
+
expression = expression.expression;
|
|
20
|
+
}
|
|
21
|
+
return expression;
|
|
22
|
+
};
|
|
23
|
+
var getCssSelector = function getCssSelector(rawKey) {
|
|
24
|
+
var key = unwrapTypeScriptExpression(rawKey);
|
|
13
25
|
if (key.type === 'Literal' && typeof key.value === 'string') {
|
|
14
26
|
return key.value;
|
|
15
27
|
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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::
|
|
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::
|
|
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::
|
|
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