@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
|
@@ -25,7 +25,7 @@ const 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 @@ const rule = createLintRule({
|
|
|
20
20
|
ImportDeclaration(node) {
|
|
21
21
|
if (node.type === 'ImportDeclaration' && (node.source.value === '../src' || node.source.value === '@atlaskit/primitives')) {
|
|
22
22
|
node.specifiers.forEach(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 @@ const rule = createLintRule({
|
|
|
26
26
|
const buttonGroupIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(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
|
});
|
|
@@ -56,11 +56,11 @@ const rule = createLintRule({
|
|
|
56
56
|
specialFieldsByImport[source].local = defaultImport[0].local.name;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
if ('@atlaskit/form'
|
|
59
|
+
if (source !== '@atlaskit/form') {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
const namedImport = node.specifiers.filter(spec => isNodeOfType(spec, 'ImportSpecifier'));
|
|
63
|
-
if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && namedImport[0].imported.name === 'Field') {
|
|
63
|
+
if (namedImport.length && namedImport[0].type === 'ImportSpecifier' && 'name' in namedImport[0].imported && namedImport[0].imported.name === 'Field') {
|
|
64
64
|
fieldImport = namedImport[0].local;
|
|
65
65
|
}
|
|
66
66
|
},
|
|
@@ -24,7 +24,7 @@ const rule = createLintRule({
|
|
|
24
24
|
node
|
|
25
25
|
};
|
|
26
26
|
for (const specifier of node.specifiers) {
|
|
27
|
-
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'cx') {
|
|
27
|
+
if (specifier.type === 'ImportSpecifier' && 'name' in specifier.imported && specifier.imported.name === 'cx') {
|
|
28
28
|
importStatement.cxFuncLocalName = specifier.local.name;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -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
|
}
|
|
@@ -73,21 +75,31 @@ const rule = createLintRule({
|
|
|
73
75
|
return;
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
// Add expression
|
|
78
|
+
// Add expression container's body if an expression container
|
|
77
79
|
if (isNodeOfType(node, 'JSXExpressionContainer')) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
const expression = node.expression;
|
|
81
|
+
if (isNodeOfType(expression, 'ArrowFunctionExpression') || isNodeOfType(expression, 'FunctionExpression')) {
|
|
82
|
+
if (isNodeOfType(expression.body, 'JSXElement') || isNodeOfType(expression.body, 'JSXFragment')) {
|
|
83
|
+
searchExpression(expression.body);
|
|
84
|
+
} else if (isNodeOfType(expression.body, 'BlockStatement')) {
|
|
85
|
+
expression.body.body.forEach(statement => {
|
|
86
|
+
if (isNodeOfType(statement, 'ReturnStatement') && statement.argument) {
|
|
87
|
+
searchExpression(statement.argument);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
} else if (isNodeOfType(expression, 'LogicalExpression')) {
|
|
81
92
|
const {
|
|
82
93
|
left,
|
|
83
94
|
right
|
|
84
|
-
} =
|
|
95
|
+
} = expression;
|
|
85
96
|
[left, right].forEach(e => {
|
|
86
|
-
|
|
87
|
-
searchNode(e, true);
|
|
88
|
-
}
|
|
97
|
+
searchExpression(e);
|
|
89
98
|
});
|
|
99
|
+
} else {
|
|
100
|
+
searchExpression(expression);
|
|
90
101
|
}
|
|
102
|
+
return;
|
|
91
103
|
}
|
|
92
104
|
|
|
93
105
|
// Skip if not a JSX Element
|
|
@@ -110,6 +122,13 @@ const rule = createLintRule({
|
|
|
110
122
|
searchNode(node);
|
|
111
123
|
}
|
|
112
124
|
};
|
|
125
|
+
const searchExpression = expression => {
|
|
126
|
+
if (isNodeOfType(expression, 'JSXElement')) {
|
|
127
|
+
searchNode(expression, true);
|
|
128
|
+
} else if (isNodeOfType(expression, 'JSXFragment')) {
|
|
129
|
+
searchJSXFragment(expression);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
113
132
|
const searchNode = (node, searchSelf = false) => {
|
|
114
133
|
if (searchSelf) {
|
|
115
134
|
checkNode(node);
|
|
@@ -118,6 +137,13 @@ const rule = createLintRule({
|
|
|
118
137
|
checkNode(child);
|
|
119
138
|
}
|
|
120
139
|
};
|
|
140
|
+
const searchJSXFragment = node => {
|
|
141
|
+
if (isNodeOfType(node, 'JSXFragment')) {
|
|
142
|
+
for (let child of node.children) {
|
|
143
|
+
checkNode(child);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
121
147
|
if (name === defaultImportLocalName) {
|
|
122
148
|
searchNode(node);
|
|
123
149
|
|
|
@@ -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') {
|
|
@@ -76,20 +76,29 @@ var rule = createLintRule({
|
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
// Add expression
|
|
79
|
+
// Add expression container's body if an expression container
|
|
80
80
|
if (isNodeOfType(node, 'JSXExpressionContainer')) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
var expression = node.expression;
|
|
82
|
+
if (isNodeOfType(expression, 'ArrowFunctionExpression') || isNodeOfType(expression, 'FunctionExpression')) {
|
|
83
|
+
if (isNodeOfType(expression.body, 'JSXElement') || isNodeOfType(expression.body, 'JSXFragment')) {
|
|
84
|
+
searchExpression(expression.body);
|
|
85
|
+
} else if (isNodeOfType(expression.body, 'BlockStatement')) {
|
|
86
|
+
expression.body.body.forEach(function (statement) {
|
|
87
|
+
if (isNodeOfType(statement, 'ReturnStatement') && statement.argument) {
|
|
88
|
+
searchExpression(statement.argument);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
} else if (isNodeOfType(expression, 'LogicalExpression')) {
|
|
93
|
+
var left = expression.left,
|
|
94
|
+
right = expression.right;
|
|
87
95
|
[left, right].forEach(function (e) {
|
|
88
|
-
|
|
89
|
-
searchNode(e, true);
|
|
90
|
-
}
|
|
96
|
+
searchExpression(e);
|
|
91
97
|
});
|
|
98
|
+
} else {
|
|
99
|
+
searchExpression(expression);
|
|
92
100
|
}
|
|
101
|
+
return;
|
|
93
102
|
}
|
|
94
103
|
|
|
95
104
|
// Skip if not a JSX Element
|
|
@@ -112,6 +121,13 @@ var rule = createLintRule({
|
|
|
112
121
|
searchNode(node);
|
|
113
122
|
}
|
|
114
123
|
};
|
|
124
|
+
var searchExpression = function searchExpression(expression) {
|
|
125
|
+
if (isNodeOfType(expression, 'JSXElement')) {
|
|
126
|
+
searchNode(expression, true);
|
|
127
|
+
} else if (isNodeOfType(expression, 'JSXFragment')) {
|
|
128
|
+
searchJSXFragment(expression);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
115
131
|
var searchNode = function searchNode(node) {
|
|
116
132
|
var searchSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
117
133
|
if (searchSelf) {
|
|
@@ -130,6 +146,22 @@ var rule = createLintRule({
|
|
|
130
146
|
_iterator.f();
|
|
131
147
|
}
|
|
132
148
|
};
|
|
149
|
+
var searchJSXFragment = function searchJSXFragment(node) {
|
|
150
|
+
if (isNodeOfType(node, 'JSXFragment')) {
|
|
151
|
+
var _iterator2 = _createForOfIteratorHelper(node.children),
|
|
152
|
+
_step2;
|
|
153
|
+
try {
|
|
154
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
155
|
+
var child = _step2.value;
|
|
156
|
+
checkNode(child);
|
|
157
|
+
}
|
|
158
|
+
} catch (err) {
|
|
159
|
+
_iterator2.e(err);
|
|
160
|
+
} finally {
|
|
161
|
+
_iterator2.f();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
133
165
|
if (name === defaultImportLocalName) {
|
|
134
166
|
searchNode(node);
|
|
135
167
|
|