diff --git a/src/linter/ui5Types/SourceFileLinter.ts b/src/linter/ui5Types/SourceFileLinter.ts index 6725a50b3..7f4ca752f 100644 --- a/src/linter/ui5Types/SourceFileLinter.ts +++ b/src/linter/ui5Types/SourceFileLinter.ts @@ -700,7 +700,7 @@ export default class SourceFileLinter { } else if (moduleDeclaration?.name.text === "sap/ui/model/odata/v4/ODataModel") { this.#analyzeNewOdataModelV4(node); } else if (nodeType.symbol.declarations?.some( - (declaration) => this.isUi5ClassDeclaration(declaration, "sap/ui/core/Control"))) { + (declaration) => this.isUi5ClassDeclaration(declaration, "sap/ui/base/ManagedObject"))) { const originalFilename = this.#metadata?.xmlCompiledResource; // Do not process xml-s. This case would be handled separately within the BindingParser if (!originalFilename || diff --git a/test/fixtures/linter/rules/NoGlobals/FormatterGlobalBindingString.js b/test/fixtures/linter/rules/NoGlobals/FormatterGlobalBindingString.js index b90dbd68d..fe7f087eb 100644 --- a/test/fixtures/linter/rules/NoGlobals/FormatterGlobalBindingString.js +++ b/test/fixtures/linter/rules/NoGlobals/FormatterGlobalBindingString.js @@ -1,6 +1,6 @@ sap.ui.define( - ["sap/m/Input", "ui5/walkthrough/model/formatter"], - (Input, formatter) => { + ["sap/m/Input", "sap/ui/table/RowSettings", "ui5/walkthrough/model/formatter"], + (Input, RowSettings, formatter) => { // The following two cases using global notations should be detected: const input = new Input({ value: "{ path: 'invoice>Status', formatter: 'ui5.walkthrough.model.formatter.statusText' }" @@ -14,5 +14,14 @@ sap.ui.define( const input2 = new Input({ value: "{ path: 'invoice>Status', formatter: 'formatter.statusText' }" }); + + // Note: RowSettings is an element, not a control (bindings are supported for all ManagedObject sub-classes) + const rowSettings = new RowSettings({ + highlight: "{ path: 'invoice>Status', formatter: 'ui5.walkthrough.model.formatter.statusText' }", + }); + + rowSettings.applySettings({ + highlight: "{ path: 'invoice>Status', formatter: 'ui5.walkthrough.model.formatter.statusText' }", + }); } ); diff --git a/test/fixtures/linter/rules/NoGlobals/ModelDataTypes_New.js b/test/fixtures/linter/rules/NoGlobals/ModelDataTypes_New.js index 887a2b679..1cad5c5ed 100644 --- a/test/fixtures/linter/rules/NoGlobals/ModelDataTypes_New.js +++ b/test/fixtures/linter/rules/NoGlobals/ModelDataTypes_New.js @@ -1,4 +1,4 @@ -sap.ui.define(["sap/m/Input"], (Input) => { +sap.ui.define(["sap/m/Input", "sap/ui/table/RowSettings"], (Input, RowSettings) => { const input = new Input({ value: { path: "/names/0/amount", @@ -7,7 +7,7 @@ sap.ui.define(["sap/m/Input"], (Input) => { constraints: { maximum: 1000 }, }, }); - + input.applySettings({ value: { path: "/names/0/amount", @@ -16,4 +16,19 @@ sap.ui.define(["sap/m/Input"], (Input) => { constraints: { maximum: 1000 }, }, }); + + // Note: RowSettings is an element, not a control (bindings are supported for all ManagedObject sub-classes) + const rowSettings = new RowSettings({ + highlight: { + path: "/names/0/amount", + type: "sap.ui.model.type.Integer" + } + }); + + rowSettings.applySettings({ + highlight: { + path: "/names/0/amount", + type: "sap.ui.model.type.Integer" + } + }); }); diff --git a/test/fixtures/linter/rules/NoGlobals/ModelDataTypes_NewString.js b/test/fixtures/linter/rules/NoGlobals/ModelDataTypes_NewString.js index 728e8e057..561e2e1c6 100644 --- a/test/fixtures/linter/rules/NoGlobals/ModelDataTypes_NewString.js +++ b/test/fixtures/linter/rules/NoGlobals/ModelDataTypes_NewString.js @@ -1,9 +1,18 @@ -sap.ui.define(["sap/m/Input"], (Input) => { +sap.ui.define(["sap/m/Input", "sap/ui/table/RowSettings"], (Input, RowSettings) => { const input = new Input({ value: "{ path: '/names/0/amount', type: 'sap.ui.model.type.Integer' }", }); - + input.applySettings({ value: "{ path: '/names/0/amount', type: 'sap.ui.model.type.Integer' }", }); + + // Note: RowSettings is an element, not a control (bindings are supported for all ManagedObject sub-classes) + const rowSettings = new RowSettings({ + highlight: "{ path: '/names/0/amount', type: 'sap.ui.model.type.Integer' }", + }); + + rowSettings.applySettings({ + highlight: "{ path: '/names/0/amount', type: 'sap.ui.model.type.Integer' }", + }); }); diff --git a/test/lib/linter/rules/snapshots/NoGlobals.ts.md b/test/lib/linter/rules/snapshots/NoGlobals.ts.md index 0899ec6c2..2863c3a57 100644 --- a/test/lib/linter/rules/snapshots/NoGlobals.ts.md +++ b/test/lib/linter/rules/snapshots/NoGlobals.ts.md @@ -35,7 +35,7 @@ Generated by [AVA](https://avajs.dev). [ { coverageInfo: [], - errorCount: 3, + errorCount: 5, fatalErrorCount: 0, filePath: 'FormatterGlobalBindingString.js', messages: [ @@ -63,6 +63,22 @@ Generated by [AVA](https://avajs.dev). ruleId: 'no-globals', severity: 2, }, + { + column: 15, + line: 20, + message: 'Access of global variable \'ui5\' (ui5.walkthrough.model.formatter.statusText)', + messageDetails: 'Do not use global variables to access UI5 modules or APIs. See Best Practices for Developers (https://ui5.sap.com/#/topic/28fcd55b04654977b63dacbee0552712)', + ruleId: 'no-globals', + severity: 2, + }, + { + column: 15, + line: 24, + message: 'Access of global variable \'ui5\' (ui5.walkthrough.model.formatter.statusText)', + messageDetails: 'Do not use global variables to access UI5 modules or APIs. See Best Practices for Developers (https://ui5.sap.com/#/topic/28fcd55b04654977b63dacbee0552712)', + ruleId: 'no-globals', + severity: 2, + }, ], warningCount: 0, }, @@ -279,7 +295,7 @@ Generated by [AVA](https://avajs.dev). [ { coverageInfo: [], - errorCount: 2, + errorCount: 4, fatalErrorCount: 0, filePath: 'ModelDataTypes_New.js', messages: [ @@ -299,6 +315,22 @@ Generated by [AVA](https://avajs.dev). ruleId: 'no-globals', severity: 2, }, + { + column: 10, + line: 24, + message: 'Access of global variable \'sap.ui.model.type.Integer\' (sap/ui/model/type/Integer)', + messageDetails: 'Do not use global variables to access UI5 modules or APIs. See Best Practices for Developers (https://ui5.sap.com/#/topic/28fcd55b04654977b63dacbee0552712)', + ruleId: 'no-globals', + severity: 2, + }, + { + column: 10, + line: 31, + message: 'Access of global variable \'sap.ui.model.type.Integer\' (sap/ui/model/type/Integer)', + messageDetails: 'Do not use global variables to access UI5 modules or APIs. See Best Practices for Developers (https://ui5.sap.com/#/topic/28fcd55b04654977b63dacbee0552712)', + ruleId: 'no-globals', + severity: 2, + }, ], warningCount: 0, }, @@ -326,7 +358,7 @@ Generated by [AVA](https://avajs.dev). [ { coverageInfo: [], - errorCount: 2, + errorCount: 4, fatalErrorCount: 0, filePath: 'ModelDataTypes_NewString.js', messages: [ @@ -346,6 +378,22 @@ Generated by [AVA](https://avajs.dev). ruleId: 'no-globals', severity: 2, }, + { + column: 14, + line: 12, + message: 'Access of global variable \'sap\' (sap.ui.model.type.Integer)', + messageDetails: 'Do not use global variables to access UI5 modules or APIs. See Best Practices for Developers (https://ui5.sap.com/#/topic/28fcd55b04654977b63dacbee0552712)', + ruleId: 'no-globals', + severity: 2, + }, + { + column: 14, + line: 16, + message: 'Access of global variable \'sap\' (sap.ui.model.type.Integer)', + messageDetails: 'Do not use global variables to access UI5 modules or APIs. See Best Practices for Developers (https://ui5.sap.com/#/topic/28fcd55b04654977b63dacbee0552712)', + ruleId: 'no-globals', + severity: 2, + }, ], warningCount: 0, }, diff --git a/test/lib/linter/rules/snapshots/NoGlobals.ts.snap b/test/lib/linter/rules/snapshots/NoGlobals.ts.snap index eb758c3c9..8f280c043 100644 Binary files a/test/lib/linter/rules/snapshots/NoGlobals.ts.snap and b/test/lib/linter/rules/snapshots/NoGlobals.ts.snap differ