Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/fixtures/linter/rules/NoDeprecatedApi/Controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/UIComponent", "sap/ui/core/routing/History", "sap/m/Button"],
function (Controller, UIComponent, History, Button) {
"use strict";

const BaseController = Controller.extend("com.ui5.troublesome.app.controller.BaseController", {

createButton: function() {
var btn = new Button({
blocked: true
});
return btn;
},
});

const btn = new BaseController().createButton();
btn.attachTap(function() {
console.log("Tapped");
});
return BaseController;
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
sap.ui.define(["sap/ui/core/UIComponent", `sap/ui/Device`], function (UIComponent) {
"use strict";

// Given class name "[...].UIComponent" is identical to an existing variable and therefore must not
// be used for the generated ES class
return UIComponent.extend("com.ui5.troublesome.app.UIComponent", {});
});
18 changes: 18 additions & 0 deletions test/fixtures/transpiler/amd/Factory_ExtendToVar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/UIComponent", "sap/ui/core/routing/History", "sap/m/Button"],
function (Controller, UIComponent, History, Button) {
"use strict";

const BaseController = Controller.extend("com.ui5.troublesome.app.controller.BaseController", {});
BaseController.prototype.createButton = function() {
var btn = new Button({
blocked: true
});
return btn;
};

const btn = new BaseController().createButton();
btn.attachTap(function() {
console.log("Tapped");
});
return BaseController;
});
81 changes: 58 additions & 23 deletions test/lib/linter/amdTranspiler/snapshots/transpiler.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,64 @@ Generated by [AVA](https://avajs.dev).
version: 3,
}

## Transpile Factory_ExtendNameConflict.js

> Snapshot 1

`import UIComponent from "sap/ui/core/UIComponent";␊
import "sap/ui/Device";␊
export default class UIComponent_1 extends UIComponent {␊
}␊
//# sourceMappingURL=Factory_ExtendNameConflict.js.map`

> Snapshot 2

{
file: 'Factory_ExtendNameConflict.js',
mappings: 'OAAsE,WAAW,MAAlE,yBAAyB;OAAE;2CAKlC,WAAW',
names: [],
sourceRoot: '',
sources: [
'Factory_ExtendNameConflict.js',
],
version: 3,
}

## Transpile Factory_ExtendToVar.js

> Snapshot 1

`import Controller from "sap/ui/core/mvc/Controller";␊
import UIComponent from "sap/ui/core/UIComponent";␊
import History from "sap/ui/core/routing/History";␊
import Button from "sap/m/Button";␊
const BaseController = Controller.extend("com.ui5.troublesome.app.controller.BaseController", {});␊
BaseController.prototype.createButton = function () {␊
var btn = new Button({␊
blocked: true␊
});␊
return btn;␊
};␊
const btn = new BaseController().createButton();␊
btn.attachTap(function () {␊
console.log("Tapped");␊
});␊
export default BaseController;␊
//# sourceMappingURL=Factory_ExtendToVar.js.map`

> Snapshot 2

{
file: 'Factory_ExtendToVar.js',
mappings: 'OACW,UAAU,MADN,4BAA4B;OACpB,WAAW,MADW,yBAAyB;OAClC,OAAO,MAD6B,6BAA6B;OACxD,MAAM,MADoD,cAAc;AAIpH,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,mDAAmD,EAAE,EAAE,CAAC,CAAC;AAClG,cAAc,CAAC,SAAS,CAAC,YAAY,GAAG;IACvC,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC;QACpB,OAAO,EAAE,IAAI;KACb,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC,YAAY,EAAE,CAAC;AAChD,GAAG,CAAC,SAAS,CAAC;IACb,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC;eACI,cAAc',
names: [],
sourceRoot: '',
sources: [
'Factory_ExtendToVar.js',
],
version: 3,
}

## Transpile Factory_FunctionVarDeclaration.js

> Snapshot 1
Expand Down Expand Up @@ -711,29 +769,6 @@ Generated by [AVA](https://avajs.dev).
version: 3,
}

## Transpile NameConflict.js

> Snapshot 1

`import UIComponent from "sap/ui/core/UIComponent";␊
import "sap/ui/Device";␊
export default class UIComponent_1 extends UIComponent {␊
}␊
//# sourceMappingURL=NameConflict.js.map`

> Snapshot 2

{
file: 'NameConflict.js',
mappings: 'OAAsE,WAAW,MAAlE,yBAAyB;OAAE;2CAGlC,WAAW',
names: [],
sourceRoot: '',
sources: [
'NameConflict.js',
],
version: 3,
}

## Transpile Noop_DynamicImport.js

> Snapshot 1
Expand Down
Binary file modified test/lib/linter/amdTranspiler/snapshots/transpiler.ts.snap
Binary file not shown.
40 changes: 40 additions & 0 deletions test/lib/linter/rules/snapshots/NoDeprecatedApi.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,46 @@ Generated by [AVA](https://avajs.dev).
},
]

## General: Controller.js

> Snapshot 1

[
{
coverageInfo: [
{
category: 1,
column: 14,
line: 15,
message: 'Unable to analyze this method call because the type of identifier "createButton" in "new BaseController().createButton()"" could not be determined',
},
{
category: 1,
column: 2,
line: 16,
message: `Unable to analyze this method call because the type of identifier "attachTap" in "btn.attachTap(function () {␊
console.log("Tapped");␊
})"" could not be determined`,
},
],
errorCount: 1,
fatalErrorCount: 0,
filePath: 'Controller.js',
messages: [
{
column: 5,
fatal: undefined,
line: 9,
message: 'Use of deprecated property \'blocked\' of class \'Button\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-api',
severity: 2,
},
],
warningCount: 0,
},
]

## General: ModuleImport.js

> Snapshot 1
Expand Down
Binary file modified test/lib/linter/rules/snapshots/NoDeprecatedApi.ts.snap
Binary file not shown.