Skip to content

Commit a4ad5e2

Browse files
committed
refactor: Remove destructuring support
1 parent ef0548c commit a4ad5e2

File tree

4 files changed

+7
-24
lines changed

4 files changed

+7
-24
lines changed

src/autofix/autofix.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function addDependencies(
249249
throw new Error("Invalid factory function");
250250
}
251251
const existingIdentifiers = moduleDeclaration.factory
252-
.parameters.map((param: ts.ParameterDeclaration) => (param.name as ts.Identifier).text ?? "__destructured__");
252+
.parameters.map((param: ts.ParameterDeclaration) => (param.name as ts.Identifier).text);
253253
const existingIdentifiersLength = existingIdentifiers.length;
254254

255255
const imports = [...importRequests.keys()];
@@ -262,9 +262,7 @@ function addDependencies(
262262
resolveUniqueName(existingModule, declaredIdentifiers);
263263
declaredIdentifiers.add(identifierName);
264264
identifiersForExistingImports.push(identifierName);
265-
if (indexOf !== -1 &&
266-
// Destructuring
267-
!(indexOf === index && existingIdentifiers[index] === "__destructured__")) {
265+
if (indexOf !== -1) {
268266
// If there are defined dependencies, but identifiers for them are missing,
269267
// and those identifiers are needed in the code, then we need to find out
270268
// up to which index we need to build identifiers and cut the rest.

test/fixtures/autofix/GlobalsExistingDefineWithDeps.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
sap.ui.define(["sap/m/Button", "sap/m/library", "sap/m/Avatar", "sap/m/ComboBox"], function(ButtonRenamed, { BackgroundDesign }) {
1+
sap.ui.define(["sap/m/Button", "sap/m/Avatar", "sap/m/ComboBox"], function(ButtonRenamed) {
22
const avatarDOM = jQuery("#container-todo---app--avatar-profile");
33
const list = sap.ui.getCore().byId("container-todo---app--todoList");
44
sap.m.BackgroundDesign.Solid
5-
const myDesign = BackgroundDesign.Solid;
65
const button = new sap.m.Button({
76
text: "Hello"
87
});

test/lib/autofix/snapshots/autofix.ts.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,7 @@ Generated by [AVA](https://avajs.dev).
164164
165165
[
166166
{
167-
coverageInfo: [
168-
{
169-
category: 1,
170-
column: 20,
171-
line: 2,
172-
message: 'Unable to analyze this method call because the type of identifier in "jQuery("#container-todo---app--avatar-profile")"" could not be determined',
173-
},
174-
{
175-
category: 1,
176-
column: 2,
177-
line: 23,
178-
message: 'Unable to analyze this method call because the type of identifier "triggerSms" in "mLibrary.URLHelper.triggerSms()"" could not be determined',
179-
},
180-
],
167+
coverageInfo: [],
181168
errorCount: 5,
182169
fatalErrorCount: 0,
183170
filePath: 'GlobalsExistingDefineWithDeps.js',
@@ -208,15 +195,15 @@ Generated by [AVA](https://avajs.dev).
208195
},
209196
{
210197
column: 2,
211-
line: 22,
198+
line: 21,
212199
message: 'Access of global variable \'sap\' (sap.ui.view)',
213200
messageDetails: 'Do not use global variables to access UI5 modules or APIs. See Best Practices for Developers (https://ui5.sap.com/#/topic/28fcd55b04654977b63dacbee0552712)',
214201
ruleId: 'no-globals',
215202
severity: 2,
216203
},
217204
{
218205
column: 9,
219-
line: 22,
206+
line: 21,
220207
message: 'Call to deprecated function \'view\' (sap.ui.view)',
221208
messageDetails: 'Deprecated test message',
222209
ruleId: 'no-deprecated-api',
@@ -229,11 +216,10 @@ Generated by [AVA](https://avajs.dev).
229216

230217
> AutofixResult: /GlobalsExistingDefineWithDeps.js
231218
232-
`sap.ui.define(["sap/m/Button", "sap/m/library", "sap/ui/thirdparty/jquery", "sap/m/library", "sap/ui/unified/FileUploader", "sap/ui/core/library", "sap/f/library", "sap/m/Avatar", "sap/m/ComboBox"], function(ButtonRenamed, { BackgroundDesign }, jQuery, mLibrary, FileUploader, coreLibrary, fLibrary) {␊
219+
`sap.ui.define(["sap/m/Button", "sap/ui/thirdparty/jquery", "sap/m/library", "sap/ui/unified/FileUploader", "sap/ui/core/library", "sap/f/library", "sap/m/Avatar", "sap/m/ComboBox"], function(ButtonRenamed, jQuery, mLibrary, FileUploader, coreLibrary, fLibrary) {␊
233220
const avatarDOM = jQuery("#container-todo---app--avatar-profile");␊
234221
const list = sap.ui.getCore().byId("container-todo---app--todoList");␊
235222
mLibrary.BackgroundDesign.Solid␊
236-
const myDesign = BackgroundDesign.Solid;␊
237223
const button = new ButtonRenamed({␊
238224
text: "Hello"␊
239225
});␊
-34 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)