@atlaskit/eslint-plugin-design-system 13.19.3 → 13.19.5
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 +14 -0
- package/dist/cjs/ast-nodes/import.js +1 -1
- package/dist/cjs/rules/enforce-inline-styles-in-select/utils.js +9 -2
- package/dist/cjs/rules/ensure-design-token-usage/utils.js +1 -1
- package/dist/cjs/rules/ensure-proper-xcss-usage/index.js +5 -3
- package/dist/cjs/rules/no-deprecated-imports/checks.js +2 -2
- package/dist/cjs/rules/no-html-anchor/node-types/jsx-element/index.js +1 -1
- package/dist/cjs/rules/no-html-code/node-types/jsx-element/index.js +1 -1
- package/dist/cjs/rules/no-invalid-css-map/utils.js +1 -0
- package/dist/cjs/rules/no-legacy-icons/checks.js +10 -8
- package/dist/cjs/rules/no-nested-styles/index.js +1 -1
- package/dist/cjs/rules/no-separator-with-list-elements/index.js +1 -1
- package/dist/cjs/rules/use-button-group-label/index.js +3 -2
- package/dist/cjs/rules/use-correct-field/index.js +2 -2
- package/dist/cjs/rules/use-cx-function-in-xcss/index.js +1 -1
- package/dist/cjs/rules/use-datetime-picker-calendar-button/index.js +7 -5
- package/dist/cjs/rules/use-menu-section-title/index.js +3 -2
- package/dist/cjs/rules/use-modal-dialog-close-button/index.js +43 -11
- package/dist/cjs/rules/use-onboarding-spotlight-label/index.js +3 -2
- package/dist/cjs/rules/use-should-render-to-parent/index.js +1 -1
- package/dist/cjs/rules/use-tokens-typography/transformers/style-object.js +1 -1
- package/dist/cjs/rules/use-visually-hidden/index.js +1 -1
- package/dist/cjs/rules/utils/create-no-exported-rule/is-styled-component.js +1 -1
- package/dist/cjs/rules/utils/get-import-name.js +2 -3
- package/dist/cjs/rules/utils/get-import-node-by-source.js +1 -1
- package/dist/es2019/ast-nodes/import.js +1 -1
- package/dist/es2019/rules/enforce-inline-styles-in-select/utils.js +9 -2
- package/dist/es2019/rules/ensure-design-token-usage/utils.js +1 -1
- package/dist/es2019/rules/ensure-proper-xcss-usage/index.js +5 -3
- package/dist/es2019/rules/no-deprecated-imports/checks.js +2 -2
- package/dist/es2019/rules/no-html-anchor/node-types/jsx-element/index.js +1 -1
- package/dist/es2019/rules/no-html-code/node-types/jsx-element/index.js +1 -1
- package/dist/es2019/rules/no-invalid-css-map/utils.js +1 -0
- package/dist/es2019/rules/no-legacy-icons/checks.js +10 -8
- package/dist/es2019/rules/no-nested-styles/index.js +1 -1
- package/dist/es2019/rules/no-separator-with-list-elements/index.js +1 -1
- package/dist/es2019/rules/use-button-group-label/index.js +3 -2
- package/dist/es2019/rules/use-correct-field/index.js +2 -2
- package/dist/es2019/rules/use-cx-function-in-xcss/index.js +1 -1
- package/dist/es2019/rules/use-datetime-picker-calendar-button/index.js +9 -7
- package/dist/es2019/rules/use-menu-section-title/index.js +3 -2
- package/dist/es2019/rules/use-modal-dialog-close-button/index.js +36 -10
- package/dist/es2019/rules/use-onboarding-spotlight-label/index.js +3 -2
- package/dist/es2019/rules/use-should-render-to-parent/index.js +1 -1
- package/dist/es2019/rules/use-tokens-typography/transformers/style-object.js +1 -1
- package/dist/es2019/rules/use-visually-hidden/index.js +1 -1
- package/dist/es2019/rules/utils/create-no-exported-rule/is-styled-component.js +1 -1
- package/dist/es2019/rules/utils/get-import-name.js +2 -3
- package/dist/es2019/rules/utils/get-import-node-by-source.js +1 -1
- package/dist/esm/ast-nodes/import.js +1 -1
- package/dist/esm/rules/enforce-inline-styles-in-select/utils.js +9 -2
- package/dist/esm/rules/ensure-design-token-usage/utils.js +1 -1
- package/dist/esm/rules/ensure-proper-xcss-usage/index.js +5 -3
- package/dist/esm/rules/no-deprecated-imports/checks.js +2 -2
- package/dist/esm/rules/no-html-anchor/node-types/jsx-element/index.js +1 -1
- package/dist/esm/rules/no-html-code/node-types/jsx-element/index.js +1 -1
- package/dist/esm/rules/no-invalid-css-map/utils.js +1 -0
- package/dist/esm/rules/no-legacy-icons/checks.js +10 -8
- package/dist/esm/rules/no-nested-styles/index.js +1 -1
- package/dist/esm/rules/no-separator-with-list-elements/index.js +1 -1
- package/dist/esm/rules/use-button-group-label/index.js +3 -2
- package/dist/esm/rules/use-correct-field/index.js +2 -2
- package/dist/esm/rules/use-cx-function-in-xcss/index.js +1 -1
- package/dist/esm/rules/use-datetime-picker-calendar-button/index.js +7 -5
- package/dist/esm/rules/use-menu-section-title/index.js +3 -2
- package/dist/esm/rules/use-modal-dialog-close-button/index.js +43 -11
- package/dist/esm/rules/use-onboarding-spotlight-label/index.js +3 -2
- package/dist/esm/rules/use-should-render-to-parent/index.js +1 -1
- package/dist/esm/rules/use-tokens-typography/transformers/style-object.js +1 -1
- package/dist/esm/rules/use-visually-hidden/index.js +1 -1
- package/dist/esm/rules/utils/create-no-exported-rule/is-styled-component.js +1 -1
- package/dist/esm/rules/utils/get-import-name.js +2 -3
- package/dist/esm/rules/utils/get-import-node-by-source.js +1 -1
- package/dist/types/ast-nodes/function-call.d.ts +2 -2
- package/dist/types/ast-nodes/jsx-attribute.d.ts +3 -3
- package/dist/types/ast-nodes/jsx-element.d.ts +1 -1
- package/dist/types/ast-nodes/object-entry.d.ts +2 -2
- package/dist/types/ast-nodes/object.d.ts +2 -2
- package/dist/types/ast-nodes/root.d.ts +0 -1
- package/dist/types/rules/no-legacy-icons/helpers.d.ts +12 -12
- package/dist/types/rules/use-primitives-text/transformers/paragraph-elements.d.ts +1 -1
- package/dist/types/rules/use-visually-hidden/utils.d.ts +1 -1
- package/dist/types/rules/utils/create-no-exported-rule/main.d.ts +1 -1
- package/dist/types/rules/utils/create-no-tagged-template-expression-rule/index.d.ts +1 -1
- package/dist/types/rules/utils/create-rule.d.ts +1 -1
- package/dist/types/rules/utils/get-is-exception.d.ts +1 -1
- package/dist/types/rules/utils/is-node.d.ts +2 -2
- package/dist/types-ts4.5/ast-nodes/function-call.d.ts +2 -2
- package/dist/types-ts4.5/ast-nodes/jsx-attribute.d.ts +3 -3
- package/dist/types-ts4.5/ast-nodes/jsx-element.d.ts +1 -1
- package/dist/types-ts4.5/ast-nodes/object-entry.d.ts +2 -2
- package/dist/types-ts4.5/ast-nodes/object.d.ts +2 -2
- package/dist/types-ts4.5/ast-nodes/root.d.ts +0 -1
- package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +12 -12
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/paragraph-elements.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-visually-hidden/utils.d.ts +1 -1
- package/dist/types-ts4.5/rules/utils/create-no-exported-rule/main.d.ts +1 -1
- package/dist/types-ts4.5/rules/utils/create-no-tagged-template-expression-rule/index.d.ts +1 -1
- package/dist/types-ts4.5/rules/utils/create-rule.d.ts +1 -1
- package/dist/types-ts4.5/rules/utils/get-is-exception.d.ts +1 -1
- package/dist/types-ts4.5/rules/utils/is-node.d.ts +2 -2
- package/package.json +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 13.19.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 13.19.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#198800](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/198800)
|
|
14
|
+
[`b57fbbece226f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b57fbbece226f) -
|
|
15
|
+
Fixed some false positives in @atlaskit/design-system/use-modal-dialog-close-button ESLint rule
|
|
16
|
+
|
|
3
17
|
## 13.19.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -43,7 +43,7 @@ var Import = exports.Import = {
|
|
|
43
43
|
if (!(0, _eslintCodemodUtils.isNodeOfType)(specifier, 'ImportSpecifier')) {
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
46
|
-
return specifier.imported.name === name;
|
|
46
|
+
return specifier.imported.type === 'Identifier' && specifier.imported.name === name;
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
};
|
|
@@ -5,6 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.checkStylesObject = checkStylesObject;
|
|
7
7
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var getScope = function getScope(context, node) {
|
|
9
|
+
if ('getScope' in context.sourceCode) {
|
|
10
|
+
return context.sourceCode.getScope(node);
|
|
11
|
+
}
|
|
12
|
+
// this is needed for jira's eslint update, as otherwise there is type errors only in jira typechecking
|
|
13
|
+
return context.getScope(node);
|
|
14
|
+
};
|
|
8
15
|
var unsupportedSelectors = [':',
|
|
9
16
|
// pseudo-classes/elements
|
|
10
17
|
'[',
|
|
@@ -91,7 +98,7 @@ function checkSpreadElement(node, spreadElement, context) {
|
|
|
91
98
|
|
|
92
99
|
// Handle direct identifier (e.g., ...styles)
|
|
93
100
|
if ((0, _eslintCodemodUtils.isNodeOfType)(argument, 'Identifier')) {
|
|
94
|
-
var scope =
|
|
101
|
+
var scope = getScope(context, argument);
|
|
95
102
|
var variable = null;
|
|
96
103
|
var currentScope = scope;
|
|
97
104
|
|
|
@@ -210,7 +217,7 @@ function checkStylesObject(node, stylesValue, context) {
|
|
|
210
217
|
});
|
|
211
218
|
} else if ((0, _eslintCodemodUtils.isNodeOfType)(stylesValue, 'Identifier')) {
|
|
212
219
|
// track the variable
|
|
213
|
-
var scope =
|
|
220
|
+
var scope = getScope(context, stylesValue);
|
|
214
221
|
var variable = null;
|
|
215
222
|
var currentScope = scope;
|
|
216
223
|
|
|
@@ -169,7 +169,7 @@ var getValueFromIdentifier = function getValueFromIdentifier(node, context) {
|
|
|
169
169
|
}
|
|
170
170
|
var definition = variable.defs[0];
|
|
171
171
|
if ((0, _eslintCodemodUtils.isNodeOfType)(definition.node, 'ImportSpecifier') && (0, _eslintCodemodUtils.isNodeOfType)(definition.node.parent, 'ImportDeclaration') && definition.node.parent.source.value === '@atlassian/jira-common-styles/src/main.tsx') {
|
|
172
|
-
return definition.node.imported.name === 'gridSize' ? 8 : null;
|
|
172
|
+
return definition.node.imported.type === 'Identifier' && definition.node.imported.name === 'gridSize' ? 8 : null;
|
|
173
173
|
}
|
|
174
174
|
if (!(0, _eslintCodemodUtils.isNodeOfType)(definition.node, 'VariableDeclarator')) {
|
|
175
175
|
return null;
|
|
@@ -43,16 +43,18 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
43
43
|
// Handle different import sources
|
|
44
44
|
switch (source) {
|
|
45
45
|
case '@atlaskit/primitives/compiled':
|
|
46
|
-
|
|
46
|
+
if (specifier.imported.type === 'Identifier') {
|
|
47
|
+
tracker.compiledComponents.add(specifier.imported.name);
|
|
48
|
+
}
|
|
47
49
|
break;
|
|
48
50
|
case '@atlaskit/primitives':
|
|
49
|
-
if (specifier.imported.name === 'xcss') {
|
|
51
|
+
if (specifier.imported.type === 'Identifier' && specifier.imported.name === 'xcss') {
|
|
50
52
|
tracker.xcssFunction.add(specifier.local.name);
|
|
51
53
|
}
|
|
52
54
|
break;
|
|
53
55
|
case '@atlaskit/css':
|
|
54
56
|
case '@compiled/react':
|
|
55
|
-
if (specifier.imported.name === 'cssMap') {
|
|
57
|
+
if (specifier.imported.type === 'Identifier' && specifier.imported.name === 'cssMap') {
|
|
56
58
|
tracker.cssMapFunction.add(specifier.local.name);
|
|
57
59
|
}
|
|
58
60
|
break;
|
|
@@ -120,7 +120,7 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
120
120
|
} else if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
121
121
|
name = '*';
|
|
122
122
|
} else if (specifier.type === 'ImportSpecifier') {
|
|
123
|
-
name = specifier.imported.name;
|
|
123
|
+
name = specifier.imported.type === 'Identifier' ? specifier.imported.name : '';
|
|
124
124
|
}
|
|
125
125
|
if (name) {
|
|
126
126
|
importNames.set(name, specifier);
|
|
@@ -160,7 +160,7 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
160
160
|
var specifier = _step2.value;
|
|
161
161
|
var name = void 0;
|
|
162
162
|
if (specifier.local) {
|
|
163
|
-
name = specifier.local.name;
|
|
163
|
+
name = specifier.local.type === 'Identifier' ? specifier.local.name : '';
|
|
164
164
|
}
|
|
165
165
|
if (name) {
|
|
166
166
|
importNames.set(name, specifier);
|
|
@@ -55,7 +55,7 @@ var JSXElement = exports.JSXElement = {
|
|
|
55
55
|
}
|
|
56
56
|
} else if (declaration.source.value === '@atlaskit/button/new') {
|
|
57
57
|
var namedSpecifier = declaration.specifiers.find(function (specifier) {
|
|
58
|
-
return specifier.type === 'ImportSpecifier' && specifier.imported.name === 'LinkButton';
|
|
58
|
+
return specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier' && specifier.imported.name === 'LinkButton';
|
|
59
59
|
});
|
|
60
60
|
if (namedSpecifier) {
|
|
61
61
|
existingLinkButtonName = namedSpecifier.local.name;
|
|
@@ -50,7 +50,7 @@ var JSXElement = exports.JSXElement = {
|
|
|
50
50
|
declaration.specifiers.filter(function (specifier) {
|
|
51
51
|
return (0, _eslintCodemodUtils.isNodeOfType)(specifier, 'ImportSpecifier') && (0, _eslintCodemodUtils.isNodeOfType)(specifier.parent, 'ImportDeclaration');
|
|
52
52
|
}).forEach(function (specifier) {
|
|
53
|
-
if ((0, _eslintCodemodUtils.isNodeOfType)(specifier, 'ImportSpecifier') && specifier.imported.name === 'Code') {
|
|
53
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(specifier, 'ImportSpecifier') && specifier.imported.type === 'Identifier' && specifier.imported.name === 'Code') {
|
|
54
54
|
existingCodeName = specifier.local.name;
|
|
55
55
|
}
|
|
56
56
|
});
|
|
@@ -65,6 +65,7 @@ var CssMapObjectChecker = exports.CssMapObjectChecker = /*#__PURE__*/function ()
|
|
|
65
65
|
messageId: 'noInlineFunctions'
|
|
66
66
|
});
|
|
67
67
|
} else if (value.type === 'BinaryExpression' || value.type === 'LogicalExpression') {
|
|
68
|
+
// @ts-ignore -- this needs to be `ts-ignore` because this only errors in jira's typechecking due to update, not platform's
|
|
68
69
|
this.checkCssMapObjectValue(value.left);
|
|
69
70
|
this.checkCssMapObjectValue(value.right);
|
|
70
71
|
} else if (value.type === 'Identifier') {
|
|
@@ -89,7 +89,7 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
89
89
|
var _spec = _step2.value;
|
|
90
90
|
if (_spec.type === 'ImportDefaultSpecifier') {
|
|
91
91
|
newButtonImports.add(_spec.local.name);
|
|
92
|
-
} else if (_spec.type === 'ImportSpecifier' && _spec.imported.name === 'IconButton') {
|
|
92
|
+
} else if (_spec.type === 'ImportSpecifier' && 'name' in _spec.imported && _spec.imported.name === 'IconButton') {
|
|
93
93
|
newButtonImports.add(_spec.local.name);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -192,12 +192,14 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
192
192
|
try {
|
|
193
193
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
194
194
|
var spec = _step5.value;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
195
|
+
if ('name' in spec.exported) {
|
|
196
|
+
(0, _helpers.createCantMigrateReExportError)(spec, moduleSource, spec.exported.name, errorsManual);
|
|
197
|
+
(0, _helpers.addToListOfRanges)(spec, errorRanges);
|
|
198
|
+
guidance[(0, _helpers.locToString)(spec)] = (0, _helpers.createGuidance)({
|
|
199
|
+
iconPackage: moduleSource,
|
|
200
|
+
shouldUseMigrationPath: shouldUseMigrationPath
|
|
201
|
+
});
|
|
202
|
+
}
|
|
201
203
|
}
|
|
202
204
|
} catch (err) {
|
|
203
205
|
_iterator5.e(err);
|
|
@@ -238,7 +240,7 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
238
240
|
try {
|
|
239
241
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
240
242
|
var _spec3 = _step7.value;
|
|
241
|
-
if (Object.keys(legacyIconImports).includes(_spec3.local.name)) {
|
|
243
|
+
if ('name' in _spec3.local && 'name' in _spec3.exported && Object.keys(legacyIconImports).includes(_spec3.local.name)) {
|
|
242
244
|
//update legacy imports to be exported
|
|
243
245
|
legacyIconImports[_spec3.local.name] = {
|
|
244
246
|
packageName: legacyIconImports[_spec3.local.name].packageName,
|
|
@@ -31,7 +31,7 @@ var isMediaObject = function isMediaObject(node, context) {
|
|
|
31
31
|
// Make sure it's coming from the primitives packages and isn't a bootleg media query or worse: nested styles
|
|
32
32
|
if ((0, _eslintCodemodUtils.isNodeOfType)(definition.node, 'ImportSpecifier') && definition.node.parent && (0, _eslintCodemodUtils.isNodeOfType)(definition.node.parent, 'ImportDeclaration') && allowedResponsiveImports.includes(definition.node.parent.source.value)) {
|
|
33
33
|
// This should match the name of the media object exported from packages/design-system/primitives/src/responsive/media-helper.tsx
|
|
34
|
-
return definition.node.imported.name === 'media';
|
|
34
|
+
return definition.node.imported.type === 'Identifier' && definition.node.imported.name === 'media';
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -26,7 +26,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
26
26
|
ImportDeclaration: function ImportDeclaration(node) {
|
|
27
27
|
if (node.type === 'ImportDeclaration' && (node.source.value === '../src' || node.source.value === '@atlaskit/primitives')) {
|
|
28
28
|
node.specifiers.forEach(function (specifier) {
|
|
29
|
-
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'Inline') {
|
|
29
|
+
if (specifier.type === 'ImportSpecifier' && 'name' in specifier.imported && specifier.imported.name === 'Inline') {
|
|
30
30
|
inlineComponentNames.push(specifier.local.name);
|
|
31
31
|
}
|
|
32
32
|
});
|
|
@@ -32,8 +32,9 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
32
32
|
var buttonGroupIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(function (spec) {
|
|
33
33
|
if (node.source.value === '@atlaskit/button') {
|
|
34
34
|
var _spec$imported;
|
|
35
|
-
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'ButtonGroup';
|
|
36
|
-
}
|
|
35
|
+
return spec.type === 'ImportSpecifier' && 'name' in spec.imported && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'ButtonGroup';
|
|
36
|
+
}
|
|
37
|
+
if (node.source.value === '@atlaskit/button/button-group') {
|
|
37
38
|
return spec.type === 'ImportDefaultSpecifier';
|
|
38
39
|
}
|
|
39
40
|
});
|
|
@@ -67,13 +67,13 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
67
67
|
specialFieldsByImport[source].local = defaultImport[0].local.name;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
if ('@atlaskit/form'
|
|
70
|
+
if (source !== '@atlaskit/form') {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
var namedImport = node.specifiers.filter(function (spec) {
|
|
74
74
|
return (0, _eslintCodemodUtils.isNodeOfType)(spec, 'ImportSpecifier');
|
|
75
75
|
});
|
|
76
|
-
if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && namedImport[0].imported.name === 'Field') {
|
|
76
|
+
if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && 'name' in namedImport[0].imported && namedImport[0].imported.name === 'Field') {
|
|
77
77
|
fieldImport = namedImport[0].local;
|
|
78
78
|
}
|
|
79
79
|
},
|
|
@@ -37,7 +37,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
37
37
|
try {
|
|
38
38
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
39
39
|
var specifier = _step.value;
|
|
40
|
-
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'cx') {
|
|
40
|
+
if (specifier.type === 'ImportSpecifier' && 'name' in specifier.imported && specifier.imported.name === 'cx') {
|
|
41
41
|
importStatement.cxFuncLocalName = specifier.local.name;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -148,14 +148,16 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
148
148
|
var datetimePickerIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(function (spec) {
|
|
149
149
|
if (node.source.value === '@atlaskit/datetime-picker') {
|
|
150
150
|
var _spec$imported;
|
|
151
|
-
return (0, _eslintCodemodUtils.isNodeOfType)(spec, 'ImportSpecifier') && [DATE_PICKER, DATETIME_PICKER].includes((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name);
|
|
151
|
+
return (0, _eslintCodemodUtils.isNodeOfType)(spec, 'ImportSpecifier') && 'name' in spec.imported && [DATE_PICKER, DATETIME_PICKER].includes((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name);
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
datetimePickerIdentifier.forEach(function (identifier) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
if ('name' in identifier.imported) {
|
|
156
|
+
var imported = identifier.imported,
|
|
157
|
+
local = identifier.local;
|
|
158
|
+
contextLocalIdentifier.push(local.name);
|
|
159
|
+
contextImportedIdentifier.push(imported.name);
|
|
160
|
+
}
|
|
159
161
|
});
|
|
160
162
|
},
|
|
161
163
|
JSXElement: function JSXElement(node) {
|
|
@@ -32,8 +32,9 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
32
32
|
var menuSectionIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(function (spec) {
|
|
33
33
|
if (node.source.value === '@atlaskit/menu') {
|
|
34
34
|
var _spec$imported;
|
|
35
|
-
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Section';
|
|
36
|
-
}
|
|
35
|
+
return spec.type === 'ImportSpecifier' && 'name' in spec.imported && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Section';
|
|
36
|
+
}
|
|
37
|
+
if (node.source.value === '@atlaskit/menu/section') {
|
|
37
38
|
return spec.type === 'ImportDefaultSpecifier';
|
|
38
39
|
}
|
|
39
40
|
});
|
|
@@ -53,7 +53,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
53
53
|
node.specifiers.forEach(function (identifier) {
|
|
54
54
|
if ((0, _eslintCodemodUtils.isNodeOfType)(identifier, 'ImportDefaultSpecifier')) {
|
|
55
55
|
defaultImportLocalName = identifier.local.name;
|
|
56
|
-
} else if ((0, _eslintCodemodUtils.isNodeOfType)(identifier, 'ImportSpecifier')) {
|
|
56
|
+
} else if ((0, _eslintCodemodUtils.isNodeOfType)(identifier, 'ImportSpecifier') && 'name' in identifier.imported) {
|
|
57
57
|
var importName = identifier.imported.name;
|
|
58
58
|
var localName = identifier.local.name;
|
|
59
59
|
if (importName === 'ModalHeader') {
|
|
@@ -82,20 +82,29 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
// Add expression
|
|
85
|
+
// Add expression container's body if an expression container
|
|
86
86
|
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXExpressionContainer')) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
var expression = node.expression;
|
|
88
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(expression, 'ArrowFunctionExpression') || (0, _eslintCodemodUtils.isNodeOfType)(expression, 'FunctionExpression')) {
|
|
89
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(expression.body, 'JSXElement') || (0, _eslintCodemodUtils.isNodeOfType)(expression.body, 'JSXFragment')) {
|
|
90
|
+
searchExpression(expression.body);
|
|
91
|
+
} else if ((0, _eslintCodemodUtils.isNodeOfType)(expression.body, 'BlockStatement')) {
|
|
92
|
+
expression.body.body.forEach(function (statement) {
|
|
93
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(statement, 'ReturnStatement') && statement.argument) {
|
|
94
|
+
searchExpression(statement.argument);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
} else if ((0, _eslintCodemodUtils.isNodeOfType)(expression, 'LogicalExpression')) {
|
|
99
|
+
var left = expression.left,
|
|
100
|
+
right = expression.right;
|
|
93
101
|
[left, right].forEach(function (e) {
|
|
94
|
-
|
|
95
|
-
searchNode(e, true);
|
|
96
|
-
}
|
|
102
|
+
searchExpression(e);
|
|
97
103
|
});
|
|
104
|
+
} else {
|
|
105
|
+
searchExpression(expression);
|
|
98
106
|
}
|
|
107
|
+
return;
|
|
99
108
|
}
|
|
100
109
|
|
|
101
110
|
// Skip if not a JSX Element
|
|
@@ -118,6 +127,13 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
118
127
|
searchNode(node);
|
|
119
128
|
}
|
|
120
129
|
};
|
|
130
|
+
var searchExpression = function searchExpression(expression) {
|
|
131
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(expression, 'JSXElement')) {
|
|
132
|
+
searchNode(expression, true);
|
|
133
|
+
} else if ((0, _eslintCodemodUtils.isNodeOfType)(expression, 'JSXFragment')) {
|
|
134
|
+
searchJSXFragment(expression);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
121
137
|
var searchNode = function searchNode(node) {
|
|
122
138
|
var searchSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
123
139
|
if (searchSelf) {
|
|
@@ -136,6 +152,22 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
136
152
|
_iterator.f();
|
|
137
153
|
}
|
|
138
154
|
};
|
|
155
|
+
var searchJSXFragment = function searchJSXFragment(node) {
|
|
156
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXFragment')) {
|
|
157
|
+
var _iterator2 = _createForOfIteratorHelper(node.children),
|
|
158
|
+
_step2;
|
|
159
|
+
try {
|
|
160
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
161
|
+
var child = _step2.value;
|
|
162
|
+
checkNode(child);
|
|
163
|
+
}
|
|
164
|
+
} catch (err) {
|
|
165
|
+
_iterator2.e(err);
|
|
166
|
+
} finally {
|
|
167
|
+
_iterator2.f();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
139
171
|
if (name === defaultImportLocalName) {
|
|
140
172
|
searchNode(node);
|
|
141
173
|
|
|
@@ -33,8 +33,9 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
33
33
|
var buttonGroupIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(function (spec) {
|
|
34
34
|
if (node.source.value === '@atlaskit/onboarding') {
|
|
35
35
|
var _spec$imported;
|
|
36
|
-
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Spotlight';
|
|
37
|
-
}
|
|
36
|
+
return spec.type === 'ImportSpecifier' && 'name' in spec.imported && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Spotlight';
|
|
37
|
+
}
|
|
38
|
+
if (node.source.value === '@atlaskit/onboarding/spotlight') {
|
|
38
39
|
return spec.type === 'ImportDefaultSpecifier';
|
|
39
40
|
}
|
|
40
41
|
});
|
|
@@ -54,7 +54,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
54
54
|
if (defaultImport.length && defaultImport[0].local) {
|
|
55
55
|
componentLocalName = defaultImport[0].local.name;
|
|
56
56
|
// or if popup and using a named import
|
|
57
|
-
} else if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && namedImport[0].imported.name === 'Popup') {
|
|
57
|
+
} else if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && 'name' in namedImport[0].imported && namedImport[0].imported.name === 'Popup') {
|
|
58
58
|
componentLocalName = namedImport[0].local.name;
|
|
59
59
|
}
|
|
60
60
|
},
|
|
@@ -247,7 +247,7 @@ var StyleObject = exports.StyleObject = {
|
|
|
247
247
|
if (!(0, _eslintCodemodUtils.isNodeOfType)(specifier, 'ImportSpecifier')) {
|
|
248
248
|
return false;
|
|
249
249
|
}
|
|
250
|
-
if (specifier.imported.name === 'fontFallback') {
|
|
250
|
+
if ('name' in specifier.imported && specifier.imported.name === 'fontFallback') {
|
|
251
251
|
return true;
|
|
252
252
|
}
|
|
253
253
|
return false;
|
|
@@ -41,7 +41,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
41
41
|
var visuallyHiddenOrAssistive = node.specifiers.filter(function (specifier) {
|
|
42
42
|
return specifier.type === 'ImportSpecifier';
|
|
43
43
|
}).find(function (specifier) {
|
|
44
|
-
return THEME_IMPORT_NAMES.includes(specifier.imported.name);
|
|
44
|
+
return 'name' in specifier.imported && THEME_IMPORT_NAMES.includes(specifier.imported.name);
|
|
45
45
|
});
|
|
46
46
|
if (!visuallyHiddenOrAssistive) {
|
|
47
47
|
return;
|
|
@@ -51,7 +51,7 @@ var getStyledImportSpecifierName = function getStyledImportSpecifierName(context
|
|
|
51
51
|
var _supportedImport$spec;
|
|
52
52
|
var supportedImport = (0, _getFirstSupportedImport.getFirstSupportedImport)(context, importSources);
|
|
53
53
|
return supportedImport === null || supportedImport === void 0 || (_supportedImport$spec = supportedImport.specifiers.find(function (spec) {
|
|
54
|
-
return spec.type === 'ImportSpecifier' && spec.imported.name === 'styled' || spec.type === 'ImportDefaultSpecifier' && spec.local.name === 'styled';
|
|
54
|
+
return spec.type === 'ImportSpecifier' && 'name' in spec.imported && spec.imported.name === 'styled' || spec.type === 'ImportDefaultSpecifier' && spec.local.name === 'styled';
|
|
55
55
|
})) === null || _supportedImport$spec === void 0 ? void 0 : _supportedImport$spec.local.name;
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -15,7 +15,7 @@ var getImportName = exports.getImportName = function getImportName(scope, packag
|
|
|
15
15
|
if (!def || !def.node || !(0, _eslintCodemodUtils.isNodeOfType)(def.node, 'ImportSpecifier') || !def.parent || !(0, _eslintCodemodUtils.isNodeOfType)(def.parent, 'ImportDeclaration')) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
return def.parent.source.value === packageName && def.node.imported.name === componentName;
|
|
18
|
+
return def.parent.source.value === packageName && 'name' in def.node.imported && def.node.imported.name === componentName;
|
|
19
19
|
});
|
|
20
20
|
if (matchedVariable) {
|
|
21
21
|
break;
|
|
@@ -24,7 +24,6 @@ var getImportName = exports.getImportName = function getImportName(scope, packag
|
|
|
24
24
|
}
|
|
25
25
|
if (!matchedVariable) {
|
|
26
26
|
return null;
|
|
27
|
-
} else {
|
|
28
|
-
return matchedVariable.defs[0].node.local.name;
|
|
29
27
|
}
|
|
28
|
+
return matchedVariable.defs[0].node.local.name;
|
|
30
29
|
};
|
|
@@ -43,7 +43,7 @@ var getModuleOfIdentifier = exports.getModuleOfIdentifier = function getModuleOf
|
|
|
43
43
|
importName: identifierName
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
if (spec.type === 'ImportSpecifier' && spec.local.name === identifierName) {
|
|
46
|
+
if (spec.type === 'ImportSpecifier' && 'name' in spec.imported && spec.local.name === identifierName) {
|
|
47
47
|
return {
|
|
48
48
|
moduleName: node.source.value + '',
|
|
49
49
|
importName: spec.imported.name
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
const getScope = (context, node) => {
|
|
3
|
+
if ('getScope' in context.sourceCode) {
|
|
4
|
+
return context.sourceCode.getScope(node);
|
|
5
|
+
}
|
|
6
|
+
// this is needed for jira's eslint update, as otherwise there is type errors only in jira typechecking
|
|
7
|
+
return context.getScope(node);
|
|
8
|
+
};
|
|
2
9
|
const unsupportedSelectors = [':',
|
|
3
10
|
// pseudo-classes/elements
|
|
4
11
|
'[',
|
|
@@ -83,7 +90,7 @@ function checkSpreadElement(node, spreadElement, context) {
|
|
|
83
90
|
|
|
84
91
|
// Handle direct identifier (e.g., ...styles)
|
|
85
92
|
if (isNodeOfType(argument, 'Identifier')) {
|
|
86
|
-
const scope =
|
|
93
|
+
const scope = getScope(context, argument);
|
|
87
94
|
let variable = null;
|
|
88
95
|
let currentScope = scope;
|
|
89
96
|
|
|
@@ -198,7 +205,7 @@ export function checkStylesObject(node, stylesValue, context) {
|
|
|
198
205
|
});
|
|
199
206
|
} else if (isNodeOfType(stylesValue, 'Identifier')) {
|
|
200
207
|
// track the variable
|
|
201
|
-
const scope =
|
|
208
|
+
const scope = getScope(context, stylesValue);
|
|
202
209
|
let variable = null;
|
|
203
210
|
let currentScope = scope;
|
|
204
211
|
|
|
@@ -128,7 +128,7 @@ const getValueFromIdentifier = (node, context) => {
|
|
|
128
128
|
}
|
|
129
129
|
const definition = variable.defs[0];
|
|
130
130
|
if (isNodeOfType(definition.node, 'ImportSpecifier') && isNodeOfType(definition.node.parent, 'ImportDeclaration') && definition.node.parent.source.value === '@atlassian/jira-common-styles/src/main.tsx') {
|
|
131
|
-
return definition.node.imported.name === 'gridSize' ? 8 : null;
|
|
131
|
+
return definition.node.imported.type === 'Identifier' && definition.node.imported.name === 'gridSize' ? 8 : null;
|
|
132
132
|
}
|
|
133
133
|
if (!isNodeOfType(definition.node, 'VariableDeclarator')) {
|
|
134
134
|
return null;
|
|
@@ -37,16 +37,18 @@ const rule = createLintRule({
|
|
|
37
37
|
// Handle different import sources
|
|
38
38
|
switch (source) {
|
|
39
39
|
case '@atlaskit/primitives/compiled':
|
|
40
|
-
|
|
40
|
+
if (specifier.imported.type === 'Identifier') {
|
|
41
|
+
tracker.compiledComponents.add(specifier.imported.name);
|
|
42
|
+
}
|
|
41
43
|
break;
|
|
42
44
|
case '@atlaskit/primitives':
|
|
43
|
-
if (specifier.imported.name === 'xcss') {
|
|
45
|
+
if (specifier.imported.type === 'Identifier' && specifier.imported.name === 'xcss') {
|
|
44
46
|
tracker.xcssFunction.add(specifier.local.name);
|
|
45
47
|
}
|
|
46
48
|
break;
|
|
47
49
|
case '@atlaskit/css':
|
|
48
50
|
case '@compiled/react':
|
|
49
|
-
if (specifier.imported.name === 'cssMap') {
|
|
51
|
+
if (specifier.imported.type === 'Identifier' && specifier.imported.name === 'cssMap') {
|
|
50
52
|
tracker.cssMapFunction.add(specifier.local.name);
|
|
51
53
|
}
|
|
52
54
|
break;
|
|
@@ -108,7 +108,7 @@ export const createChecks = context => {
|
|
|
108
108
|
} else if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
109
109
|
name = '*';
|
|
110
110
|
} else if (specifier.type === 'ImportSpecifier') {
|
|
111
|
-
name = specifier.imported.name;
|
|
111
|
+
name = specifier.imported.type === 'Identifier' ? specifier.imported.name : '';
|
|
112
112
|
}
|
|
113
113
|
if (name) {
|
|
114
114
|
importNames.set(name, specifier);
|
|
@@ -139,7 +139,7 @@ export const createChecks = context => {
|
|
|
139
139
|
for (const specifier of node.specifiers) {
|
|
140
140
|
let name;
|
|
141
141
|
if (specifier.local) {
|
|
142
|
-
name = specifier.local.name;
|
|
142
|
+
name = specifier.local.type === 'Identifier' ? specifier.local.name : '';
|
|
143
143
|
}
|
|
144
144
|
if (name) {
|
|
145
145
|
importNames.set(name, specifier);
|
|
@@ -29,7 +29,7 @@ export const JSXElement = {
|
|
|
29
29
|
existingLinkName = defaultSpecifier.local.name;
|
|
30
30
|
}
|
|
31
31
|
} else if (declaration.source.value === '@atlaskit/button/new') {
|
|
32
|
-
const namedSpecifier = declaration.specifiers.find(specifier => specifier.type === 'ImportSpecifier' && specifier.imported.name === 'LinkButton');
|
|
32
|
+
const namedSpecifier = declaration.specifiers.find(specifier => specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier' && specifier.imported.name === 'LinkButton');
|
|
33
33
|
if (namedSpecifier) {
|
|
34
34
|
existingLinkButtonName = namedSpecifier.local.name;
|
|
35
35
|
}
|
|
@@ -25,7 +25,7 @@ export const JSXElement = {
|
|
|
25
25
|
}
|
|
26
26
|
if (declaration.source.value === '@atlaskit/code') {
|
|
27
27
|
declaration.specifiers.filter(specifier => isNodeOfType(specifier, 'ImportSpecifier') && isNodeOfType(specifier.parent, 'ImportDeclaration')).forEach(specifier => {
|
|
28
|
-
if (isNodeOfType(specifier, 'ImportSpecifier') && specifier.imported.name === 'Code') {
|
|
28
|
+
if (isNodeOfType(specifier, 'ImportSpecifier') && specifier.imported.type === 'Identifier' && specifier.imported.name === 'Code') {
|
|
29
29
|
existingCodeName = specifier.local.name;
|
|
30
30
|
}
|
|
31
31
|
});
|
|
@@ -50,6 +50,7 @@ export class CssMapObjectChecker {
|
|
|
50
50
|
messageId: 'noInlineFunctions'
|
|
51
51
|
});
|
|
52
52
|
} else if (value.type === 'BinaryExpression' || value.type === 'LogicalExpression') {
|
|
53
|
+
// @ts-ignore -- this needs to be `ts-ignore` because this only errors in jira's typechecking due to update, not platform's
|
|
53
54
|
this.checkCssMapObjectValue(value.left);
|
|
54
55
|
this.checkCssMapObjectValue(value.right);
|
|
55
56
|
} else if (value.type === 'Identifier') {
|
|
@@ -66,7 +66,7 @@ export const createChecks = context => {
|
|
|
66
66
|
for (const spec of node.specifiers) {
|
|
67
67
|
if (spec.type === 'ImportDefaultSpecifier') {
|
|
68
68
|
newButtonImports.add(spec.local.name);
|
|
69
|
-
} else if (spec.type === 'ImportSpecifier' && spec.imported.name === 'IconButton') {
|
|
69
|
+
} else if (spec.type === 'ImportSpecifier' && 'name' in spec.imported && spec.imported.name === 'IconButton') {
|
|
70
70
|
newButtonImports.add(spec.local.name);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -140,12 +140,14 @@ export const createChecks = context => {
|
|
|
140
140
|
const moduleSource = node.source.value;
|
|
141
141
|
if (typeof moduleSource === 'string' && ['@atlaskit/icon/glyph/'].find(val => moduleSource.startsWith(val)) && node.specifiers.length) {
|
|
142
142
|
for (const spec of node.specifiers) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
if ('name' in spec.exported) {
|
|
144
|
+
createCantMigrateReExportError(spec, moduleSource, spec.exported.name, errorsManual);
|
|
145
|
+
addToListOfRanges(spec, errorRanges);
|
|
146
|
+
guidance[locToString(spec)] = createGuidance({
|
|
147
|
+
iconPackage: moduleSource,
|
|
148
|
+
shouldUseMigrationPath
|
|
149
|
+
});
|
|
150
|
+
}
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
153
|
} else if (node.declaration && isNodeOfType(node.declaration, 'VariableDeclaration')) {
|
|
@@ -168,7 +170,7 @@ export const createChecks = context => {
|
|
|
168
170
|
* export { AddIcon, CrossIcon as default }
|
|
169
171
|
*/
|
|
170
172
|
for (const spec of node.specifiers) {
|
|
171
|
-
if (Object.keys(legacyIconImports).includes(spec.local.name)) {
|
|
173
|
+
if ('name' in spec.local && 'name' in spec.exported && Object.keys(legacyIconImports).includes(spec.local.name)) {
|
|
172
174
|
//update legacy imports to be exported
|
|
173
175
|
legacyIconImports[spec.local.name] = {
|
|
174
176
|
packageName: legacyIconImports[spec.local.name].packageName,
|