Unexpected aliasing of 'this' to local variable
134 this.minZoom = 0.0001;
135 this.maxZoom = 5;
136 this.setupTools();
137 const ref = this; 138 EventBus.get().on(EventBus.UPDATE_RENDERS, function(feature, refresh = true) {
139 if (ref.ensureFeatureExists(feature)) {
140 ref.view.updateFeature(feature);
Unexpected aliasing of 'this' to local variable
99 this.tools = {};
100 this.rightMouseTool = new SelectTool(this);
101 this.__currentDevice = null;
102 const reference = this; 103 this.updateQueue = new SimpleQueue(function() {
104 reference.view.refresh();
105 }, 20);
Unexpected aliasing of 'this' to local variable
31 super(viewManagerDelegate, threeduftype, setString, currentParameters);
32 this.valveType = valveType;
33
34 const ref = this; 35
36 this.down = function (event: MouseEvent) {
37 console.log(event);
Unexpected aliasing of 'this' to local variable
28 this.lastPoint = null;
29 this.currentSelectBox = null;
30 this.currentSelection = [];
31 const ref = this; 32 this.updateQueue = new SimpleQueue(function() {
33 ref.dragHandler();
34 }, 20);
Unexpected aliasing of 'this' to local variable
36 this.lastPoint = null;
37 this.currentSelectBox = null;
38 this.currentSelection = [];
39 const ref = this; 40 this.updateQueue = new SimpleQueue(function () {
41 ref.dragHandler();
42 }, 20);
Unexpected aliasing of 'this' to local variable
31 this.setString = "Basic";
32 this.currentFeatureID = null;
33 this.currentParameters = currentParameters;
34 const ref = this; 35 this.lastPoint = [0, 0];
36 this.showQueue = new SimpleQueue(
37 function() {
Unexpected aliasing of 'this' to local variable
18 this.startPoint = null;
19 this.lastPoint = null;
20 this.startCenter = null;
21 const ref = this;22 this.updateQueue = new SimpleQueue(function () {
23 ref.pan();
24 }, 10);
Unexpected aliasing of 'this' to local variable
29 // this.lastPoint = null;
30 // this.currentSelectBox = null;
31 // this.currentSelection = [];
32 const ref = this; 33 // this.updateQueue = new SimpleQueue(function () {
34 // ref.dragHandler();
35 // }, 20);
Unexpected aliasing of 'this' to local variable
30 this.lastPoint = null;
31 this.currentSelectBox = null;
32 this.currentSelection = [];
33 const ref = this; 34 this.updateQueue = new SimpleQueue(function () {
35 ref.dragHandler();
36 }, 20);
Unexpected aliasing of 'this' to local variable
26 this.typeString = "TEXT";
27 this.setString = "Standard";
28 this.currentFeatureID = null;
29 const ref = this;30 this.lastPoint = null;
31 this._text = "TESTING-TEXT";
32 this.fontSize = 12;
Unexpected aliasing of 'this' to local variable
21 // this.lastPoint = null;
22 // this.currentSelectBox = null;
23 // this.currentSelection = [];
24 const ref = this; 25 // this.updateQueue = new SimpleQueue(function () {
26 // ref.dragHandler();
27 // }, 20);
Unexpected aliasing of 'this' to local variable
65 2. WAYPOINT
66 3. TARGET
67 */
68 const ref = this; 69
70 this.showQueue = new SimpleQueue(
71 function () {
Unexpected aliasing of 'this' to local variable
28 this.currentChannelID = null;
29 this.currentTarget = null;
30 this.dragging = false;
31 const ref = this; 32
33 this.showQueue = new SimpleQueue(
34 function() {
Unexpected aliasing of 'this' to local variable
38 }
39
40 startTimer(): void {
41 const ref = this;42 this.waiting = true;
43 window.setTimeout(function() {
44 ref.endTimer();
Unexpected aliasing of 'this' to local variable
254
255 console.log("Inverse Control Manufacturing Layers:", mfglayers);
256
257 const ref = this;258 mfglayers.forEach(function(mfglayer: ManufacturingLayer, index: number) {
259 ref.__svgData.set(mfglayer.name, mfglayer.exportToSVG());
260 mfglayer.flushData();
Unexpected aliasing of 'this' to local variable
141 const edge = new paper.Path.Rectangle(topleft, bottomright);
142 const mfglayer = new ManufacturingLayer("UniversalEdge");
143 mfglayer.addFeature(edge);
144 const ref = this;145 ref.__svgData.set(mfglayer.name, mfglayer.exportToSVG());
146 mfglayer.flushData();
147 }
Unexpected aliasing of 'this' to local variable
120 });
121
122 console.log("XY Manufacturing Layers:", mfglayers);
123 const ref = this;124 mfglayers.forEach(function(mfglayer: ManufacturingLayer, index: number) {
125 ref.__svgData.set(mfglayer.name, mfglayer.exportToSVG());
126 mfglayer.flushData();
Unexpected aliasing of 'this' to local variable
141 const edge = new paper.Path.Rectangle(topleft, bottomright);
142 const mfglayer = new ManufacturingLayer("UniversalEdge");
143 mfglayer.addFeature(edge);
144 const ref = this;145 ref.__svgData.set(mfglayer.name, mfglayer.exportToSVG());
146 mfglayer.flushData();
147 }
Unexpected aliasing of 'this' to local variable
120 });
121
122 console.log("XY Manufacturing Layers:", mfglayers);
123 const ref = this;124 mfglayers.forEach(function(mfglayer: ManufacturingLayer, index: number) {
125 ref.__svgData.set(mfglayer.name, mfglayer.exportToSVG());
126 mfglayer.flushData();
Description
This rule prohibits assigning variables to this
.
Bad Practice
//Assigning a variable to this instead of properly using arrow lambdas may be a symptom of pre-ES6 practices or not managing scope well.
//Instead of storing a reference to this and using it inside a function () {:
const self = this;
setTimeout(function () {
self.doWork();
});
Recommended
// Use () => arrow lambdas, as they preserve this scope for you:
setTimeout(() => {
this.doWork();
});