@atlaskit/eslint-plugin-ui-styling-standard 2.1.7 → 2.1.8
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 +11 -0
- package/dist/cjs/rules/no-imported-style-values/index.js +7 -0
- package/dist/cjs/rules/no-unsafe-values/utils.js +26 -0
- package/dist/es2019/rules/no-imported-style-values/index.js +7 -0
- package/dist/es2019/rules/no-unsafe-values/utils.js +26 -0
- package/dist/esm/rules/no-imported-style-values/index.js +7 -0
- package/dist/esm/rules/no-unsafe-values/utils.js +26 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 2.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2808e38fa97f7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2808e38fa97f7) -
|
|
8
|
+
Allow static style keys and values annotated with TypeScript `satisfies` expressions
|
|
9
|
+
- [`98d68443fc958`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/98d68443fc958) -
|
|
10
|
+
Handle TypeScript satisfies and assertion wrappers without rejecting safe inline style values or
|
|
11
|
+
imported type references. Update the Platform ESLint plugin's Compiled ESLint dependency to
|
|
12
|
+
^0.20.2 to fix shorthand-property sorting crashes on inline satisfies expressions.
|
|
13
|
+
|
|
3
14
|
## 2.1.7
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -80,6 +80,13 @@ var checkIdentifier = function checkIdentifier(identifier, context, functionAllo
|
|
|
80
80
|
var _ref = identifier,
|
|
81
81
|
parent = _ref.parent;
|
|
82
82
|
|
|
83
|
+
// Type references and `typeof` queries are erased at runtime and are not
|
|
84
|
+
// imported style values. Runtime expressions wrapped by `as` or `satisfies`
|
|
85
|
+
// must still be checked.
|
|
86
|
+
if (parent && (parent.type === 'TSTypeReference' || parent.type === 'TSTypeQuery')) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
83
90
|
// Even though `member` in `object.member` is syntactically an identifier,
|
|
84
91
|
// it should be ignored as `.member` is syntax sugar for `['member']` here.
|
|
85
92
|
// We should still lint `object[member]` (when `parent.computed` === true)
|
|
@@ -13,6 +13,16 @@ var _findVariable = require("@atlaskit/eslint-utils/find-variable");
|
|
|
13
13
|
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; } } }; }
|
|
14
14
|
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; } }
|
|
15
15
|
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; }
|
|
16
|
+
var unwrapSatisfiesExpression = function unwrapSatisfiesExpression(node) {
|
|
17
|
+
if (node.type !== 'TSSatisfiesExpression') {
|
|
18
|
+
return node;
|
|
19
|
+
}
|
|
20
|
+
var currentNode = node;
|
|
21
|
+
while (['TSAsExpression', 'TSSatisfiesExpression', 'TSTypeAssertion'].includes(currentNode.type)) {
|
|
22
|
+
currentNode = currentNode.expression;
|
|
23
|
+
}
|
|
24
|
+
return currentNode;
|
|
25
|
+
};
|
|
16
26
|
function isReferenceToCssVar(variable) {
|
|
17
27
|
var definitions = variable.defs;
|
|
18
28
|
return definitions.every(function (definition) {
|
|
@@ -189,6 +199,16 @@ var Linter = exports.Linter = /*#__PURE__*/function () {
|
|
|
189
199
|
}, {
|
|
190
200
|
key: "lintKey",
|
|
191
201
|
value: function lintKey(property) {
|
|
202
|
+
var key = property.key;
|
|
203
|
+
|
|
204
|
+
// A type-only `satisfies` annotation preserves a static key at runtime.
|
|
205
|
+
// It is safe for the same reason as a directly written string literal.
|
|
206
|
+
var unwrappedKey = unwrapSatisfiesExpression(key);
|
|
207
|
+
var isSatisfiesExpression = unwrappedKey !== key;
|
|
208
|
+
if (property.computed && isSatisfiesExpression && unwrappedKey.type === 'Literal' && typeof unwrappedKey.value === 'string') {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
192
212
|
/**
|
|
193
213
|
* If it's not computed then it must be a plain string.
|
|
194
214
|
*
|
|
@@ -280,6 +300,12 @@ var Linter = exports.Linter = /*#__PURE__*/function () {
|
|
|
280
300
|
}, {
|
|
281
301
|
key: "lintValue",
|
|
282
302
|
value: function lintValue(value) {
|
|
303
|
+
var unwrappedValue = unwrapSatisfiesExpression(value);
|
|
304
|
+
if (unwrappedValue !== value) {
|
|
305
|
+
this.lintValue(unwrappedValue);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
|
|
283
309
|
/**
|
|
284
310
|
* Literals are always allowed by this rule.
|
|
285
311
|
*/
|
|
@@ -69,6 +69,13 @@ const checkIdentifier = (identifier, context, functionAllowList, keysAllowList)
|
|
|
69
69
|
parent
|
|
70
70
|
} = identifier;
|
|
71
71
|
|
|
72
|
+
// Type references and `typeof` queries are erased at runtime and are not
|
|
73
|
+
// imported style values. Runtime expressions wrapped by `as` or `satisfies`
|
|
74
|
+
// must still be checked.
|
|
75
|
+
if (parent && (parent.type === 'TSTypeReference' || parent.type === 'TSTypeQuery')) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
// Even though `member` in `object.member` is syntactically an identifier,
|
|
73
80
|
// it should be ignored as `.member` is syntax sugar for `['member']` here.
|
|
74
81
|
// We should still lint `object[member]` (when `parent.computed` === true)
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { getAllowedDynamicKeys, getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
2
2
|
import { findIdentifierNode } from '@atlaskit/eslint-utils/find-identifier-node';
|
|
3
3
|
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
4
|
+
const unwrapSatisfiesExpression = node => {
|
|
5
|
+
if (node.type !== 'TSSatisfiesExpression') {
|
|
6
|
+
return node;
|
|
7
|
+
}
|
|
8
|
+
let currentNode = node;
|
|
9
|
+
while (['TSAsExpression', 'TSSatisfiesExpression', 'TSTypeAssertion'].includes(currentNode.type)) {
|
|
10
|
+
currentNode = currentNode.expression;
|
|
11
|
+
}
|
|
12
|
+
return currentNode;
|
|
13
|
+
};
|
|
4
14
|
function isReferenceToCssVar(variable) {
|
|
5
15
|
const definitions = variable.defs;
|
|
6
16
|
return definitions.every(definition => {
|
|
@@ -156,6 +166,16 @@ export class Linter {
|
|
|
156
166
|
});
|
|
157
167
|
}
|
|
158
168
|
lintKey(property) {
|
|
169
|
+
const key = property.key;
|
|
170
|
+
|
|
171
|
+
// A type-only `satisfies` annotation preserves a static key at runtime.
|
|
172
|
+
// It is safe for the same reason as a directly written string literal.
|
|
173
|
+
const unwrappedKey = unwrapSatisfiesExpression(key);
|
|
174
|
+
const isSatisfiesExpression = unwrappedKey !== key;
|
|
175
|
+
if (property.computed && isSatisfiesExpression && unwrappedKey.type === 'Literal' && typeof unwrappedKey.value === 'string') {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
159
179
|
/**
|
|
160
180
|
* If it's not computed then it must be a plain string.
|
|
161
181
|
*
|
|
@@ -228,6 +248,12 @@ export class Linter {
|
|
|
228
248
|
});
|
|
229
249
|
}
|
|
230
250
|
lintValue(value) {
|
|
251
|
+
const unwrappedValue = unwrapSatisfiesExpression(value);
|
|
252
|
+
if (unwrappedValue !== value) {
|
|
253
|
+
this.lintValue(unwrappedValue);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
231
257
|
/**
|
|
232
258
|
* Literals are always allowed by this rule.
|
|
233
259
|
*/
|
|
@@ -73,6 +73,13 @@ var checkIdentifier = function checkIdentifier(identifier, context, functionAllo
|
|
|
73
73
|
var _ref = identifier,
|
|
74
74
|
parent = _ref.parent;
|
|
75
75
|
|
|
76
|
+
// Type references and `typeof` queries are erased at runtime and are not
|
|
77
|
+
// imported style values. Runtime expressions wrapped by `as` or `satisfies`
|
|
78
|
+
// must still be checked.
|
|
79
|
+
if (parent && (parent.type === 'TSTypeReference' || parent.type === 'TSTypeQuery')) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
76
83
|
// Even though `member` in `object.member` is syntactically an identifier,
|
|
77
84
|
// it should be ignored as `.member` is syntax sugar for `['member']` here.
|
|
78
85
|
// We should still lint `object[member]` (when `parent.computed` === true)
|
|
@@ -6,6 +6,16 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
6
6
|
import { getAllowedDynamicKeys, getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
7
7
|
import { findIdentifierNode } from '@atlaskit/eslint-utils/find-identifier-node';
|
|
8
8
|
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
9
|
+
var unwrapSatisfiesExpression = function unwrapSatisfiesExpression(node) {
|
|
10
|
+
if (node.type !== 'TSSatisfiesExpression') {
|
|
11
|
+
return node;
|
|
12
|
+
}
|
|
13
|
+
var currentNode = node;
|
|
14
|
+
while (['TSAsExpression', 'TSSatisfiesExpression', 'TSTypeAssertion'].includes(currentNode.type)) {
|
|
15
|
+
currentNode = currentNode.expression;
|
|
16
|
+
}
|
|
17
|
+
return currentNode;
|
|
18
|
+
};
|
|
9
19
|
function isReferenceToCssVar(variable) {
|
|
10
20
|
var definitions = variable.defs;
|
|
11
21
|
return definitions.every(function (definition) {
|
|
@@ -182,6 +192,16 @@ export var Linter = /*#__PURE__*/function () {
|
|
|
182
192
|
}, {
|
|
183
193
|
key: "lintKey",
|
|
184
194
|
value: function lintKey(property) {
|
|
195
|
+
var key = property.key;
|
|
196
|
+
|
|
197
|
+
// A type-only `satisfies` annotation preserves a static key at runtime.
|
|
198
|
+
// It is safe for the same reason as a directly written string literal.
|
|
199
|
+
var unwrappedKey = unwrapSatisfiesExpression(key);
|
|
200
|
+
var isSatisfiesExpression = unwrappedKey !== key;
|
|
201
|
+
if (property.computed && isSatisfiesExpression && unwrappedKey.type === 'Literal' && typeof unwrappedKey.value === 'string') {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
185
205
|
/**
|
|
186
206
|
* If it's not computed then it must be a plain string.
|
|
187
207
|
*
|
|
@@ -273,6 +293,12 @@ export var Linter = /*#__PURE__*/function () {
|
|
|
273
293
|
}, {
|
|
274
294
|
key: "lintValue",
|
|
275
295
|
value: function lintValue(value) {
|
|
296
|
+
var unwrappedValue = unwrapSatisfiesExpression(value);
|
|
297
|
+
if (unwrappedValue !== value) {
|
|
298
|
+
this.lintValue(unwrappedValue);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
|
|
276
302
|
/**
|
|
277
303
|
* Literals are always allowed by this rule.
|
|
278
304
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-ui-styling-standard",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8",
|
|
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",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"@types/eslint": "^8.56.6",
|
|
51
51
|
"@types/eslint__eslintrc": "^2.1.2",
|
|
52
52
|
"@types/estraverse": "^5.1.7",
|
|
53
|
+
"@types/estree": "1.0.5",
|
|
53
54
|
"@types/json-schema": "^7.0.15",
|
|
54
55
|
"eslint": "^8.57.0",
|
|
55
56
|
"lodash": "^4.17.21"
|