@atlaskit/eslint-plugin-design-system 9.5.0 → 9.5.1
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 +7 -0
- package/dist/cjs/rules/no-invalid-css-map/utils.js +23 -61
- package/dist/es2019/rules/no-invalid-css-map/utils.js +22 -49
- package/dist/esm/rules/no-invalid-css-map/utils.js +22 -60
- package/dist/types/rules/no-invalid-css-map/utils.d.ts +1 -2
- package/dist/types-ts4.5/rules/no-invalid-css-map/utils.d.ts +1 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 9.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#87213](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87213) [`c7caf85c839c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c7caf85c839c) - Internal refactoring to `no-invalid-css-map` to use new shared utilities from `@atlaskit/eslint-utils` for determining allowed functions calls.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 9.5.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -5,9 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getCssMapObject = exports.CssMapObjectChecker = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _allowedFunctionCalls = require("@atlaskit/eslint-utils/allowed-function-calls");
|
|
11
|
+
var _findVariable = require("@atlaskit/eslint-utils/find-variable");
|
|
11
12
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
13
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
14
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -23,75 +24,35 @@ var getCssMapObject = exports.getCssMapObject = function getCssMapObject(node) {
|
|
|
23
24
|
}
|
|
24
25
|
return node.arguments[0];
|
|
25
26
|
};
|
|
26
|
-
var findNodeReference = function findNodeReference(references, node) {
|
|
27
|
-
return references.find(function (reference) {
|
|
28
|
-
return reference.identifier === node;
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
var getAllowedFunctionCalls = function getAllowedFunctionCalls(options) {
|
|
32
|
-
var _options$;
|
|
33
|
-
if (options.length === 0 || ((_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.allowedFunctionCalls) === undefined) {
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Beyond the basic check of "does allowedFunctionCalls exist?",
|
|
38
|
-
// we assume ESLint's rule checker type checks the contents of allowedFunctionCalls
|
|
39
|
-
// as it should
|
|
40
|
-
return options[0].allowedFunctionCalls;
|
|
41
|
-
};
|
|
42
27
|
var CssMapObjectChecker = exports.CssMapObjectChecker = /*#__PURE__*/function () {
|
|
43
28
|
function CssMapObjectChecker(cssMapObject, context) {
|
|
44
29
|
(0, _classCallCheck2.default)(this, CssMapObjectChecker);
|
|
45
|
-
this.allowedFunctionCalls = getAllowedFunctionCalls(context.options);
|
|
30
|
+
this.allowedFunctionCalls = (0, _allowedFunctionCalls.getAllowedFunctionCalls)(context.options);
|
|
46
31
|
this.cssMapObject = cssMapObject;
|
|
47
32
|
this.report = context.report;
|
|
48
|
-
this.
|
|
33
|
+
this.context = context;
|
|
49
34
|
}
|
|
50
35
|
(0, _createClass2.default)(CssMapObjectChecker, [{
|
|
51
|
-
key: "isNotWhitelistedFunction",
|
|
52
|
-
value: function isNotWhitelistedFunction(callee) {
|
|
53
|
-
var _reference$resolved,
|
|
54
|
-
_this = this;
|
|
55
|
-
if (callee.type !== 'Identifier' || this.allowedFunctionCalls.length === 0) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
var reference = findNodeReference(this.references, callee);
|
|
59
|
-
var definitions = reference === null || reference === void 0 || (_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs;
|
|
60
|
-
if (!definitions) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
return definitions.some(function (definition) {
|
|
64
|
-
// We add some restrictions to keep this simple...
|
|
65
|
-
// Forbid non-imported functions
|
|
66
|
-
if (definition.type !== 'ImportBinding') {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
// Forbid default imports (e.g. `import React from 'react'`)
|
|
70
|
-
if (definition.node.type !== 'ImportSpecifier') {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
var packageName = definition.parent.source.value;
|
|
74
|
-
var importedFunctionName = definition.node.imported.name;
|
|
75
|
-
return !_this.allowedFunctionCalls.some(function (_ref) {
|
|
76
|
-
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
77
|
-
allowedPackageName = _ref2[0],
|
|
78
|
-
allowedFunctionName = _ref2[1];
|
|
79
|
-
return allowedPackageName === packageName && allowedFunctionName === importedFunctionName;
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
36
|
key: "checkCssMapObjectValue",
|
|
85
37
|
value: function checkCssMapObjectValue(value) {
|
|
86
|
-
if (value.type === 'CallExpression' &&
|
|
38
|
+
if (value.type === 'CallExpression' && value.callee.type === 'Identifier') {
|
|
87
39
|
// object value is a function call in the style
|
|
88
40
|
// {
|
|
89
41
|
// key: functionCall(), ...
|
|
90
42
|
// }
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
43
|
+
var variable = (0, _findVariable.findVariable)({
|
|
44
|
+
identifier: value.callee,
|
|
45
|
+
sourceCode: this.context.sourceCode
|
|
94
46
|
});
|
|
47
|
+
if (!variable || !(0, _allowedFunctionCalls.isAllowListedVariable)({
|
|
48
|
+
allowList: this.allowedFunctionCalls,
|
|
49
|
+
variable: variable
|
|
50
|
+
})) {
|
|
51
|
+
this.report({
|
|
52
|
+
node: value,
|
|
53
|
+
messageId: 'noFunctionCalls'
|
|
54
|
+
});
|
|
55
|
+
}
|
|
95
56
|
} else if (value.type === 'ArrowFunctionExpression' || value.type === 'FunctionExpression') {
|
|
96
57
|
// object value is a function call in the style
|
|
97
58
|
// {
|
|
@@ -106,16 +67,17 @@ var CssMapObjectChecker = exports.CssMapObjectChecker = /*#__PURE__*/function ()
|
|
|
106
67
|
this.checkCssMapObjectValue(value.left);
|
|
107
68
|
this.checkCssMapObjectValue(value.right);
|
|
108
69
|
} else if (value.type === 'Identifier') {
|
|
109
|
-
var
|
|
110
|
-
|
|
70
|
+
var _variable = (0, _findVariable.findVariable)({
|
|
71
|
+
identifier: value,
|
|
72
|
+
sourceCode: this.context.sourceCode
|
|
73
|
+
});
|
|
111
74
|
|
|
112
|
-
// Get the variable's definition when initialised
|
|
113
|
-
// is the most recent one.
|
|
75
|
+
// Get the variable's definition when initialised, and check the first definition that we find.
|
|
114
76
|
//
|
|
115
77
|
// Ideally we would try to get the variable's value at the point at which
|
|
116
78
|
// cssMap() is run, but ESLint doesn't seem to give us an easy way to
|
|
117
79
|
// do that...
|
|
118
|
-
var definitions =
|
|
80
|
+
var definitions = _variable === null || _variable === void 0 ? void 0 : _variable.defs;
|
|
119
81
|
if (!definitions || definitions.length === 0) {
|
|
120
82
|
// Variable is not defined :thinking:
|
|
121
83
|
return;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
2
|
+
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
1
3
|
export const getCssMapObject = node => {
|
|
2
4
|
// We assume the argument `node` is already a cssMap() call.
|
|
3
5
|
|
|
@@ -10,62 +12,32 @@ export const getCssMapObject = node => {
|
|
|
10
12
|
}
|
|
11
13
|
return node.arguments[0];
|
|
12
14
|
};
|
|
13
|
-
const findNodeReference = (references, node) => {
|
|
14
|
-
return references.find(reference => reference.identifier === node);
|
|
15
|
-
};
|
|
16
|
-
const getAllowedFunctionCalls = options => {
|
|
17
|
-
var _options$;
|
|
18
|
-
if (options.length === 0 || ((_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.allowedFunctionCalls) === undefined) {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Beyond the basic check of "does allowedFunctionCalls exist?",
|
|
23
|
-
// we assume ESLint's rule checker type checks the contents of allowedFunctionCalls
|
|
24
|
-
// as it should
|
|
25
|
-
return options[0].allowedFunctionCalls;
|
|
26
|
-
};
|
|
27
15
|
export class CssMapObjectChecker {
|
|
28
16
|
constructor(cssMapObject, context) {
|
|
29
17
|
this.allowedFunctionCalls = getAllowedFunctionCalls(context.options);
|
|
30
18
|
this.cssMapObject = cssMapObject;
|
|
31
19
|
this.report = context.report;
|
|
32
|
-
this.
|
|
33
|
-
}
|
|
34
|
-
isNotWhitelistedFunction(callee) {
|
|
35
|
-
var _reference$resolved;
|
|
36
|
-
if (callee.type !== 'Identifier' || this.allowedFunctionCalls.length === 0) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
const reference = findNodeReference(this.references, callee);
|
|
40
|
-
const definitions = reference === null || reference === void 0 ? void 0 : (_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs;
|
|
41
|
-
if (!definitions) {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
return definitions.some(definition => {
|
|
45
|
-
// We add some restrictions to keep this simple...
|
|
46
|
-
// Forbid non-imported functions
|
|
47
|
-
if (definition.type !== 'ImportBinding') {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
// Forbid default imports (e.g. `import React from 'react'`)
|
|
51
|
-
if (definition.node.type !== 'ImportSpecifier') {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
const packageName = definition.parent.source.value;
|
|
55
|
-
const importedFunctionName = definition.node.imported.name;
|
|
56
|
-
return !this.allowedFunctionCalls.some(([allowedPackageName, allowedFunctionName]) => allowedPackageName === packageName && allowedFunctionName === importedFunctionName);
|
|
57
|
-
});
|
|
20
|
+
this.context = context;
|
|
58
21
|
}
|
|
59
22
|
checkCssMapObjectValue(value) {
|
|
60
|
-
if (value.type === 'CallExpression' &&
|
|
23
|
+
if (value.type === 'CallExpression' && value.callee.type === 'Identifier') {
|
|
61
24
|
// object value is a function call in the style
|
|
62
25
|
// {
|
|
63
26
|
// key: functionCall(), ...
|
|
64
27
|
// }
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
28
|
+
const variable = findVariable({
|
|
29
|
+
identifier: value.callee,
|
|
30
|
+
sourceCode: this.context.sourceCode
|
|
68
31
|
});
|
|
32
|
+
if (!variable || !isAllowListedVariable({
|
|
33
|
+
allowList: this.allowedFunctionCalls,
|
|
34
|
+
variable
|
|
35
|
+
})) {
|
|
36
|
+
this.report({
|
|
37
|
+
node: value,
|
|
38
|
+
messageId: 'noFunctionCalls'
|
|
39
|
+
});
|
|
40
|
+
}
|
|
69
41
|
} else if (value.type === 'ArrowFunctionExpression' || value.type === 'FunctionExpression') {
|
|
70
42
|
// object value is a function call in the style
|
|
71
43
|
// {
|
|
@@ -80,16 +52,17 @@ export class CssMapObjectChecker {
|
|
|
80
52
|
this.checkCssMapObjectValue(value.left);
|
|
81
53
|
this.checkCssMapObjectValue(value.right);
|
|
82
54
|
} else if (value.type === 'Identifier') {
|
|
83
|
-
|
|
84
|
-
|
|
55
|
+
const variable = findVariable({
|
|
56
|
+
identifier: value,
|
|
57
|
+
sourceCode: this.context.sourceCode
|
|
58
|
+
});
|
|
85
59
|
|
|
86
|
-
// Get the variable's definition when initialised
|
|
87
|
-
// is the most recent one.
|
|
60
|
+
// Get the variable's definition when initialised, and check the first definition that we find.
|
|
88
61
|
//
|
|
89
62
|
// Ideally we would try to get the variable's value at the point at which
|
|
90
63
|
// cssMap() is run, but ESLint doesn't seem to give us an easy way to
|
|
91
64
|
// do that...
|
|
92
|
-
const definitions =
|
|
65
|
+
const definitions = variable === null || variable === void 0 ? void 0 : variable.defs;
|
|
93
66
|
if (!definitions || definitions.length === 0) {
|
|
94
67
|
// Variable is not defined :thinking:
|
|
95
68
|
return;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
3
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
5
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
5
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
import { getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
7
|
+
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
7
8
|
export var getCssMapObject = function getCssMapObject(node) {
|
|
8
9
|
// We assume the argument `node` is already a cssMap() call.
|
|
9
10
|
|
|
@@ -16,75 +17,35 @@ export var getCssMapObject = function getCssMapObject(node) {
|
|
|
16
17
|
}
|
|
17
18
|
return node.arguments[0];
|
|
18
19
|
};
|
|
19
|
-
var findNodeReference = function findNodeReference(references, node) {
|
|
20
|
-
return references.find(function (reference) {
|
|
21
|
-
return reference.identifier === node;
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
var getAllowedFunctionCalls = function getAllowedFunctionCalls(options) {
|
|
25
|
-
var _options$;
|
|
26
|
-
if (options.length === 0 || ((_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.allowedFunctionCalls) === undefined) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Beyond the basic check of "does allowedFunctionCalls exist?",
|
|
31
|
-
// we assume ESLint's rule checker type checks the contents of allowedFunctionCalls
|
|
32
|
-
// as it should
|
|
33
|
-
return options[0].allowedFunctionCalls;
|
|
34
|
-
};
|
|
35
20
|
export var CssMapObjectChecker = /*#__PURE__*/function () {
|
|
36
21
|
function CssMapObjectChecker(cssMapObject, context) {
|
|
37
22
|
_classCallCheck(this, CssMapObjectChecker);
|
|
38
23
|
this.allowedFunctionCalls = getAllowedFunctionCalls(context.options);
|
|
39
24
|
this.cssMapObject = cssMapObject;
|
|
40
25
|
this.report = context.report;
|
|
41
|
-
this.
|
|
26
|
+
this.context = context;
|
|
42
27
|
}
|
|
43
28
|
_createClass(CssMapObjectChecker, [{
|
|
44
|
-
key: "isNotWhitelistedFunction",
|
|
45
|
-
value: function isNotWhitelistedFunction(callee) {
|
|
46
|
-
var _reference$resolved,
|
|
47
|
-
_this = this;
|
|
48
|
-
if (callee.type !== 'Identifier' || this.allowedFunctionCalls.length === 0) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
var reference = findNodeReference(this.references, callee);
|
|
52
|
-
var definitions = reference === null || reference === void 0 || (_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs;
|
|
53
|
-
if (!definitions) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
return definitions.some(function (definition) {
|
|
57
|
-
// We add some restrictions to keep this simple...
|
|
58
|
-
// Forbid non-imported functions
|
|
59
|
-
if (definition.type !== 'ImportBinding') {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
// Forbid default imports (e.g. `import React from 'react'`)
|
|
63
|
-
if (definition.node.type !== 'ImportSpecifier') {
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
var packageName = definition.parent.source.value;
|
|
67
|
-
var importedFunctionName = definition.node.imported.name;
|
|
68
|
-
return !_this.allowedFunctionCalls.some(function (_ref) {
|
|
69
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
70
|
-
allowedPackageName = _ref2[0],
|
|
71
|
-
allowedFunctionName = _ref2[1];
|
|
72
|
-
return allowedPackageName === packageName && allowedFunctionName === importedFunctionName;
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}, {
|
|
77
29
|
key: "checkCssMapObjectValue",
|
|
78
30
|
value: function checkCssMapObjectValue(value) {
|
|
79
|
-
if (value.type === 'CallExpression' &&
|
|
31
|
+
if (value.type === 'CallExpression' && value.callee.type === 'Identifier') {
|
|
80
32
|
// object value is a function call in the style
|
|
81
33
|
// {
|
|
82
34
|
// key: functionCall(), ...
|
|
83
35
|
// }
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
36
|
+
var variable = findVariable({
|
|
37
|
+
identifier: value.callee,
|
|
38
|
+
sourceCode: this.context.sourceCode
|
|
87
39
|
});
|
|
40
|
+
if (!variable || !isAllowListedVariable({
|
|
41
|
+
allowList: this.allowedFunctionCalls,
|
|
42
|
+
variable: variable
|
|
43
|
+
})) {
|
|
44
|
+
this.report({
|
|
45
|
+
node: value,
|
|
46
|
+
messageId: 'noFunctionCalls'
|
|
47
|
+
});
|
|
48
|
+
}
|
|
88
49
|
} else if (value.type === 'ArrowFunctionExpression' || value.type === 'FunctionExpression') {
|
|
89
50
|
// object value is a function call in the style
|
|
90
51
|
// {
|
|
@@ -99,16 +60,17 @@ export var CssMapObjectChecker = /*#__PURE__*/function () {
|
|
|
99
60
|
this.checkCssMapObjectValue(value.left);
|
|
100
61
|
this.checkCssMapObjectValue(value.right);
|
|
101
62
|
} else if (value.type === 'Identifier') {
|
|
102
|
-
var
|
|
103
|
-
|
|
63
|
+
var _variable = findVariable({
|
|
64
|
+
identifier: value,
|
|
65
|
+
sourceCode: this.context.sourceCode
|
|
66
|
+
});
|
|
104
67
|
|
|
105
|
-
// Get the variable's definition when initialised
|
|
106
|
-
// is the most recent one.
|
|
68
|
+
// Get the variable's definition when initialised, and check the first definition that we find.
|
|
107
69
|
//
|
|
108
70
|
// Ideally we would try to get the variable's value at the point at which
|
|
109
71
|
// cssMap() is run, but ESLint doesn't seem to give us an easy way to
|
|
110
72
|
// do that...
|
|
111
|
-
var definitions =
|
|
73
|
+
var definitions = _variable === null || _variable === void 0 ? void 0 : _variable.defs;
|
|
112
74
|
if (!definitions || definitions.length === 0) {
|
|
113
75
|
// Variable is not defined :thinking:
|
|
114
76
|
return;
|
|
@@ -5,9 +5,8 @@ export declare class CssMapObjectChecker {
|
|
|
5
5
|
private readonly allowedFunctionCalls;
|
|
6
6
|
private readonly cssMapObject;
|
|
7
7
|
private readonly report;
|
|
8
|
-
private readonly
|
|
8
|
+
private readonly context;
|
|
9
9
|
constructor(cssMapObject: ObjectExpression, context: Rule.RuleContext);
|
|
10
|
-
private isNotWhitelistedFunction;
|
|
11
10
|
private checkCssMapObjectValue;
|
|
12
11
|
private checkCssMapObject;
|
|
13
12
|
run(): void;
|
|
@@ -5,9 +5,8 @@ export declare class CssMapObjectChecker {
|
|
|
5
5
|
private readonly allowedFunctionCalls;
|
|
6
6
|
private readonly cssMapObject;
|
|
7
7
|
private readonly report;
|
|
8
|
-
private readonly
|
|
8
|
+
private readonly context;
|
|
9
9
|
constructor(cssMapObject: ObjectExpression, context: Rule.RuleContext);
|
|
10
|
-
private isNotWhitelistedFunction;
|
|
11
10
|
private checkCssMapObjectValue;
|
|
12
11
|
private checkCssMapObject;
|
|
13
12
|
run(): void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-design-system",
|
|
3
3
|
"description": "The essential plugin for use with the Atlassian Design System.",
|
|
4
|
-
"version": "9.5.
|
|
4
|
+
"version": "9.5.1",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"react": "^16.8.0 || ^17.0.0 || ~18.2.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@atlaskit/eslint-utils": "^1.
|
|
44
|
+
"@atlaskit/eslint-utils": "^1.3.0",
|
|
45
45
|
"@atlaskit/tokens": "*",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
47
|
"@typescript-eslint/utils": "^5.48.1",
|