@atlaskit/eslint-plugin-platform 1.0.0 → 2.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 +22 -0
- package/afm-jira/tsconfig.json +5 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/rules/compiled/expand-background-shorthand/index.js +5 -5
- package/dist/cjs/rules/feature-gating/inline-usage/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-module-level-eval/index.js +4 -3
- package/dist/cjs/rules/feature-gating/no-module-level-eval-nav4/index.js +4 -3
- package/dist/cjs/rules/feature-gating/no-preconditioning/index.js +1 -1
- package/dist/cjs/rules/feature-gating/prefer-fg/index.js +7 -6
- package/dist/cjs/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/cjs/rules/feature-gating/use-recommended-utils/index.js +2 -2
- package/dist/cjs/rules/feature-gating/utils.js +10 -9
- package/dist/cjs/rules/util/context-compat.js +33 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/rules/compiled/expand-background-shorthand/index.js +4 -4
- package/dist/es2019/rules/feature-gating/inline-usage/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-module-level-eval/index.js +4 -3
- package/dist/es2019/rules/feature-gating/no-module-level-eval-nav4/index.js +4 -3
- package/dist/es2019/rules/feature-gating/no-preconditioning/index.js +1 -1
- package/dist/es2019/rules/feature-gating/prefer-fg/index.js +5 -4
- package/dist/es2019/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/es2019/rules/feature-gating/use-recommended-utils/index.js +2 -2
- package/dist/es2019/rules/feature-gating/utils.js +9 -8
- package/dist/es2019/rules/util/context-compat.js +27 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/rules/compiled/expand-background-shorthand/index.js +5 -5
- package/dist/esm/rules/feature-gating/inline-usage/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-module-level-eval/index.js +4 -3
- package/dist/esm/rules/feature-gating/no-module-level-eval-nav4/index.js +4 -3
- package/dist/esm/rules/feature-gating/no-preconditioning/index.js +1 -1
- package/dist/esm/rules/feature-gating/prefer-fg/index.js +7 -6
- package/dist/esm/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/esm/rules/feature-gating/use-recommended-utils/index.js +2 -2
- package/dist/esm/rules/feature-gating/utils.js +10 -9
- package/dist/esm/rules/util/context-compat.js +27 -0
- package/dist/types/rules/feature-gating/utils.d.ts +4 -3
- package/dist/types/rules/util/context-compat.d.ts +10 -0
- package/dist/types-ts4.5/rules/feature-gating/utils.d.ts +4 -3
- package/dist/types-ts4.5/rules/util/context-compat.d.ts +10 -0
- package/package.json +2 -5
- package/src/index.tsx +1 -1
- package/src/rules/compiled/expand-background-shorthand/__tests__/rule.test.ts +1 -1
- package/src/rules/compiled/expand-background-shorthand/index.tsx +4 -4
- package/src/rules/feature-gating/inline-usage/index.tsx +1 -1
- package/src/rules/feature-gating/no-alias/index.tsx +6 -1
- package/src/rules/feature-gating/no-module-level-eval/index.tsx +8 -6
- package/src/rules/feature-gating/no-module-level-eval-nav4/index.tsx +6 -5
- package/src/rules/feature-gating/no-preconditioning/index.tsx +1 -1
- package/src/rules/feature-gating/prefer-fg/index.tsx +8 -6
- package/src/rules/feature-gating/static-feature-flags/index.tsx +2 -2
- package/src/rules/feature-gating/use-recommended-utils/index.tsx +2 -2
- package/src/rules/feature-gating/utils.tsx +8 -6
- package/src/rules/util/context-compat.ts +28 -0
- package/tsconfig.app.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-platform
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#176646](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/176646)
|
|
8
|
+
[`9612cd921a885`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9612cd921a885) -
|
|
9
|
+
ESlint rule for expand background shorthand with color token
|
|
10
|
+
|
|
11
|
+
## 1.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#176809](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/176809)
|
|
16
|
+
[`ec53bfbf3e476`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ec53bfbf3e476) -
|
|
17
|
+
support eslint v9
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [#176809](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/176809)
|
|
22
|
+
[`d03658b0cfd2e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d03658b0cfd2e) -
|
|
23
|
+
remove compiled plugin from peer dependencies
|
|
24
|
+
|
|
3
25
|
## 1.0.0
|
|
4
26
|
|
|
5
27
|
### Major Changes
|
package/afm-jira/tsconfig.json
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -69,7 +69,7 @@ var commonConfig = {
|
|
|
69
69
|
'@atlaskit/platform/no-module-level-eval-nav4': 'error',
|
|
70
70
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
71
71
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
72
|
-
'@atlaskit/platform/expand-background-shorthand': '
|
|
72
|
+
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
73
73
|
'@compiled/jsx-pragma': ['error', {
|
|
74
74
|
importSources: ['@atlaskit/css'],
|
|
75
75
|
onlyRunIfImportingCompiled: true,
|
|
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.expandBackgroundShorthand = exports.default = void 0;
|
|
7
7
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
8
|
+
var _contextCompat = require("../../util/context-compat");
|
|
8
9
|
// Checks if the function that holds the border property is using an import package that this rule is targeting
|
|
9
|
-
var isCompiledAPI = function isCompiledAPI(context) {
|
|
10
|
+
var isCompiledAPI = function isCompiledAPI(context, node) {
|
|
10
11
|
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
11
|
-
var
|
|
12
|
-
references =
|
|
12
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
13
|
+
references = _getScope.references;
|
|
13
14
|
var ancestors = context.getAncestors();
|
|
14
15
|
if (ancestors.some(function (ancestor) {
|
|
15
16
|
return ancestor.type === 'CallExpression' && ancestor.callee && ((0, _isSupportedImport.isCompiled)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isAtlasKitCSS)(ancestor.callee, references, importSources));
|
|
@@ -42,7 +43,7 @@ var expandBackgroundShorthand = exports.expandBackgroundShorthand = {
|
|
|
42
43
|
create: function create(context) {
|
|
43
44
|
return {
|
|
44
45
|
'Property[key.name="background"]': function PropertyKeyNameBackground(node) {
|
|
45
|
-
if (isCompiledAPI(context) && isTokenCallExpression(node.value)) {
|
|
46
|
+
if (isCompiledAPI(context, node) && isTokenCallExpression(node.value)) {
|
|
46
47
|
context.report({
|
|
47
48
|
node: node,
|
|
48
49
|
messageId: 'expandBackgroundShorthand',
|
|
@@ -50,7 +51,6 @@ var expandBackgroundShorthand = exports.expandBackgroundShorthand = {
|
|
|
50
51
|
return fixer.replaceText(node.key, "backgroundColor");
|
|
51
52
|
}
|
|
52
53
|
});
|
|
53
|
-
return;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
};
|
|
@@ -15,7 +15,7 @@ var findDefinitionDeclaration = function findDefinitionDeclaration(node) {
|
|
|
15
15
|
var validateCallExpression = function validateCallExpression(node, context) {
|
|
16
16
|
var targetedFunctionsSwitch = context.options[0] === 'ssOnly' ? STATSIG_ONLY_FUNCTION_NAMES : FUNCTION_NAMES;
|
|
17
17
|
var callee = node.callee;
|
|
18
|
-
var shouldWarn = callee.type === 'Identifier' && targetedFunctionsSwitch.has(callee.name) && (0, _utils.isAPIimport)(callee.name, context);
|
|
18
|
+
var shouldWarn = callee.type === 'Identifier' && targetedFunctionsSwitch.has(callee.name) && (0, _utils.isAPIimport)(callee.name, context, node);
|
|
19
19
|
if (shouldWarn) {
|
|
20
20
|
var defDeclaration = findDefinitionDeclaration(node.parent);
|
|
21
21
|
context.report({
|
|
@@ -50,7 +50,7 @@ var rule = {
|
|
|
50
50
|
if (!node.init || node.init.type !== 'Identifier') {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
var isReassignment = (0, _utils.isIdentifierImportedFrom)(node.init.name, IMPORT_SOURCES, context);
|
|
53
|
+
var isReassignment = (0, _utils.isIdentifierImportedFrom)(node.init.name, IMPORT_SOURCES, context, node);
|
|
54
54
|
if (isReassignment) {
|
|
55
55
|
context.report({
|
|
56
56
|
messageId: 'noReassignment',
|
|
@@ -5,8 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _utils = require("../utils");
|
|
8
|
-
var
|
|
9
|
-
|
|
8
|
+
var _contextCompat = require("../../util/context-compat");
|
|
9
|
+
var isInFunctionLevel = function isInFunctionLevel(context, node) {
|
|
10
|
+
var scope = (0, _contextCompat.getScope)(context, node);
|
|
10
11
|
while (((_scope = scope) === null || _scope === void 0 ? void 0 : _scope.type) !== 'module' && ((_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2.type) !== 'global') {
|
|
11
12
|
var _scope, _scope2;
|
|
12
13
|
if (scope.type === 'function') {
|
|
@@ -32,7 +33,7 @@ var rule = {
|
|
|
32
33
|
create: function create(context) {
|
|
33
34
|
return {
|
|
34
35
|
'CallExpression[callee.type="Identifier"]': function CallExpressionCalleeTypeIdentifier(node) {
|
|
35
|
-
if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && (0, _utils.isAPIimport)(node.callee.name, context) && !isInFunctionLevel(context)) {
|
|
36
|
+
if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && (0, _utils.isAPIimport)(node.callee.name, context, node) && !isInFunctionLevel(context, node)) {
|
|
36
37
|
context.report({
|
|
37
38
|
messageId: 'noModuleLevelEval',
|
|
38
39
|
node: node
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _contextCompat = require("../../util/context-compat");
|
|
7
8
|
var featureLibraryFunctions = new Set([
|
|
8
9
|
/*
|
|
9
10
|
* STOP!
|
|
@@ -16,8 +17,8 @@ var featureLibraryFunctions = new Set([
|
|
|
16
17
|
* Slack thread: https://atlassian.slack.com/archives/CFGLH1ZS8/p1726449739284819
|
|
17
18
|
*/
|
|
18
19
|
'isVisualRefreshEnabled', 'getMetaBoolean', 'getNav4Rollout', 'getWillShowNav3', 'getWillShowNav4', 'getWillShowNav4UserOptIn', 'getWillShowNav4UserOptOut']);
|
|
19
|
-
var isInFunctionLevel = function isInFunctionLevel(context) {
|
|
20
|
-
var scope =
|
|
20
|
+
var isInFunctionLevel = function isInFunctionLevel(context, node) {
|
|
21
|
+
var scope = (0, _contextCompat.getScope)(context, node);
|
|
21
22
|
while (((_scope = scope) === null || _scope === void 0 ? void 0 : _scope.type) !== 'module' && ((_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2.type) !== 'global') {
|
|
22
23
|
var _scope, _scope2;
|
|
23
24
|
if (scope.type === 'function') {
|
|
@@ -43,7 +44,7 @@ var rule = {
|
|
|
43
44
|
create: function create(context) {
|
|
44
45
|
return {
|
|
45
46
|
'CallExpression[callee.type="Identifier"]': function CallExpressionCalleeTypeIdentifier(node) {
|
|
46
|
-
if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && featureLibraryFunctions.has(node.callee.name) && !isInFunctionLevel(context)) {
|
|
47
|
+
if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && featureLibraryFunctions.has(node.callee.name) && !isInFunctionLevel(context, node)) {
|
|
47
48
|
context.report({
|
|
48
49
|
messageId: 'noModuleLevelEval',
|
|
49
50
|
node: node
|
|
@@ -20,7 +20,7 @@ var getGateType = function getGateType(node, context) {
|
|
|
20
20
|
var callee = node.callee;
|
|
21
21
|
var isFeatureGate = type === 'CallExpression' && callee.type === 'Identifier' && (
|
|
22
22
|
// Experiments cannot have other experiments as preconditions, only gates
|
|
23
|
-
callee.name === 'fg' || isExpUsage(callee.name)) && (0, _utils.isAPIimport)(callee.name, context);
|
|
23
|
+
callee.name === 'fg' || isExpUsage(callee.name)) && (0, _utils.isAPIimport)(callee.name, context, node);
|
|
24
24
|
return isFeatureGate ? callee.name : '';
|
|
25
25
|
}
|
|
26
26
|
return '';
|
|
@@ -9,13 +9,14 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _constants = require("../../constants");
|
|
12
|
+
var _contextCompat = require("../../util/context-compat");
|
|
12
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
15
|
var validateUsage = function validateUsage(node, utilName, context, changeMap) {
|
|
15
|
-
var
|
|
16
|
-
var resolved = (
|
|
16
|
+
var _getScope$references$;
|
|
17
|
+
var resolved = (_getScope$references$ = (0, _contextCompat.getScope)(context, node).references.find(function (ref) {
|
|
17
18
|
return ref.identifier.name === utilName;
|
|
18
|
-
})) === null ||
|
|
19
|
+
})) === null || _getScope$references$ === void 0 ? void 0 : _getScope$references$.resolved;
|
|
19
20
|
var importSpecifierDefinition = resolved === null || resolved === void 0 ? void 0 : resolved.defs.find(function (def) {
|
|
20
21
|
var _def$node, _def$parent;
|
|
21
22
|
return ((_def$node = def.node) === null || _def$node === void 0 ? void 0 : _def$node.type) === 'ImportSpecifier' && _constants.FEATURE_API_IMPORT_SOURCES.has((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.source.value);
|
|
@@ -72,12 +73,12 @@ var rule = {
|
|
|
72
73
|
changeMap = changeMap || new Map();
|
|
73
74
|
validateUsage(node, 'getBooleanFF', context, changeMap);
|
|
74
75
|
},
|
|
75
|
-
'Program:exit': function ProgramExit() {
|
|
76
|
+
'Program:exit': function ProgramExit(node) {
|
|
76
77
|
var _changeMap;
|
|
77
78
|
if ((_changeMap = changeMap) !== null && _changeMap !== void 0 && _changeMap.size) {
|
|
78
79
|
changeMap.forEach(function (changeCounts, importDeclaration) {
|
|
79
|
-
var
|
|
80
|
-
moduleScope =
|
|
80
|
+
var _getScope$childScopes = (0, _slicedToArray2.default)((0, _contextCompat.getScope)(context, node).childScopes, 1),
|
|
81
|
+
moduleScope = _getScope$childScopes[0];
|
|
81
82
|
var importSpecifiers = new Set(importDeclaration.specifiers.map(function (_ref) {
|
|
82
83
|
var imported = _ref.imported;
|
|
83
84
|
return imported.name;
|
|
@@ -33,12 +33,12 @@ var rule = {
|
|
|
33
33
|
if (node.type !== 'CallExpression') {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
if (node.callee.type === 'Identifier' && (!targetedFunctionsSwitch.has(node.callee.name) || !(0, _utils.isIdentifierImportedFrom)(node.callee.name, IMPORT_SOURCES, context))) {
|
|
36
|
+
if (node.callee.type === 'Identifier' && (!targetedFunctionsSwitch.has(node.callee.name) || !(0, _utils.isIdentifierImportedFrom)(node.callee.name, IMPORT_SOURCES, context, node))) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
var nameArgument = node.arguments[0];
|
|
40
40
|
if (nameArgument.type === 'Identifier') {
|
|
41
|
-
var def = (0, _utils.getDef)(nameArgument.name, context);
|
|
41
|
+
var def = (0, _utils.getDef)(nameArgument.name, context, node);
|
|
42
42
|
if (def != null && def.type === 'Variable') {
|
|
43
43
|
var _ref = def.node.init,
|
|
44
44
|
value = _ref.value;
|
|
@@ -21,7 +21,7 @@ var rule = {
|
|
|
21
21
|
create: function create(context) {
|
|
22
22
|
return {
|
|
23
23
|
'CallExpression > MemberExpression:matches([property.name="checkGate"])': function CallExpressionMemberExpressionMatchesPropertyNameCheckGate(node) {
|
|
24
|
-
if (node.object.type === 'Identifier' && (0, _utils.isIdentifierImportedFrom)(node.object.name, BANNED_IMPORTS_SET, context)) {
|
|
24
|
+
if (node.object.type === 'Identifier' && (0, _utils.isIdentifierImportedFrom)(node.object.name, BANNED_IMPORTS_SET, context, node)) {
|
|
25
25
|
context.report({
|
|
26
26
|
messageId: 'useRecommended',
|
|
27
27
|
node: node,
|
|
@@ -34,7 +34,7 @@ var rule = {
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
'CallExpression > MemberExpression:matches([property.name="getExperimentValue"])': function CallExpressionMemberExpressionMatchesPropertyNameGetExperimentValue(node) {
|
|
37
|
-
if (node.object.type === 'Identifier' && (0, _utils.isIdentifierImportedFrom)(node.object.name, BANNED_IMPORTS_SET, context)) {
|
|
37
|
+
if (node.object.type === 'Identifier' && (0, _utils.isIdentifierImportedFrom)(node.object.name, BANNED_IMPORTS_SET, context, node)) {
|
|
38
38
|
context.report({
|
|
39
39
|
messageId: 'notSupported',
|
|
40
40
|
node: node
|
|
@@ -7,28 +7,29 @@ exports.getDef = getDef;
|
|
|
7
7
|
exports.isAPIimport = isAPIimport;
|
|
8
8
|
exports.isIdentifierImportedFrom = isIdentifierImportedFrom;
|
|
9
9
|
var _constants = require("../constants");
|
|
10
|
+
var _contextCompat = require("../util/context-compat");
|
|
10
11
|
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; } } }; }
|
|
11
12
|
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; } }
|
|
12
13
|
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; }
|
|
13
|
-
function isIdentifierImportedFrom(identifierName, sources, context) {
|
|
14
|
+
function isIdentifierImportedFrom(identifierName, sources, context, node) {
|
|
14
15
|
if (sources.size > 0) {
|
|
15
|
-
var
|
|
16
|
-
return (
|
|
16
|
+
var _getScope$references$, _getScope$references$2;
|
|
17
|
+
return (_getScope$references$ = (_getScope$references$2 = (0, _contextCompat.getScope)(context, node).references.find(function (ref) {
|
|
17
18
|
return ref.identifier.name === identifierName;
|
|
18
|
-
})) === null ||
|
|
19
|
+
})) === null || _getScope$references$2 === void 0 || (_getScope$references$2 = _getScope$references$2.resolved) === null || _getScope$references$2 === void 0 ? void 0 : _getScope$references$2.defs.some(function (def) {
|
|
19
20
|
var _def$parent;
|
|
20
21
|
return ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.type) === 'ImportDeclaration' && sources.has(def.parent.source.value + '');
|
|
21
|
-
})) !== null &&
|
|
22
|
+
})) !== null && _getScope$references$ !== void 0 ? _getScope$references$ : false;
|
|
22
23
|
}
|
|
23
24
|
return false;
|
|
24
25
|
}
|
|
25
|
-
function isAPIimport(functionName, context) {
|
|
26
|
-
return isIdentifierImportedFrom(functionName, _constants.FEATURE_API_IMPORT_SOURCES, context);
|
|
26
|
+
function isAPIimport(functionName, context, node) {
|
|
27
|
+
return isIdentifierImportedFrom(functionName, _constants.FEATURE_API_IMPORT_SOURCES, context, node);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
// returns the definition node of a variable if it's declared within the scope of the file
|
|
30
|
-
function getDef(name, context) {
|
|
31
|
-
var scope =
|
|
31
|
+
function getDef(name, context, node) {
|
|
32
|
+
var scope = (0, _contextCompat.getScope)(context, node);
|
|
32
33
|
while (scope && scope.type !== 'global') {
|
|
33
34
|
var _iterator = _createForOfIteratorHelper(scope.variables),
|
|
34
35
|
_step;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getScope = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* TODO: Consider whether this should be replaced by ESLint's compat library.
|
|
9
|
+
* Either way, this should be removed once we no longer need to support ESLint versions less than 8.40.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A compatibility layer to support older versions of ESLint.
|
|
14
|
+
* `context.sourceCode` is the preferred way to access SourceCode, as
|
|
15
|
+
* `context.getSourceCode()` is deprecated in v8 and removed in v9.
|
|
16
|
+
* @param context - The ESLint rule context
|
|
17
|
+
*/
|
|
18
|
+
var getSourceCode = function getSourceCode(context) {
|
|
19
|
+
var _context$sourceCode;
|
|
20
|
+
return (_context$sourceCode = context.sourceCode) !== null && _context$sourceCode !== void 0 ? _context$sourceCode : context.getSourceCode();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A compatibility layer to support older versions of ESLint.
|
|
25
|
+
* `context.sourceCode.getScope()` is the preferred way to access Scope, as
|
|
26
|
+
* `context.getScope()` was removed in v9.
|
|
27
|
+
* @param context - The ESLint rule context
|
|
28
|
+
* @param node - The node to get the scope for
|
|
29
|
+
*/
|
|
30
|
+
var getScope = exports.getScope = function getScope(context, node) {
|
|
31
|
+
var _getSourceCode$getSco, _getSourceCode;
|
|
32
|
+
return (_getSourceCode$getSco = (_getSourceCode = getSourceCode(context)) === null || _getSourceCode === void 0 ? void 0 : _getSourceCode.getScope(node)) !== null && _getSourceCode$getSco !== void 0 ? _getSourceCode$getSco : context.getScope();
|
|
33
|
+
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -61,7 +61,7 @@ const commonConfig = {
|
|
|
61
61
|
'@atlaskit/platform/no-module-level-eval-nav4': 'error',
|
|
62
62
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
63
63
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
64
|
-
'@atlaskit/platform/expand-background-shorthand': '
|
|
64
|
+
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
65
65
|
'@compiled/jsx-pragma': ['error', {
|
|
66
66
|
importSources: ['@atlaskit/css'],
|
|
67
67
|
onlyRunIfImportingCompiled: true,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { getImportSources, isCompiled, isAtlasKitCSS } from '@atlaskit/eslint-utils/is-supported-import';
|
|
2
|
+
import { getScope } from '../../util/context-compat';
|
|
2
3
|
|
|
3
4
|
// Checks if the function that holds the border property is using an import package that this rule is targeting
|
|
4
|
-
const isCompiledAPI = context => {
|
|
5
|
+
const isCompiledAPI = (context, node) => {
|
|
5
6
|
const importSources = getImportSources(context);
|
|
6
7
|
const {
|
|
7
8
|
references
|
|
8
|
-
} =
|
|
9
|
+
} = getScope(context, node);
|
|
9
10
|
const ancestors = context.getAncestors();
|
|
10
11
|
if (ancestors.some(ancestor => ancestor.type === 'CallExpression' && ancestor.callee && (isCompiled(ancestor.callee, references, importSources) || isAtlasKitCSS(ancestor.callee, references, importSources)))) {
|
|
11
12
|
return true;
|
|
@@ -36,7 +37,7 @@ export const expandBackgroundShorthand = {
|
|
|
36
37
|
create(context) {
|
|
37
38
|
return {
|
|
38
39
|
'Property[key.name="background"]': function (node) {
|
|
39
|
-
if (isCompiledAPI(context) && isTokenCallExpression(node.value)) {
|
|
40
|
+
if (isCompiledAPI(context, node) && isTokenCallExpression(node.value)) {
|
|
40
41
|
context.report({
|
|
41
42
|
node,
|
|
42
43
|
messageId: 'expandBackgroundShorthand',
|
|
@@ -44,7 +45,6 @@ export const expandBackgroundShorthand = {
|
|
|
44
45
|
return fixer.replaceText(node.key, `backgroundColor`);
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
|
-
return;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
};
|
|
@@ -7,7 +7,7 @@ const validateCallExpression = (node, context) => {
|
|
|
7
7
|
const {
|
|
8
8
|
callee
|
|
9
9
|
} = node;
|
|
10
|
-
const shouldWarn = callee.type === 'Identifier' && targetedFunctionsSwitch.has(callee.name) && isAPIimport(callee.name, context);
|
|
10
|
+
const shouldWarn = callee.type === 'Identifier' && targetedFunctionsSwitch.has(callee.name) && isAPIimport(callee.name, context, node);
|
|
11
11
|
if (shouldWarn) {
|
|
12
12
|
const defDeclaration = findDefinitionDeclaration(node.parent);
|
|
13
13
|
context.report({
|
|
@@ -44,7 +44,7 @@ const rule = {
|
|
|
44
44
|
if (!node.init || node.init.type !== 'Identifier') {
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
const isReassignment = isIdentifierImportedFrom(node.init.name, IMPORT_SOURCES, context);
|
|
47
|
+
const isReassignment = isIdentifierImportedFrom(node.init.name, IMPORT_SOURCES, context, node);
|
|
48
48
|
if (isReassignment) {
|
|
49
49
|
context.report({
|
|
50
50
|
messageId: 'noReassignment',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isAPIimport } from '../utils';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { getScope } from '../../util/context-compat';
|
|
3
|
+
const isInFunctionLevel = (context, node) => {
|
|
4
|
+
let scope = getScope(context, node);
|
|
4
5
|
while (((_scope = scope) === null || _scope === void 0 ? void 0 : _scope.type) !== 'module' && ((_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2.type) !== 'global') {
|
|
5
6
|
var _scope, _scope2;
|
|
6
7
|
if (scope.type === 'function') {
|
|
@@ -26,7 +27,7 @@ const rule = {
|
|
|
26
27
|
create(context) {
|
|
27
28
|
return {
|
|
28
29
|
'CallExpression[callee.type="Identifier"]': node => {
|
|
29
|
-
if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && isAPIimport(node.callee.name, context) && !isInFunctionLevel(context)) {
|
|
30
|
+
if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && isAPIimport(node.callee.name, context, node) && !isInFunctionLevel(context, node)) {
|
|
30
31
|
context.report({
|
|
31
32
|
messageId: 'noModuleLevelEval',
|
|
32
33
|
node
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getScope } from '../../util/context-compat';
|
|
1
2
|
const featureLibraryFunctions = new Set([
|
|
2
3
|
/*
|
|
3
4
|
* STOP!
|
|
@@ -10,8 +11,8 @@ const featureLibraryFunctions = new Set([
|
|
|
10
11
|
* Slack thread: https://atlassian.slack.com/archives/CFGLH1ZS8/p1726449739284819
|
|
11
12
|
*/
|
|
12
13
|
'isVisualRefreshEnabled', 'getMetaBoolean', 'getNav4Rollout', 'getWillShowNav3', 'getWillShowNav4', 'getWillShowNav4UserOptIn', 'getWillShowNav4UserOptOut']);
|
|
13
|
-
const isInFunctionLevel = context => {
|
|
14
|
-
let scope =
|
|
14
|
+
const isInFunctionLevel = (context, node) => {
|
|
15
|
+
let scope = getScope(context, node);
|
|
15
16
|
while (((_scope = scope) === null || _scope === void 0 ? void 0 : _scope.type) !== 'module' && ((_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2.type) !== 'global') {
|
|
16
17
|
var _scope, _scope2;
|
|
17
18
|
if (scope.type === 'function') {
|
|
@@ -37,7 +38,7 @@ const rule = {
|
|
|
37
38
|
create(context) {
|
|
38
39
|
return {
|
|
39
40
|
'CallExpression[callee.type="Identifier"]': node => {
|
|
40
|
-
if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && featureLibraryFunctions.has(node.callee.name) && !isInFunctionLevel(context)) {
|
|
41
|
+
if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && featureLibraryFunctions.has(node.callee.name) && !isInFunctionLevel(context, node)) {
|
|
41
42
|
context.report({
|
|
42
43
|
messageId: 'noModuleLevelEval',
|
|
43
44
|
node
|
|
@@ -14,7 +14,7 @@ const getGateType = (node, context) => {
|
|
|
14
14
|
} = node;
|
|
15
15
|
const isFeatureGate = type === 'CallExpression' && callee.type === 'Identifier' && (
|
|
16
16
|
// Experiments cannot have other experiments as preconditions, only gates
|
|
17
|
-
callee.name === 'fg' || isExpUsage(callee.name)) && isAPIimport(callee.name, context);
|
|
17
|
+
callee.name === 'fg' || isExpUsage(callee.name)) && isAPIimport(callee.name, context, node);
|
|
18
18
|
return isFeatureGate ? callee.name : '';
|
|
19
19
|
}
|
|
20
20
|
return '';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FEATURE_API_IMPORT_SOURCES } from '../../constants';
|
|
2
|
+
import { getScope } from '../../util/context-compat';
|
|
2
3
|
const validateUsage = (node, utilName, context, changeMap) => {
|
|
3
|
-
var
|
|
4
|
-
const resolved = (
|
|
4
|
+
var _getScope$references$;
|
|
5
|
+
const resolved = (_getScope$references$ = getScope(context, node).references.find(ref => ref.identifier.name === utilName)) === null || _getScope$references$ === void 0 ? void 0 : _getScope$references$.resolved;
|
|
5
6
|
const importSpecifierDefinition = resolved === null || resolved === void 0 ? void 0 : resolved.defs.find(def => {
|
|
6
7
|
var _def$node, _def$parent;
|
|
7
8
|
return ((_def$node = def.node) === null || _def$node === void 0 ? void 0 : _def$node.type) === 'ImportSpecifier' && FEATURE_API_IMPORT_SOURCES.has((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.source.value);
|
|
@@ -51,11 +52,11 @@ const rule = {
|
|
|
51
52
|
changeMap = changeMap || new Map();
|
|
52
53
|
validateUsage(node, 'getBooleanFF', context, changeMap);
|
|
53
54
|
},
|
|
54
|
-
'Program:exit':
|
|
55
|
+
'Program:exit': node => {
|
|
55
56
|
var _changeMap;
|
|
56
57
|
if ((_changeMap = changeMap) !== null && _changeMap !== void 0 && _changeMap.size) {
|
|
57
58
|
changeMap.forEach((changeCounts, importDeclaration) => {
|
|
58
|
-
const [moduleScope] =
|
|
59
|
+
const [moduleScope] = getScope(context, node).childScopes;
|
|
59
60
|
const importSpecifiers = new Set(importDeclaration.specifiers.map(({
|
|
60
61
|
imported
|
|
61
62
|
}) => imported.name));
|
|
@@ -25,12 +25,12 @@ const rule = {
|
|
|
25
25
|
if (node.type !== 'CallExpression') {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
if (node.callee.type === 'Identifier' && (!targetedFunctionsSwitch.has(node.callee.name) || !isIdentifierImportedFrom(node.callee.name, IMPORT_SOURCES, context))) {
|
|
28
|
+
if (node.callee.type === 'Identifier' && (!targetedFunctionsSwitch.has(node.callee.name) || !isIdentifierImportedFrom(node.callee.name, IMPORT_SOURCES, context, node))) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
const nameArgument = node.arguments[0];
|
|
32
32
|
if (nameArgument.type === 'Identifier') {
|
|
33
|
-
const def = getDef(nameArgument.name, context);
|
|
33
|
+
const def = getDef(nameArgument.name, context, node);
|
|
34
34
|
if (def != null && def.type === 'Variable') {
|
|
35
35
|
const {
|
|
36
36
|
value
|
|
@@ -15,7 +15,7 @@ const rule = {
|
|
|
15
15
|
create(context) {
|
|
16
16
|
return {
|
|
17
17
|
'CallExpression > MemberExpression:matches([property.name="checkGate"])': node => {
|
|
18
|
-
if (node.object.type === 'Identifier' && isIdentifierImportedFrom(node.object.name, BANNED_IMPORTS_SET, context)) {
|
|
18
|
+
if (node.object.type === 'Identifier' && isIdentifierImportedFrom(node.object.name, BANNED_IMPORTS_SET, context, node)) {
|
|
19
19
|
context.report({
|
|
20
20
|
messageId: 'useRecommended',
|
|
21
21
|
node,
|
|
@@ -28,7 +28,7 @@ const rule = {
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
'CallExpression > MemberExpression:matches([property.name="getExperimentValue"])': node => {
|
|
31
|
-
if (node.object.type === 'Identifier' && isIdentifierImportedFrom(node.object.name, BANNED_IMPORTS_SET, context)) {
|
|
31
|
+
if (node.object.type === 'Identifier' && isIdentifierImportedFrom(node.object.name, BANNED_IMPORTS_SET, context, node)) {
|
|
32
32
|
context.report({
|
|
33
33
|
messageId: 'notSupported',
|
|
34
34
|
node
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { FEATURE_API_IMPORT_SOURCES } from '../constants';
|
|
2
|
-
|
|
2
|
+
import { getScope } from '../util/context-compat';
|
|
3
|
+
export function isIdentifierImportedFrom(identifierName, sources, context, node) {
|
|
3
4
|
if (sources.size > 0) {
|
|
4
|
-
var
|
|
5
|
-
return (
|
|
5
|
+
var _getScope$references$, _getScope$references$2, _getScope$references$3;
|
|
6
|
+
return (_getScope$references$ = (_getScope$references$2 = getScope(context, node).references.find(ref => ref.identifier.name === identifierName)) === null || _getScope$references$2 === void 0 ? void 0 : (_getScope$references$3 = _getScope$references$2.resolved) === null || _getScope$references$3 === void 0 ? void 0 : _getScope$references$3.defs.some(def => {
|
|
6
7
|
var _def$parent;
|
|
7
8
|
return ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.type) === 'ImportDeclaration' && sources.has(def.parent.source.value + '');
|
|
8
|
-
})) !== null &&
|
|
9
|
+
})) !== null && _getScope$references$ !== void 0 ? _getScope$references$ : false;
|
|
9
10
|
}
|
|
10
11
|
return false;
|
|
11
12
|
}
|
|
12
|
-
export function isAPIimport(functionName, context) {
|
|
13
|
-
return isIdentifierImportedFrom(functionName, FEATURE_API_IMPORT_SOURCES, context);
|
|
13
|
+
export function isAPIimport(functionName, context, node) {
|
|
14
|
+
return isIdentifierImportedFrom(functionName, FEATURE_API_IMPORT_SOURCES, context, node);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
// returns the definition node of a variable if it's declared within the scope of the file
|
|
17
|
-
export function getDef(name, context) {
|
|
18
|
-
let scope =
|
|
18
|
+
export function getDef(name, context, node) {
|
|
19
|
+
let scope = getScope(context, node);
|
|
19
20
|
while (scope && scope.type !== 'global') {
|
|
20
21
|
for (const variable of scope.variables) {
|
|
21
22
|
if (variable.name === name) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TODO: Consider whether this should be replaced by ESLint's compat library.
|
|
3
|
+
* Either way, this should be removed once we no longer need to support ESLint versions less than 8.40.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A compatibility layer to support older versions of ESLint.
|
|
8
|
+
* `context.sourceCode` is the preferred way to access SourceCode, as
|
|
9
|
+
* `context.getSourceCode()` is deprecated in v8 and removed in v9.
|
|
10
|
+
* @param context - The ESLint rule context
|
|
11
|
+
*/
|
|
12
|
+
const getSourceCode = context => {
|
|
13
|
+
var _context$sourceCode;
|
|
14
|
+
return (_context$sourceCode = context.sourceCode) !== null && _context$sourceCode !== void 0 ? _context$sourceCode : context.getSourceCode();
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A compatibility layer to support older versions of ESLint.
|
|
19
|
+
* `context.sourceCode.getScope()` is the preferred way to access Scope, as
|
|
20
|
+
* `context.getScope()` was removed in v9.
|
|
21
|
+
* @param context - The ESLint rule context
|
|
22
|
+
* @param node - The node to get the scope for
|
|
23
|
+
*/
|
|
24
|
+
export const getScope = (context, node) => {
|
|
25
|
+
var _getSourceCode$getSco, _getSourceCode;
|
|
26
|
+
return (_getSourceCode$getSco = (_getSourceCode = getSourceCode(context)) === null || _getSourceCode === void 0 ? void 0 : _getSourceCode.getScope(node)) !== null && _getSourceCode$getSco !== void 0 ? _getSourceCode$getSco : context.getScope();
|
|
27
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -64,7 +64,7 @@ var commonConfig = {
|
|
|
64
64
|
'@atlaskit/platform/no-module-level-eval-nav4': 'error',
|
|
65
65
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
66
66
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
67
|
-
'@atlaskit/platform/expand-background-shorthand': '
|
|
67
|
+
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
68
68
|
'@compiled/jsx-pragma': ['error', {
|
|
69
69
|
importSources: ['@atlaskit/css'],
|
|
70
70
|
onlyRunIfImportingCompiled: true,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getImportSources, isCompiled, isAtlasKitCSS } from '@atlaskit/eslint-utils/is-supported-import';
|
|
2
|
+
import { getScope } from '../../util/context-compat';
|
|
2
3
|
|
|
3
4
|
// Checks if the function that holds the border property is using an import package that this rule is targeting
|
|
4
|
-
var isCompiledAPI = function isCompiledAPI(context) {
|
|
5
|
+
var isCompiledAPI = function isCompiledAPI(context, node) {
|
|
5
6
|
var importSources = getImportSources(context);
|
|
6
|
-
var
|
|
7
|
-
references =
|
|
7
|
+
var _getScope = getScope(context, node),
|
|
8
|
+
references = _getScope.references;
|
|
8
9
|
var ancestors = context.getAncestors();
|
|
9
10
|
if (ancestors.some(function (ancestor) {
|
|
10
11
|
return ancestor.type === 'CallExpression' && ancestor.callee && (isCompiled(ancestor.callee, references, importSources) || isAtlasKitCSS(ancestor.callee, references, importSources));
|
|
@@ -37,7 +38,7 @@ export var expandBackgroundShorthand = {
|
|
|
37
38
|
create: function create(context) {
|
|
38
39
|
return {
|
|
39
40
|
'Property[key.name="background"]': function PropertyKeyNameBackground(node) {
|
|
40
|
-
if (isCompiledAPI(context) && isTokenCallExpression(node.value)) {
|
|
41
|
+
if (isCompiledAPI(context, node) && isTokenCallExpression(node.value)) {
|
|
41
42
|
context.report({
|
|
42
43
|
node: node,
|
|
43
44
|
messageId: 'expandBackgroundShorthand',
|
|
@@ -45,7 +46,6 @@ export var expandBackgroundShorthand = {
|
|
|
45
46
|
return fixer.replaceText(node.key, "backgroundColor");
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
|
-
return;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
};
|
|
@@ -8,7 +8,7 @@ var findDefinitionDeclaration = function findDefinitionDeclaration(node) {
|
|
|
8
8
|
var validateCallExpression = function validateCallExpression(node, context) {
|
|
9
9
|
var targetedFunctionsSwitch = context.options[0] === 'ssOnly' ? STATSIG_ONLY_FUNCTION_NAMES : FUNCTION_NAMES;
|
|
10
10
|
var callee = node.callee;
|
|
11
|
-
var shouldWarn = callee.type === 'Identifier' && targetedFunctionsSwitch.has(callee.name) && isAPIimport(callee.name, context);
|
|
11
|
+
var shouldWarn = callee.type === 'Identifier' && targetedFunctionsSwitch.has(callee.name) && isAPIimport(callee.name, context, node);
|
|
12
12
|
if (shouldWarn) {
|
|
13
13
|
var defDeclaration = findDefinitionDeclaration(node.parent);
|
|
14
14
|
context.report({
|
|
@@ -43,7 +43,7 @@ var rule = {
|
|
|
43
43
|
if (!node.init || node.init.type !== 'Identifier') {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
var isReassignment = isIdentifierImportedFrom(node.init.name, IMPORT_SOURCES, context);
|
|
46
|
+
var isReassignment = isIdentifierImportedFrom(node.init.name, IMPORT_SOURCES, context, node);
|
|
47
47
|
if (isReassignment) {
|
|
48
48
|
context.report({
|
|
49
49
|
messageId: 'noReassignment',
|