From 0843787284847d083f35de041c8ac356e18f01f1 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Tue, 26 Nov 2024 09:45:11 +0100 Subject: [PATCH] test: Add fixtures for rerender override detection --- .../rules/renderer/ControlRerenderOverride.js | 36 +++++++++ .../rules/renderer/ControlRerenderOverride.ts | 44 +++++++++++ .../lib/linter/rules/snapshots/renderer.ts.md | 71 ++++++++++++++++++ .../linter/rules/snapshots/renderer.ts.snap | Bin 4273 -> 4708 bytes 4 files changed, 151 insertions(+) create mode 100644 test/fixtures/linter/rules/renderer/ControlRerenderOverride.js create mode 100644 test/fixtures/linter/rules/renderer/ControlRerenderOverride.ts diff --git a/test/fixtures/linter/rules/renderer/ControlRerenderOverride.js b/test/fixtures/linter/rules/renderer/ControlRerenderOverride.js new file mode 100644 index 000000000..7012be717 --- /dev/null +++ b/test/fixtures/linter/rules/renderer/ControlRerenderOverride.js @@ -0,0 +1,36 @@ +sap.ui.define(["sap/ui/core/Control"], function(Control, Button) { + 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"); + } + } + }); +}); diff --git a/test/fixtures/linter/rules/renderer/ControlRerenderOverride.ts b/test/fixtures/linter/rules/renderer/ControlRerenderOverride.ts new file mode 100644 index 000000000..b77ac049d --- /dev/null +++ b/test/fixtures/linter/rules/renderer/ControlRerenderOverride.ts @@ -0,0 +1,44 @@ +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: Example1) { + rm.openStart("div", control); + rm.openEnd(); + rm.close("div"); + } + } +} diff --git a/test/lib/linter/rules/snapshots/renderer.ts.md b/test/lib/linter/rules/snapshots/renderer.ts.md index ff4bd1f9f..01516aa28 100644 --- a/test/lib/linter/rules/snapshots/renderer.ts.md +++ b/test/lib/linter/rules/snapshots/renderer.ts.md @@ -475,6 +475,77 @@ Generated by [AVA](https://avajs.dev). ], warningCount: 0, }, + { + coverageInfo: [ + { + category: 1, + column: 5, + line: 13, + message: 'Unable to analyze this method call because the type of identifier "openStart" in "oRm.openStart("div", oControl)"" could not be determined', + }, + { + category: 1, + column: 5, + line: 14, + message: 'Unable to analyze this method call because the type of identifier "openEnd" in "oRm.openEnd()"" could not be determined', + }, + { + category: 1, + column: 5, + line: 15, + message: 'Unable to analyze this method call because the type of identifier "close" in "oRm.close("div")"" could not be determined', + }, + { + category: 1, + column: 5, + line: 30, + message: 'Unable to analyze this method call because the type of identifier "openStart" in "oRm.openStart("div", oControl)"" could not be determined', + }, + { + category: 1, + column: 5, + line: 31, + message: 'Unable to analyze this method call because the type of identifier "openEnd" in "oRm.openEnd()"" could not be determined', + }, + { + category: 1, + column: 5, + line: 32, + message: 'Unable to analyze this method call because the type of identifier "close" in "oRm.close("div")"" could not be determined', + }, + ], + errorCount: 1, + fatalErrorCount: 0, + filePath: 'ControlRerenderOverride.js', + messages: [ + { + column: 11, + line: 7, + message: 'Use of deprecated property \'rerender\'', + messageDetails: 'Deprecated test message', + ruleId: 'no-deprecated-api', + severity: 2, + }, + ], + warningCount: 0, + }, + { + coverageInfo: [], + errorCount: 1, + fatalErrorCount: 0, + filePath: 'ControlRerenderOverride.ts', + messages: [ + { + column: 16, + line: 13, + message: 'Call to deprecated function \'rerender\' (super.rerender)', + messageDetails: 'Deprecated test message', + ruleId: 'no-deprecated-api', + severity: 2, + }, + ], + warningCount: 0, + }, { coverageInfo: [], errorCount: 3, diff --git a/test/lib/linter/rules/snapshots/renderer.ts.snap b/test/lib/linter/rules/snapshots/renderer.ts.snap index 5d71d97c6bb4b24b8ec972a1705ec475bdfea746..9d09603dae75e06999884f0d6a7901f6c97b63c4 100644 GIT binary patch literal 4708 zcmV-q5}WNoRzVqaTY100000000B+oC|Oq#hJ%{D_d__Z`ok2z&aHhX4tLBu9#bt8jz_4ililT`D2Tg#=Q^n>$ER+~pu}SK$hBghz1% zIPN$ggyYy;BMeo zz&`-L0iFk51>ONZ0#Y21=YV1dlsll#0qa8FCFM90Hv|Imu)`5aWo2dINW+nbBi-TH z>IhYy?r>b~0EZ)#d@z_y2qixZCTE0_4GG|w8A=`tCKE%+9|n_2q2#NB|%rxNOvUd>^`EnO-F*2%+AgZp;siqSCZiN zBzPYBtuQIfTr8fwq!Vv3`5CqQ!+f54F8i1nJEIAX+vvLpfLs7Q(!O!Zcc$G zQs5;K&9$LPsgRKhOHyH5Dg;vDmQ?sS(BGxP?^EI9RFKkOQyK));Mz0+U0_3h zoCZHngQwHr-83jnhn?x5rVHp|8+vUzT%Qhir^COb!~5y5Fay?R2o( z9?2BYwKnvXOn4&`(z2i;3-)BeSF+&NECJnULm$b4C$iwxEJ)1;S2he}!#A@9bh{1x zSvK684bNr62iY($2fA`#Fh@Z5+R&SF;MN?tKL=jSfuvmM%mpJ?KrgnTH{`^r@?cFKbmR%>Asc#W9$b+Jx8%WtdGJae%+H5a`2woi&`a{clMi3Yhuibv*ZJ^X zKI9Y#sLv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