Skip to content

Commit 4c6c33d

Browse files
committed
fix: Handle more cases of existing dependencies
1 parent 4060fbd commit 4c6c33d

8 files changed

+103
-53
lines changed

test/fixtures/autofix/GlobalsExistingDefineWithAllExistingDeps.js

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sap.ui.define(["sap/m/Button", "sap/m/Input"], function(Button, Input) {
2+
"use strict";
3+
4+
new sap.m.Input();
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sap.ui.define(["sap/m/Button"], function(Button) {
2+
"use strict";
3+
4+
new sap.m.Button();
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sap.ui.define(["sap/m/Button", "sap/m/Input"], function() {
2+
"use strict";
3+
4+
new sap.m.Input();
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sap.ui.define(["sap/m/Button"], function() {
2+
"use strict";
3+
4+
new sap.m.Button();
5+
});

test/fixtures/autofix/GlobalsExistingDefineWithUnusedDeps.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -131,33 +131,6 @@ Generated by [AVA](https://avajs.dev).
131131
},
132132
]
133133

134-
## General: GlobalsExistingDefineWithAllExistingDeps.js
135-
136-
> Snapshot 1
137-
138-
[
139-
{
140-
coverageInfo: [],
141-
errorCount: 0,
142-
fatalErrorCount: 0,
143-
filePath: 'GlobalsExistingDefineWithAllExistingDeps.js',
144-
messages: [],
145-
warningCount: 0,
146-
},
147-
]
148-
149-
> AutofixResult: /GlobalsExistingDefineWithAllExistingDeps.js
150-
151-
`sap.ui.define(["sap/m/Button"], function(Button) {␊
152-
const button1 = new Button({␊
153-
text: "Hello"␊
154-
});␊
155-
const button2 = new Button({␊
156-
text: "Hello"␊
157-
});␊
158-
});␊
159-
`
160-
161134
## General: GlobalsExistingDefineWithDeps.js
162135

163136
> Snapshot 1
@@ -512,7 +485,7 @@ Generated by [AVA](https://avajs.dev).
512485
});␊
513486
`
514487

515-
## General: GlobalsExistingDefineWithTrailingCommas.js
488+
## General: GlobalsExistingDefineWithExistingDepsMultiple.js
516489

517490
> Snapshot 1
518491
@@ -521,23 +494,22 @@ Generated by [AVA](https://avajs.dev).
521494
coverageInfo: [],
522495
errorCount: 0,
523496
fatalErrorCount: 0,
524-
filePath: 'GlobalsExistingDefineWithTrailingCommas.js',
497+
filePath: 'GlobalsExistingDefineWithExistingDepsMultiple.js',
525498
messages: [],
526499
warningCount: 0,
527500
},
528501
]
529502

530-
> AutofixResult: /GlobalsExistingDefineWithTrailingCommas.js
503+
> AutofixResult: /GlobalsExistingDefineWithExistingDepsMultiple.js
531504
532-
`sap.ui.define(["sap/m/Button", "sap/ui/model/json/JSONModel",], function(Button, JSONModel,) {␊
533-
const button = new Button({␊
534-
text: "Hello"␊
535-
});␊
536-
var model = new JSONModel();␊
505+
`sap.ui.define(["sap/m/Button", "sap/m/Input"], function(Button, Input, Button, Input) {␊
506+
"use strict";␊
507+
508+
new Input();␊
537509
});␊
538510
`
539511

540-
## General: GlobalsExistingDefineWithUnusedDeps.js
512+
## General: GlobalsExistingDefineWithExistingDepsSingle.js
541513

542514
> Snapshot 1
543515
@@ -546,19 +518,91 @@ Generated by [AVA](https://avajs.dev).
546518
coverageInfo: [],
547519
errorCount: 0,
548520
fatalErrorCount: 0,
549-
filePath: 'GlobalsExistingDefineWithUnusedDeps.js',
521+
filePath: 'GlobalsExistingDefineWithExistingDepsSingle.js',
550522
messages: [],
551523
warningCount: 0,
552524
},
553525
]
554526

555-
> AutofixResult: /GlobalsExistingDefineWithUnusedDeps.js
527+
> AutofixResult: /GlobalsExistingDefineWithExistingDepsSingle.js
556528
557-
`sap.ui.define(["sap/ui/core/Control", "sap/m/Button"], function(Control, Button) {␊
529+
`sap.ui.define(["sap/m/Button"], function(Button) {␊
558530
"use strict";␊
559531
560532
new Button();␊
533+
});␊
534+
`
535+
536+
## General: GlobalsExistingDefineWithExistingUnusedDepsMultiple.js
537+
538+
> Snapshot 1
539+
540+
[
541+
{
542+
coverageInfo: [],
543+
errorCount: 0,
544+
fatalErrorCount: 0,
545+
filePath: 'GlobalsExistingDefineWithExistingUnusedDepsMultiple.js',
546+
messages: [],
547+
warningCount: 0,
548+
},
549+
]
550+
551+
> AutofixResult: /GlobalsExistingDefineWithExistingUnusedDepsMultiple.js
552+
553+
`sap.ui.define(["sap/m/Button", "sap/m/Input"], function(Button, Input) {␊
554+
"use strict";␊
555+
556+
new Input();␊
557+
});␊
558+
`
559+
560+
## General: GlobalsExistingDefineWithExistingUnusedDepsSingle.js
561+
562+
> Snapshot 1
563+
564+
[
565+
{
566+
coverageInfo: [],
567+
errorCount: 0,
568+
fatalErrorCount: 0,
569+
filePath: 'GlobalsExistingDefineWithExistingUnusedDepsSingle.js',
570+
messages: [],
571+
warningCount: 0,
572+
},
573+
]
574+
575+
> AutofixResult: /GlobalsExistingDefineWithExistingUnusedDepsSingle.js
576+
577+
`sap.ui.define(["sap/m/Button"], function() {␊
578+
"use strict";␊
561579
580+
new Button();␊
581+
});␊
582+
`
583+
584+
## General: GlobalsExistingDefineWithTrailingCommas.js
585+
586+
> Snapshot 1
587+
588+
[
589+
{
590+
coverageInfo: [],
591+
errorCount: 0,
592+
fatalErrorCount: 0,
593+
filePath: 'GlobalsExistingDefineWithTrailingCommas.js',
594+
messages: [],
595+
warningCount: 0,
596+
},
597+
]
598+
599+
> AutofixResult: /GlobalsExistingDefineWithTrailingCommas.js
600+
601+
`sap.ui.define(["sap/m/Button", "sap/ui/model/json/JSONModel",], function(Button, JSONModel,) {␊
602+
const button = new Button({␊
603+
text: "Hello"␊
604+
});␊
605+
var model = new JSONModel();␊
562606
});␊
563607
`
564608

107 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)