@atlaskit/eslint-plugin-design-system 13.19.4 → 13.19.6
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 +1 -1
- 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 +4 -2
- 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 +1 -1
- 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 +6 -6
|
@@ -132,16 +132,18 @@ const rule = createLintRule({
|
|
|
132
132
|
const datetimePickerIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(spec => {
|
|
133
133
|
if (node.source.value === '@atlaskit/datetime-picker') {
|
|
134
134
|
var _spec$imported;
|
|
135
|
-
return isNodeOfType(spec, 'ImportSpecifier') && [DATE_PICKER, DATETIME_PICKER].includes((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name);
|
|
135
|
+
return 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);
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
datetimePickerIdentifier.forEach(identifier => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
if ('name' in identifier.imported) {
|
|
140
|
+
const {
|
|
141
|
+
imported,
|
|
142
|
+
local
|
|
143
|
+
} = identifier;
|
|
144
|
+
contextLocalIdentifier.push(local.name);
|
|
145
|
+
contextImportedIdentifier.push(imported.name);
|
|
146
|
+
}
|
|
145
147
|
});
|
|
146
148
|
},
|
|
147
149
|
JSXElement(node) {
|
|
@@ -26,8 +26,9 @@ const rule = createLintRule({
|
|
|
26
26
|
const menuSectionIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(spec => {
|
|
27
27
|
if (node.source.value === '@atlaskit/menu') {
|
|
28
28
|
var _spec$imported;
|
|
29
|
-
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Section';
|
|
30
|
-
}
|
|
29
|
+
return spec.type === 'ImportSpecifier' && 'name' in spec.imported && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Section';
|
|
30
|
+
}
|
|
31
|
+
if (node.source.value === '@atlaskit/menu/section') {
|
|
31
32
|
return spec.type === 'ImportDefaultSpecifier';
|
|
32
33
|
}
|
|
33
34
|
});
|
|
@@ -44,7 +44,7 @@ const rule = createLintRule({
|
|
|
44
44
|
node.specifiers.forEach(identifier => {
|
|
45
45
|
if (isNodeOfType(identifier, 'ImportDefaultSpecifier')) {
|
|
46
46
|
defaultImportLocalName = identifier.local.name;
|
|
47
|
-
} else if (isNodeOfType(identifier, 'ImportSpecifier')) {
|
|
47
|
+
} else if (isNodeOfType(identifier, 'ImportSpecifier') && 'name' in identifier.imported) {
|
|
48
48
|
const importName = identifier.imported.name;
|
|
49
49
|
const localName = identifier.local.name;
|
|
50
50
|
if (importName === 'ModalHeader') {
|
|
@@ -62,7 +62,9 @@ const rule = createLintRule({
|
|
|
62
62
|
if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
65
|
+
const {
|
|
66
|
+
name
|
|
67
|
+
} = node.openingElement.name;
|
|
66
68
|
if (![defaultImportLocalName, modalHeaderLocalName].includes(name)) {
|
|
67
69
|
return;
|
|
68
70
|
}
|
|
@@ -27,8 +27,9 @@ const rule = createLintRule({
|
|
|
27
27
|
const buttonGroupIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(spec => {
|
|
28
28
|
if (node.source.value === '@atlaskit/onboarding') {
|
|
29
29
|
var _spec$imported;
|
|
30
|
-
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Spotlight';
|
|
31
|
-
}
|
|
30
|
+
return spec.type === 'ImportSpecifier' && 'name' in spec.imported && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Spotlight';
|
|
31
|
+
}
|
|
32
|
+
if (node.source.value === '@atlaskit/onboarding/spotlight') {
|
|
32
33
|
return spec.type === 'ImportDefaultSpecifier';
|
|
33
34
|
}
|
|
34
35
|
});
|
|
@@ -44,7 +44,7 @@ const rule = createLintRule({
|
|
|
44
44
|
if (defaultImport.length && defaultImport[0].local) {
|
|
45
45
|
componentLocalName = defaultImport[0].local.name;
|
|
46
46
|
// or if popup and using a named import
|
|
47
|
-
} else if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && namedImport[0].imported.name === 'Popup') {
|
|
47
|
+
} else if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && 'name' in namedImport[0].imported && namedImport[0].imported.name === 'Popup') {
|
|
48
48
|
componentLocalName = namedImport[0].local.name;
|
|
49
49
|
}
|
|
50
50
|
},
|
|
@@ -241,7 +241,7 @@ export const StyleObject = {
|
|
|
241
241
|
if (!isNodeOfType(specifier, 'ImportSpecifier')) {
|
|
242
242
|
return false;
|
|
243
243
|
}
|
|
244
|
-
if (specifier.imported.name === 'fontFallback') {
|
|
244
|
+
if ('name' in specifier.imported && specifier.imported.name === 'fontFallback') {
|
|
245
245
|
return true;
|
|
246
246
|
}
|
|
247
247
|
return false;
|
|
@@ -30,7 +30,7 @@ const rule = createLintRule({
|
|
|
30
30
|
if (!isThemeNode) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
const visuallyHiddenOrAssistive = node.specifiers.filter(specifier => specifier.type === 'ImportSpecifier').find(specifier => THEME_IMPORT_NAMES.includes(specifier.imported.name));
|
|
33
|
+
const visuallyHiddenOrAssistive = node.specifiers.filter(specifier => specifier.type === 'ImportSpecifier').find(specifier => 'name' in specifier.imported && THEME_IMPORT_NAMES.includes(specifier.imported.name));
|
|
34
34
|
if (!visuallyHiddenOrAssistive) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
@@ -42,7 +42,7 @@ const findNode = nodes => {
|
|
|
42
42
|
const getStyledImportSpecifierName = (context, importSources) => {
|
|
43
43
|
var _supportedImport$spec;
|
|
44
44
|
const supportedImport = getFirstSupportedImport(context, importSources);
|
|
45
|
-
return supportedImport === null || supportedImport === void 0 ? void 0 : (_supportedImport$spec = supportedImport.specifiers.find(spec => spec.type === 'ImportSpecifier' && spec.imported.name === 'styled' || spec.type === 'ImportDefaultSpecifier' && spec.local.name === 'styled')) === null || _supportedImport$spec === void 0 ? void 0 : _supportedImport$spec.local.name;
|
|
45
|
+
return supportedImport === null || supportedImport === void 0 ? void 0 : (_supportedImport$spec = supportedImport.specifiers.find(spec => spec.type === 'ImportSpecifier' && 'name' in spec.imported && spec.imported.name === 'styled' || spec.type === 'ImportDefaultSpecifier' && spec.local.name === 'styled')) === null || _supportedImport$spec === void 0 ? void 0 : _supportedImport$spec.local.name;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
/**
|
|
@@ -9,7 +9,7 @@ export const getImportName = (scope, packageName, componentName) => {
|
|
|
9
9
|
if (!def || !def.node || !isNodeOfType(def.node, 'ImportSpecifier') || !def.parent || !isNodeOfType(def.parent, 'ImportDeclaration')) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
return def.parent.source.value === packageName && def.node.imported.name === componentName;
|
|
12
|
+
return def.parent.source.value === packageName && 'name' in def.node.imported && def.node.imported.name === componentName;
|
|
13
13
|
});
|
|
14
14
|
if (matchedVariable) {
|
|
15
15
|
break;
|
|
@@ -18,7 +18,6 @@ export const getImportName = (scope, packageName, componentName) => {
|
|
|
18
18
|
}
|
|
19
19
|
if (!matchedVariable) {
|
|
20
20
|
return null;
|
|
21
|
-
} else {
|
|
22
|
-
return matchedVariable.defs[0].node.local.name;
|
|
23
21
|
}
|
|
22
|
+
return matchedVariable.defs[0].node.local.name;
|
|
24
23
|
};
|
|
@@ -22,7 +22,7 @@ export const getModuleOfIdentifier = (source, identifierName) => {
|
|
|
22
22
|
importName: identifierName
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
if (spec.type === 'ImportSpecifier' && spec.local.name === identifierName) {
|
|
25
|
+
if (spec.type === 'ImportSpecifier' && 'name' in spec.imported && spec.local.name === identifierName) {
|
|
26
26
|
return {
|
|
27
27
|
moduleName: node.source.value + '',
|
|
28
28
|
importName: spec.imported.name
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
var getScope = function 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
|
var unsupportedSelectors = [':',
|
|
3
10
|
// pseudo-classes/elements
|
|
4
11
|
'[',
|
|
@@ -85,7 +92,7 @@ function checkSpreadElement(node, spreadElement, context) {
|
|
|
85
92
|
|
|
86
93
|
// Handle direct identifier (e.g., ...styles)
|
|
87
94
|
if (isNodeOfType(argument, 'Identifier')) {
|
|
88
|
-
var scope =
|
|
95
|
+
var scope = getScope(context, argument);
|
|
89
96
|
var variable = null;
|
|
90
97
|
var currentScope = scope;
|
|
91
98
|
|
|
@@ -204,7 +211,7 @@ export function checkStylesObject(node, stylesValue, context) {
|
|
|
204
211
|
});
|
|
205
212
|
} else if (isNodeOfType(stylesValue, 'Identifier')) {
|
|
206
213
|
// track the variable
|
|
207
|
-
var scope =
|
|
214
|
+
var scope = getScope(context, stylesValue);
|
|
208
215
|
var variable = null;
|
|
209
216
|
var currentScope = scope;
|
|
210
217
|
|
|
@@ -141,7 +141,7 @@ var getValueFromIdentifier = function getValueFromIdentifier(node, context) {
|
|
|
141
141
|
}
|
|
142
142
|
var definition = variable.defs[0];
|
|
143
143
|
if (isNodeOfType(definition.node, 'ImportSpecifier') && isNodeOfType(definition.node.parent, 'ImportDeclaration') && definition.node.parent.source.value === '@atlassian/jira-common-styles/src/main.tsx') {
|
|
144
|
-
return definition.node.imported.name === 'gridSize' ? 8 : null;
|
|
144
|
+
return definition.node.imported.type === 'Identifier' && definition.node.imported.name === 'gridSize' ? 8 : null;
|
|
145
145
|
}
|
|
146
146
|
if (!isNodeOfType(definition.node, 'VariableDeclarator')) {
|
|
147
147
|
return null;
|
|
@@ -37,16 +37,18 @@ var 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;
|
|
@@ -114,7 +114,7 @@ export var createChecks = function createChecks(context) {
|
|
|
114
114
|
} else if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
115
115
|
name = '*';
|
|
116
116
|
} else if (specifier.type === 'ImportSpecifier') {
|
|
117
|
-
name = specifier.imported.name;
|
|
117
|
+
name = specifier.imported.type === 'Identifier' ? specifier.imported.name : '';
|
|
118
118
|
}
|
|
119
119
|
if (name) {
|
|
120
120
|
importNames.set(name, specifier);
|
|
@@ -154,7 +154,7 @@ export var createChecks = function createChecks(context) {
|
|
|
154
154
|
var specifier = _step2.value;
|
|
155
155
|
var name = void 0;
|
|
156
156
|
if (specifier.local) {
|
|
157
|
-
name = specifier.local.name;
|
|
157
|
+
name = specifier.local.type === 'Identifier' ? specifier.local.name : '';
|
|
158
158
|
}
|
|
159
159
|
if (name) {
|
|
160
160
|
importNames.set(name, specifier);
|
|
@@ -47,7 +47,7 @@ export var JSXElement = {
|
|
|
47
47
|
}
|
|
48
48
|
} else if (declaration.source.value === '@atlaskit/button/new') {
|
|
49
49
|
var namedSpecifier = declaration.specifiers.find(function (specifier) {
|
|
50
|
-
return specifier.type === 'ImportSpecifier' && specifier.imported.name === 'LinkButton';
|
|
50
|
+
return specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier' && specifier.imported.name === 'LinkButton';
|
|
51
51
|
});
|
|
52
52
|
if (namedSpecifier) {
|
|
53
53
|
existingLinkButtonName = namedSpecifier.local.name;
|
|
@@ -42,7 +42,7 @@ export var JSXElement = {
|
|
|
42
42
|
declaration.specifiers.filter(function (specifier) {
|
|
43
43
|
return isNodeOfType(specifier, 'ImportSpecifier') && isNodeOfType(specifier.parent, 'ImportDeclaration');
|
|
44
44
|
}).forEach(function (specifier) {
|
|
45
|
-
if (isNodeOfType(specifier, 'ImportSpecifier') && specifier.imported.name === 'Code') {
|
|
45
|
+
if (isNodeOfType(specifier, 'ImportSpecifier') && specifier.imported.type === 'Identifier' && specifier.imported.name === 'Code') {
|
|
46
46
|
existingCodeName = specifier.local.name;
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -58,6 +58,7 @@ export var CssMapObjectChecker = /*#__PURE__*/function () {
|
|
|
58
58
|
messageId: 'noInlineFunctions'
|
|
59
59
|
});
|
|
60
60
|
} else if (value.type === 'BinaryExpression' || value.type === 'LogicalExpression') {
|
|
61
|
+
// @ts-ignore -- this needs to be `ts-ignore` because this only errors in jira's typechecking due to update, not platform's
|
|
61
62
|
this.checkCssMapObjectValue(value.left);
|
|
62
63
|
this.checkCssMapObjectValue(value.right);
|
|
63
64
|
} else if (value.type === 'Identifier') {
|
|
@@ -83,7 +83,7 @@ export var createChecks = function createChecks(context) {
|
|
|
83
83
|
var _spec = _step2.value;
|
|
84
84
|
if (_spec.type === 'ImportDefaultSpecifier') {
|
|
85
85
|
newButtonImports.add(_spec.local.name);
|
|
86
|
-
} else if (_spec.type === 'ImportSpecifier' && _spec.imported.name === 'IconButton') {
|
|
86
|
+
} else if (_spec.type === 'ImportSpecifier' && 'name' in _spec.imported && _spec.imported.name === 'IconButton') {
|
|
87
87
|
newButtonImports.add(_spec.local.name);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -186,12 +186,14 @@ export var createChecks = function createChecks(context) {
|
|
|
186
186
|
try {
|
|
187
187
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
188
188
|
var spec = _step5.value;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
if ('name' in spec.exported) {
|
|
190
|
+
createCantMigrateReExportError(spec, moduleSource, spec.exported.name, errorsManual);
|
|
191
|
+
addToListOfRanges(spec, errorRanges);
|
|
192
|
+
guidance[locToString(spec)] = createGuidance({
|
|
193
|
+
iconPackage: moduleSource,
|
|
194
|
+
shouldUseMigrationPath: shouldUseMigrationPath
|
|
195
|
+
});
|
|
196
|
+
}
|
|
195
197
|
}
|
|
196
198
|
} catch (err) {
|
|
197
199
|
_iterator5.e(err);
|
|
@@ -232,7 +234,7 @@ export var createChecks = function createChecks(context) {
|
|
|
232
234
|
try {
|
|
233
235
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
234
236
|
var _spec3 = _step7.value;
|
|
235
|
-
if (Object.keys(legacyIconImports).includes(_spec3.local.name)) {
|
|
237
|
+
if ('name' in _spec3.local && 'name' in _spec3.exported && Object.keys(legacyIconImports).includes(_spec3.local.name)) {
|
|
236
238
|
//update legacy imports to be exported
|
|
237
239
|
legacyIconImports[_spec3.local.name] = {
|
|
238
240
|
packageName: legacyIconImports[_spec3.local.name].packageName,
|
|
@@ -25,7 +25,7 @@ var isMediaObject = function isMediaObject(node, context) {
|
|
|
25
25
|
// Make sure it's coming from the primitives packages and isn't a bootleg media query or worse: nested styles
|
|
26
26
|
if (isNodeOfType(definition.node, 'ImportSpecifier') && definition.node.parent && isNodeOfType(definition.node.parent, 'ImportDeclaration') && allowedResponsiveImports.includes(definition.node.parent.source.value)) {
|
|
27
27
|
// This should match the name of the media object exported from packages/design-system/primitives/src/responsive/media-helper.tsx
|
|
28
|
-
return definition.node.imported.name === 'media';
|
|
28
|
+
return definition.node.imported.type === 'Identifier' && definition.node.imported.name === 'media';
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -20,7 +20,7 @@ var rule = createLintRule({
|
|
|
20
20
|
ImportDeclaration: function ImportDeclaration(node) {
|
|
21
21
|
if (node.type === 'ImportDeclaration' && (node.source.value === '../src' || node.source.value === '@atlaskit/primitives')) {
|
|
22
22
|
node.specifiers.forEach(function (specifier) {
|
|
23
|
-
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'Inline') {
|
|
23
|
+
if (specifier.type === 'ImportSpecifier' && 'name' in specifier.imported && specifier.imported.name === 'Inline') {
|
|
24
24
|
inlineComponentNames.push(specifier.local.name);
|
|
25
25
|
}
|
|
26
26
|
});
|
|
@@ -26,8 +26,9 @@ var rule = createLintRule({
|
|
|
26
26
|
var buttonGroupIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(function (spec) {
|
|
27
27
|
if (node.source.value === '@atlaskit/button') {
|
|
28
28
|
var _spec$imported;
|
|
29
|
-
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'ButtonGroup';
|
|
30
|
-
}
|
|
29
|
+
return spec.type === 'ImportSpecifier' && 'name' in spec.imported && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'ButtonGroup';
|
|
30
|
+
}
|
|
31
|
+
if (node.source.value === '@atlaskit/button/button-group') {
|
|
31
32
|
return spec.type === 'ImportDefaultSpecifier';
|
|
32
33
|
}
|
|
33
34
|
});
|
|
@@ -61,13 +61,13 @@ var rule = createLintRule({
|
|
|
61
61
|
specialFieldsByImport[source].local = defaultImport[0].local.name;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
if ('@atlaskit/form'
|
|
64
|
+
if (source !== '@atlaskit/form') {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
var namedImport = node.specifiers.filter(function (spec) {
|
|
68
68
|
return isNodeOfType(spec, 'ImportSpecifier');
|
|
69
69
|
});
|
|
70
|
-
if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && namedImport[0].imported.name === 'Field') {
|
|
70
|
+
if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && 'name' in namedImport[0].imported && namedImport[0].imported.name === 'Field') {
|
|
71
71
|
fieldImport = namedImport[0].local;
|
|
72
72
|
}
|
|
73
73
|
},
|
|
@@ -31,7 +31,7 @@ var rule = createLintRule({
|
|
|
31
31
|
try {
|
|
32
32
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
33
33
|
var specifier = _step.value;
|
|
34
|
-
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'cx') {
|
|
34
|
+
if (specifier.type === 'ImportSpecifier' && 'name' in specifier.imported && specifier.imported.name === 'cx') {
|
|
35
35
|
importStatement.cxFuncLocalName = specifier.local.name;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -142,14 +142,16 @@ var rule = createLintRule({
|
|
|
142
142
|
var datetimePickerIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(function (spec) {
|
|
143
143
|
if (node.source.value === '@atlaskit/datetime-picker') {
|
|
144
144
|
var _spec$imported;
|
|
145
|
-
return isNodeOfType(spec, 'ImportSpecifier') && [DATE_PICKER, DATETIME_PICKER].includes((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name);
|
|
145
|
+
return 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);
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
datetimePickerIdentifier.forEach(function (identifier) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
if ('name' in identifier.imported) {
|
|
150
|
+
var imported = identifier.imported,
|
|
151
|
+
local = identifier.local;
|
|
152
|
+
contextLocalIdentifier.push(local.name);
|
|
153
|
+
contextImportedIdentifier.push(imported.name);
|
|
154
|
+
}
|
|
153
155
|
});
|
|
154
156
|
},
|
|
155
157
|
JSXElement: function JSXElement(node) {
|
|
@@ -26,8 +26,9 @@ var rule = createLintRule({
|
|
|
26
26
|
var menuSectionIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(function (spec) {
|
|
27
27
|
if (node.source.value === '@atlaskit/menu') {
|
|
28
28
|
var _spec$imported;
|
|
29
|
-
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Section';
|
|
30
|
-
}
|
|
29
|
+
return spec.type === 'ImportSpecifier' && 'name' in spec.imported && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Section';
|
|
30
|
+
}
|
|
31
|
+
if (node.source.value === '@atlaskit/menu/section') {
|
|
31
32
|
return spec.type === 'ImportDefaultSpecifier';
|
|
32
33
|
}
|
|
33
34
|
});
|
|
@@ -47,7 +47,7 @@ var rule = createLintRule({
|
|
|
47
47
|
node.specifiers.forEach(function (identifier) {
|
|
48
48
|
if (isNodeOfType(identifier, 'ImportDefaultSpecifier')) {
|
|
49
49
|
defaultImportLocalName = identifier.local.name;
|
|
50
|
-
} else if (isNodeOfType(identifier, 'ImportSpecifier')) {
|
|
50
|
+
} else if (isNodeOfType(identifier, 'ImportSpecifier') && 'name' in identifier.imported) {
|
|
51
51
|
var importName = identifier.imported.name;
|
|
52
52
|
var localName = identifier.local.name;
|
|
53
53
|
if (importName === 'ModalHeader') {
|
|
@@ -27,8 +27,9 @@ var rule = createLintRule({
|
|
|
27
27
|
var buttonGroupIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(function (spec) {
|
|
28
28
|
if (node.source.value === '@atlaskit/onboarding') {
|
|
29
29
|
var _spec$imported;
|
|
30
|
-
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Spotlight';
|
|
31
|
-
}
|
|
30
|
+
return spec.type === 'ImportSpecifier' && 'name' in spec.imported && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'Spotlight';
|
|
31
|
+
}
|
|
32
|
+
if (node.source.value === '@atlaskit/onboarding/spotlight') {
|
|
32
33
|
return spec.type === 'ImportDefaultSpecifier';
|
|
33
34
|
}
|
|
34
35
|
});
|
|
@@ -48,7 +48,7 @@ var rule = createLintRule({
|
|
|
48
48
|
if (defaultImport.length && defaultImport[0].local) {
|
|
49
49
|
componentLocalName = defaultImport[0].local.name;
|
|
50
50
|
// or if popup and using a named import
|
|
51
|
-
} else if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && namedImport[0].imported.name === 'Popup') {
|
|
51
|
+
} else if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && 'name' in namedImport[0].imported && namedImport[0].imported.name === 'Popup') {
|
|
52
52
|
componentLocalName = namedImport[0].local.name;
|
|
53
53
|
}
|
|
54
54
|
},
|
|
@@ -242,7 +242,7 @@ export var StyleObject = {
|
|
|
242
242
|
if (!isNodeOfType(specifier, 'ImportSpecifier')) {
|
|
243
243
|
return false;
|
|
244
244
|
}
|
|
245
|
-
if (specifier.imported.name === 'fontFallback') {
|
|
245
|
+
if ('name' in specifier.imported && specifier.imported.name === 'fontFallback') {
|
|
246
246
|
return true;
|
|
247
247
|
}
|
|
248
248
|
return false;
|
|
@@ -34,7 +34,7 @@ var rule = createLintRule({
|
|
|
34
34
|
var visuallyHiddenOrAssistive = node.specifiers.filter(function (specifier) {
|
|
35
35
|
return specifier.type === 'ImportSpecifier';
|
|
36
36
|
}).find(function (specifier) {
|
|
37
|
-
return THEME_IMPORT_NAMES.includes(specifier.imported.name);
|
|
37
|
+
return 'name' in specifier.imported && THEME_IMPORT_NAMES.includes(specifier.imported.name);
|
|
38
38
|
});
|
|
39
39
|
if (!visuallyHiddenOrAssistive) {
|
|
40
40
|
return;
|
|
@@ -45,7 +45,7 @@ var getStyledImportSpecifierName = function getStyledImportSpecifierName(context
|
|
|
45
45
|
var _supportedImport$spec;
|
|
46
46
|
var supportedImport = getFirstSupportedImport(context, importSources);
|
|
47
47
|
return supportedImport === null || supportedImport === void 0 || (_supportedImport$spec = supportedImport.specifiers.find(function (spec) {
|
|
48
|
-
return spec.type === 'ImportSpecifier' && spec.imported.name === 'styled' || spec.type === 'ImportDefaultSpecifier' && spec.local.name === 'styled';
|
|
48
|
+
return spec.type === 'ImportSpecifier' && 'name' in spec.imported && spec.imported.name === 'styled' || spec.type === 'ImportDefaultSpecifier' && spec.local.name === 'styled';
|
|
49
49
|
})) === null || _supportedImport$spec === void 0 ? void 0 : _supportedImport$spec.local.name;
|
|
50
50
|
};
|
|
51
51
|
|
|
@@ -9,7 +9,7 @@ export var getImportName = function getImportName(scope, packageName, componentN
|
|
|
9
9
|
if (!def || !def.node || !isNodeOfType(def.node, 'ImportSpecifier') || !def.parent || !isNodeOfType(def.parent, 'ImportDeclaration')) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
return def.parent.source.value === packageName && def.node.imported.name === componentName;
|
|
12
|
+
return def.parent.source.value === packageName && 'name' in def.node.imported && def.node.imported.name === componentName;
|
|
13
13
|
});
|
|
14
14
|
if (matchedVariable) {
|
|
15
15
|
break;
|
|
@@ -18,7 +18,6 @@ export var getImportName = function getImportName(scope, packageName, componentN
|
|
|
18
18
|
}
|
|
19
19
|
if (!matchedVariable) {
|
|
20
20
|
return null;
|
|
21
|
-
} else {
|
|
22
|
-
return matchedVariable.defs[0].node.local.name;
|
|
23
21
|
}
|
|
22
|
+
return matchedVariable.defs[0].node.local.name;
|
|
24
23
|
};
|
|
@@ -37,7 +37,7 @@ export var getModuleOfIdentifier = function getModuleOfIdentifier(source, identi
|
|
|
37
37
|
importName: identifierName
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
if (spec.type === 'ImportSpecifier' && spec.local.name === identifierName) {
|
|
40
|
+
if (spec.type === 'ImportSpecifier' && 'name' in spec.imported && spec.local.name === identifierName) {
|
|
41
41
|
return {
|
|
42
42
|
moduleName: node.source.value + '',
|
|
43
43
|
importName: spec.imported.name
|
|
@@ -12,10 +12,10 @@ export declare const FunctionCall: {
|
|
|
12
12
|
* If you need to support another type of arg, add it, and update the type.
|
|
13
13
|
*/
|
|
14
14
|
getArgumentAtPos(node: CallExpression, pos: number): {
|
|
15
|
-
type:
|
|
15
|
+
type: "Literal";
|
|
16
16
|
value: string;
|
|
17
17
|
} | {
|
|
18
|
-
type:
|
|
18
|
+
type: "ObjectExpression";
|
|
19
19
|
value: ObjectExpression;
|
|
20
20
|
} | undefined;
|
|
21
21
|
};
|
|
@@ -16,13 +16,13 @@ declare const HelperJSXAttribute: {
|
|
|
16
16
|
* If you need additional functionality add it, and set the correct `type` on the returned object
|
|
17
17
|
*/
|
|
18
18
|
getValue(node: JSXAttribute): {
|
|
19
|
-
type:
|
|
19
|
+
type: "ExpressionStatement";
|
|
20
20
|
value: string;
|
|
21
21
|
} | {
|
|
22
|
-
type:
|
|
22
|
+
type: "ExpressionStatement Literal";
|
|
23
23
|
value: string | number | bigint | boolean | RegExp | null | undefined;
|
|
24
24
|
} | {
|
|
25
|
-
type:
|
|
25
|
+
type: "Literal";
|
|
26
26
|
value: string;
|
|
27
27
|
} | undefined;
|
|
28
28
|
};
|
|
@@ -18,7 +18,7 @@ export declare const JSXElementHelper: {
|
|
|
18
18
|
getAttributeByName(node: JSXElement, name: string): JSXAttribute | undefined;
|
|
19
19
|
containsSpreadAttributes(node: JSXElement): boolean;
|
|
20
20
|
addAttribute(node: JSXElement, name: string, value: string, fixer: Rule.RuleFixer): Rule.Fix;
|
|
21
|
-
getChildren(node: JSXElement | JSXFragment): JSXElement[
|
|
21
|
+
getChildren(node: JSXElement | JSXFragment): JSXElement["children"];
|
|
22
22
|
hasAllowedAttrsOnly(node: JSXElement, allowedProps: string[]): boolean;
|
|
23
23
|
};
|
|
24
24
|
export { JSXElementHelper as JSXElement };
|
|
@@ -2,10 +2,10 @@ import type { Rule } from 'eslint';
|
|
|
2
2
|
import { type Property, type SpreadElement } from 'eslint-codemod-utils';
|
|
3
3
|
export declare const ObjectEntry: {
|
|
4
4
|
getProperty(node: Property): {
|
|
5
|
-
type:
|
|
5
|
+
type: "Identifier";
|
|
6
6
|
value: string;
|
|
7
7
|
} | {
|
|
8
|
-
type:
|
|
8
|
+
type: "Literal";
|
|
9
9
|
value: string;
|
|
10
10
|
} | {
|
|
11
11
|
type: undefined;
|
|
@@ -22,7 +22,7 @@ declare const ASTObjectExpression: {
|
|
|
22
22
|
* Returns only the property @type {Property['key']} like: `padding` from: `{ padding: '8px' }`.
|
|
23
23
|
* If you want the key/value pair, use `getEntryByPropertyName`.
|
|
24
24
|
*/
|
|
25
|
-
getProperty(node: ObjectExpression, name: string): Property[
|
|
25
|
+
getProperty(node: ObjectExpression, name: string): Property["key"] | undefined;
|
|
26
26
|
/**
|
|
27
27
|
* Gets the array of key/value pairs in an ObjectExpression.
|
|
28
28
|
*/
|
|
@@ -32,7 +32,7 @@ declare const ASTObjectExpression: {
|
|
|
32
32
|
*
|
|
33
33
|
* Values can be basically anything, so be careful with this.
|
|
34
34
|
*/
|
|
35
|
-
getValueByPropertyName(node: ObjectExpression, name: string): Property[
|
|
35
|
+
getValueByPropertyName(node: ObjectExpression, name: string): Property["value"] | undefined;
|
|
36
36
|
containsSpreadProps(node: ObjectExpression): boolean;
|
|
37
37
|
updateValue(node: ObjectExpression, propertyName: string, newValue: string, fixer: Rule.RuleFixer): Rule.Fix;
|
|
38
38
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { Rule } from 'eslint';
|
|
3
2
|
import { type Directive, type ImportDeclaration, insertImportDeclaration, type ModuleDeclaration, type Statement } from 'eslint-codemod-utils';
|
|
4
3
|
type ImportData = Parameters<typeof insertImportDeclaration>[1];
|