generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Detect override of control "rerender"
JIRA: CPOUI5FOUNDATION-939
- Loading branch information
Showing
9 changed files
with
564 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
test/fixtures/linter/rules/renderer/ControlRerenderOverride.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
sap.ui.define(["sap/ui/core/Control"], function(Control) { | ||
const Example1 = Control.extend("sap.ui.demo.linter.controls.Example1", { | ||
metadata: {}, | ||
|
||
rerender: function() { | ||
console.log("Overriding rerender method"); | ||
return Control.prototype.rerender.apply(this, arguments); | ||
}, | ||
|
||
renderer: { | ||
apiVersion: 2, | ||
render: function(oRm, oControl) { | ||
oRm.openStart("div", oControl); | ||
oRm.openEnd(); | ||
oRm.close("div"); | ||
} | ||
} | ||
}); | ||
|
||
const Example2 = Control.extend("sap.ui.demo.linter.controls.Example2", { | ||
metadata: {}, | ||
|
||
"rerender": function() { | ||
console.log("Overriding rerender method without calling super method"); | ||
}, | ||
|
||
renderer: { | ||
apiVersion: 2, | ||
render: function(oRm, oControl) { | ||
oRm.openStart("div", oControl); | ||
oRm.openEnd(); | ||
oRm.close("div"); | ||
} | ||
} | ||
}); | ||
|
||
const Example3 = Control.extend("sap.ui.demo.linter.controls.Example3", { | ||
metadata: {}, | ||
|
||
rerender: () => { | ||
console.log("Overriding rerender method without calling super method"); | ||
}, | ||
|
||
renderer: { | ||
apiVersion: 2, | ||
render: function(oRm, oControl) { | ||
oRm.openStart("div", oControl); | ||
oRm.openEnd(); | ||
oRm.close("div"); | ||
} | ||
} | ||
}); | ||
|
||
const Example4 = Control.extend("sap.ui.demo.linter.controls.Example4", { | ||
metadata: {}, | ||
|
||
rerender() { | ||
console.log("Overriding rerender method without calling super method"); | ||
}, | ||
|
||
renderer: { | ||
apiVersion: 2, | ||
render: function(oRm, oControl) { | ||
oRm.openStart("div", oControl); | ||
oRm.openEnd(); | ||
oRm.close("div"); | ||
} | ||
} | ||
}); | ||
|
||
const Example5 = Control.extend("sap.ui.demo.linter.controls.Example5", { | ||
metadata: {}, | ||
|
||
renderer: { | ||
apiVersion: 2, | ||
render: function(oRm, oControl) { | ||
oRm.openStart("div", oControl); | ||
oRm.openEnd(); | ||
oRm.close("div"); | ||
} | ||
} | ||
}); | ||
// TODO detect: Check why this override is currently not detected in JavaScript files. | ||
// The same code is detected properly in ControlRerenderOverrideTypeScript.ts. | ||
Example5.prototype.rerender = function() { | ||
console.log("Overriding rerender method without calling super method"); | ||
}; | ||
|
||
function rerender() { | ||
console.log("Overriding rerender method without calling super method"); | ||
} | ||
|
||
const Example6 = Control.extend("sap.ui.demo.linter.controls.Example6", { | ||
metadata: {}, | ||
|
||
rerender, | ||
|
||
renderer: { | ||
apiVersion: 2, | ||
render: function(oRm, oControl) { | ||
oRm.openStart("div", oControl); | ||
oRm.openEnd(); | ||
oRm.close("div"); | ||
} | ||
} | ||
}); | ||
|
||
const Example7 = Control.extend("sap.ui.demo.linter.controls.Example7", { | ||
metadata: {}, | ||
|
||
rerender: rerender, | ||
|
||
renderer: { | ||
apiVersion: 2, | ||
render: function(oRm, oControl) { | ||
oRm.openStart("div", oControl); | ||
oRm.openEnd(); | ||
oRm.close("div"); | ||
} | ||
} | ||
}); | ||
}); |
125 changes: 125 additions & 0 deletions
125
test/fixtures/linter/rules/renderer/ControlRerenderOverrideTypeScript.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import Control from "sap/ui/core/Control"; | ||
import type { MetadataOptions } from "sap/ui/core/Element"; | ||
import RenderManager from "sap/ui/core/RenderManager"; | ||
|
||
/** | ||
* @namespace sap.ui.demo.linter.controls | ||
*/ | ||
class Example1 extends Control { | ||
static readonly metadata: MetadataOptions = {} | ||
|
||
rerender() { | ||
console.log("Overriding rerender method"); | ||
return super.rerender(); | ||
} | ||
|
||
static renderer = { | ||
apiVersion: 2, | ||
render: function(rm: RenderManager, control: Example1) { | ||
rm.openStart("div", control); | ||
rm.openEnd(); | ||
rm.close("div"); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @namespace sap.ui.demo.linter.controls | ||
*/ | ||
class Example2 extends Control { | ||
static readonly metadata: MetadataOptions = {} | ||
|
||
rerender() { | ||
console.log("Overriding rerender method without calling super method"); | ||
} | ||
|
||
static renderer = { | ||
apiVersion: 2, | ||
render: function(rm: RenderManager, control: Example2) { | ||
rm.openStart("div", control); | ||
rm.openEnd(); | ||
rm.close("div"); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @namespace sap.ui.demo.linter.controls | ||
*/ | ||
class Example3 extends Control { | ||
static readonly metadata: MetadataOptions = {} | ||
|
||
rerender = () => { | ||
console.log("Overriding rerender method without calling super method"); | ||
} | ||
|
||
static renderer = { | ||
apiVersion: 2, | ||
render: function(rm: RenderManager, control: Example3) { | ||
rm.openStart("div", control); | ||
rm.openEnd(); | ||
rm.close("div"); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @namespace sap.ui.demo.linter.controls | ||
*/ | ||
class Example4 extends Control { | ||
static readonly metadata: MetadataOptions = {} | ||
|
||
rerender = function() { | ||
console.log("Overriding rerender method without calling super method"); | ||
} | ||
|
||
static renderer = { | ||
apiVersion: 2, | ||
render: function(rm: RenderManager, control: Example4) { | ||
rm.openStart("div", control); | ||
rm.openEnd(); | ||
rm.close("div"); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @namespace sap.ui.demo.linter.controls | ||
*/ | ||
class Example5 extends Control { | ||
static readonly metadata: MetadataOptions = {} | ||
|
||
static renderer = { | ||
apiVersion: 2, | ||
render: function(rm: RenderManager, control: Example5) { | ||
rm.openStart("div", control); | ||
rm.openEnd(); | ||
rm.close("div"); | ||
} | ||
} | ||
} | ||
Example5.prototype.rerender = function() { | ||
console.log("Overriding rerender method without calling super method"); | ||
}; | ||
|
||
function rerender() { | ||
console.log("Overriding rerender method without calling super method"); | ||
} | ||
|
||
/** | ||
* @namespace sap.ui.demo.linter.controls | ||
*/ | ||
class Example6 extends Control { | ||
static readonly metadata: MetadataOptions = {} | ||
|
||
rerender = rerender | ||
|
||
static renderer = { | ||
apiVersion: 2, | ||
render: function(rm: RenderManager, control: Example6) { | ||
rm.openStart("div", control); | ||
rm.openEnd(); | ||
rm.close("div"); | ||
} | ||
} | ||
} |
Oops, something went wrong.