eslint-plugin-jest 28.13.1 → 28.13.3
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.
|
@@ -80,7 +80,12 @@ var _default = exports.default = (0, _utils2.createRule)({
|
|
|
80
80
|
if (importNode?.type === _utils.AST_NODE_TYPES.ImportDeclaration) {
|
|
81
81
|
for (const specifier of importNode.specifiers) {
|
|
82
82
|
if (specifier.type === _utils.AST_NODE_TYPES.ImportSpecifier && specifier.imported?.name) {
|
|
83
|
-
|
|
83
|
+
let importName = specifier.imported.name;
|
|
84
|
+
const local = (0, _utils2.getAccessorValue)(specifier.local);
|
|
85
|
+
if (local !== importName) {
|
|
86
|
+
importName = `${importName} as ${local}`;
|
|
87
|
+
}
|
|
88
|
+
functionsToImport.add(importName);
|
|
84
89
|
}
|
|
85
90
|
if (specifier.type === _utils.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
86
91
|
functionsToImport.add(specifier.local.name);
|
|
@@ -94,9 +99,17 @@ var _default = exports.default = (0, _utils2.createRule)({
|
|
|
94
99
|
}
|
|
95
100
|
if (requireNode.declarations[0]?.id.type === _utils.AST_NODE_TYPES.ObjectPattern) {
|
|
96
101
|
for (const property of requireNode.declarations[0].id.properties) {
|
|
97
|
-
if (property.type
|
|
98
|
-
|
|
102
|
+
if (property.type !== _utils.AST_NODE_TYPES.Property || !(0, _utils2.isSupportedAccessor)(property.key)) {
|
|
103
|
+
continue;
|
|
99
104
|
}
|
|
105
|
+
let importName = (0, _utils2.getAccessorValue)(property.key);
|
|
106
|
+
if ((0, _utils2.isSupportedAccessor)(property.value)) {
|
|
107
|
+
const local = (0, _utils2.getAccessorValue)(property.value);
|
|
108
|
+
if (importName !== local) {
|
|
109
|
+
importName += `: ${local}`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
functionsToImport.add(importName);
|
|
100
113
|
}
|
|
101
114
|
}
|
|
102
115
|
return fixer.replaceText(requireNode, `${createFixerImports(isModule, functionsToImport)}`);
|