mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Fix 'no-dynamic-delete' lint failures (#22822)
This commit is contained in:
parent
219dd6df82
commit
01d4dcdcd2
@ -614,7 +614,7 @@ function updateSproc(id: string, update: Object) {
|
||||
} else if (document[existingFieldName]) {
|
||||
// If the field exists, set/overwrite the new field name and unset the existing field name.
|
||||
document[newFieldName] = document[existingFieldName];
|
||||
delete document[existingFieldName];
|
||||
delete document[existingFieldName]; // tslint:disable-line no-dynamic-delete
|
||||
} else {
|
||||
// Otherwise this is a noop.
|
||||
}
|
||||
@ -641,7 +641,7 @@ function updateSproc(id: string, update: Object) {
|
||||
if (update.$unset) {
|
||||
fields = Object.keys(update.$unset);
|
||||
for (i = 0; i < fields.length; i++) {
|
||||
delete document[fields[i]];
|
||||
delete document[fields[i]]; // tslint:disable-line no-dynamic-delete
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,8 +38,6 @@ else { // if not an array but scalar value here is a way how to convert to array
|
||||
|
||||
// The way to remove the parameter:
|
||||
delete u.query.a;
|
||||
// or:
|
||||
delete u.query["a"];
|
||||
|
||||
// If you need to remove all query string params:
|
||||
console.log(u.clearQuery());
|
||||
|
||||
@ -40,8 +40,6 @@ else { // if not an array but scalar value here is a way how to convert to array
|
||||
|
||||
// The way to remove the parameter:
|
||||
delete u.query.a
|
||||
// or:
|
||||
delete u.query["a"]
|
||||
|
||||
// If you need to remove all query string params:
|
||||
u.query.clear();
|
||||
|
||||
@ -143,8 +143,8 @@ Model.findOne({ name: 'john' }, (err: any, doc: mongoose.Document) => {
|
||||
|
||||
doc.toJSON({ getters: true, virtuals: false });
|
||||
var data: any = doc.toObject();
|
||||
delete data['age'];
|
||||
delete data['weight'];
|
||||
delete data['age']; // tslint:disable-line no-dynamic-delete
|
||||
delete data['weight']; // tslint:disable-line no-dynamic-delete
|
||||
data['isAwesome'] = true;
|
||||
});
|
||||
|
||||
|
||||
@ -654,13 +654,11 @@ const STATUS_LOADING = 1
|
||||
const STATUS_LOADED = 2
|
||||
|
||||
export class InfiniteLoaderExample extends PureComponent<any, any> {
|
||||
_timeoutIdMap: any;
|
||||
_timeoutIds = new Set<number>();
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
this._timeoutIdMap = {}
|
||||
|
||||
this._clearData = this._clearData.bind(this)
|
||||
this._isRowLoaded = this._isRowLoaded.bind(this)
|
||||
this._loadMoreRows = this._loadMoreRows.bind(this)
|
||||
@ -668,9 +666,7 @@ export class InfiniteLoaderExample extends PureComponent<any, any> {
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Object.keys(this._timeoutIdMap).forEach(timeoutId => {
|
||||
clearTimeout(timeoutId as any)
|
||||
})
|
||||
this._timeoutIds.forEach(clearTimeout);
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -731,7 +727,7 @@ export class InfiniteLoaderExample extends PureComponent<any, any> {
|
||||
const timeoutId = setTimeout(() => {
|
||||
const { loadedRowCount, loadingRowCount } = this.state
|
||||
|
||||
delete this._timeoutIdMap[timeoutId]
|
||||
this._timeoutIds.delete(timeoutId);
|
||||
|
||||
for (let i = startIndex; i <= stopIndex; i++) {
|
||||
loadedRowsMap[i] = STATUS_LOADED
|
||||
@ -745,7 +741,7 @@ export class InfiniteLoaderExample extends PureComponent<any, any> {
|
||||
promiseResolver()
|
||||
}, 1000 + Math.round(Math.random() * 2000))
|
||||
|
||||
this._timeoutIdMap[timeoutId] = true
|
||||
this._timeoutIds.add(timeoutId);
|
||||
|
||||
let promiseResolver
|
||||
|
||||
|
||||
@ -354,7 +354,7 @@ interface CreepMemory {
|
||||
const interShardData = JSON.parse(RawMemory.interShardSegment);
|
||||
if (interShardData.creeps[creep.name]) {
|
||||
creep.memory = interShardData[creep.name];
|
||||
delete interShardData.creeps[creep.name];
|
||||
delete interShardData.creeps[creep.name]; // tslint:disable-line no-dynamic-delete
|
||||
}
|
||||
RawMemory.interShardSegment = JSON.stringify(interShardData);
|
||||
|
||||
|
||||
@ -47,8 +47,8 @@ function setFilters_0() {
|
||||
}
|
||||
|
||||
function setFilters_1(oldPOS: RegExp) {
|
||||
Sizzle.selectors.match['POS'] = new RegExp(oldPOS.source.replace('first', 'uno'), 'gi');
|
||||
Sizzle.selectors.setFilters['uno'] = Sizzle.selectors.setFilters['first'];
|
||||
delete Sizzle.selectors.setFilters['first'];
|
||||
Sizzle.selectors.match.POS = new RegExp(oldPOS.source.replace('first', 'uno'), 'gi');
|
||||
Sizzle.selectors.setFilters.uno = Sizzle.selectors.setFilters.first;
|
||||
delete Sizzle.selectors.setFilters.first;
|
||||
Sizzle('div:uno'); // ==> [ <div> ]
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ new ssh2.Server({
|
||||
var session = accept();
|
||||
session.on('sftp', (accept: any, reject: any) => {
|
||||
console.log('Client SFTP session');
|
||||
var openFiles: any = {};
|
||||
var openFiles = new Set<number>();
|
||||
var handleCount = 0;
|
||||
// `sftpStream` is an `SFTPStream` instance in server mode
|
||||
// see: https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md
|
||||
@ -401,12 +401,12 @@ new ssh2.Server({
|
||||
// be a real file descriptor number for example if actually opening
|
||||
// the file on the disk
|
||||
var handle = new Buffer(4);
|
||||
openFiles[handleCount] = true;
|
||||
openFiles.add(handleCount);
|
||||
handle.writeUInt32BE(handleCount++, 0, true);
|
||||
sftpStream.handle(reqid, handle);
|
||||
console.log('Opening file for write')
|
||||
}).on('WRITE', (reqid: any, handle: any, offset: any, data: any) => {
|
||||
if (handle.length !== 4 || !openFiles[handle.readUInt32BE(0, true)])
|
||||
if (handle.length !== 4 || !openFiles.has(handle.readUInt32BE(0, true)))
|
||||
return sftpStream.status(reqid, STATUS_CODE.FAILURE);
|
||||
// fake the write
|
||||
sftpStream.status(reqid, STATUS_CODE.OK);
|
||||
@ -414,9 +414,9 @@ new ssh2.Server({
|
||||
console.log('Write to file at offset %d: %s', offset, inspected);
|
||||
}).on('CLOSE', (reqid: any, handle: any) => {
|
||||
var fnum: any;
|
||||
if (handle.length !== 4 || !openFiles[(fnum = handle.readUInt32BE(0, true))])
|
||||
if (handle.length !== 4 || !openFiles.has((fnum = handle.readUInt32BE(0, true))))
|
||||
return sftpStream.status(reqid, STATUS_CODE.FAILURE);
|
||||
delete openFiles[fnum];
|
||||
openFiles.delete(fnum);
|
||||
sftpStream.status(reqid, STATUS_CODE.OK);
|
||||
console.log('Closing file');
|
||||
});
|
||||
|
||||
@ -109,7 +109,7 @@ function test_swipey() {
|
||||
var canvas = <HTMLCanvasElement>$('canvas')[0];
|
||||
var context = canvas.getContext('2d');
|
||||
var iOS = (/iphone|ipad/i).test(navigator.userAgent);
|
||||
var pointers = {};
|
||||
var pointers = new Map<string, any>();
|
||||
// handle resizing / rotating of the viewport
|
||||
var width, height;
|
||||
$(window).bind(viewporter.ACTIVE ? 'viewportchange' : 'resize', function () {
|
||||
@ -123,11 +123,12 @@ function test_swipey() {
|
||||
for (var i = 0; i < touches.length; i++) {
|
||||
identifier = touches[i].identifier || 'mouse';
|
||||
// if no pointer has been created for this finger yet, do it
|
||||
if (!pointers[identifier]) {
|
||||
pointers[identifier] = new drawingPointer(context, rainbow(8, Object.keys(pointers).length));
|
||||
let pointer = pointers.get(identifier);
|
||||
if (!pointer) {
|
||||
pointers.set(identifier, pointer = new drawingPointer(context, rainbow(8, Object.keys(pointers).length)));
|
||||
}
|
||||
pointers[identifier].start();
|
||||
pointers[identifier].addPoint(touches[i].pageX, touches[i].pageY);
|
||||
pointer.start();
|
||||
pointer.addPoint(touches[i].pageX, touches[i].pageY);
|
||||
}
|
||||
});
|
||||
|
||||
@ -136,8 +137,9 @@ function test_swipey() {
|
||||
var identifier;
|
||||
for (var i = 0; i < touches.length; i++) {
|
||||
identifier = touches[i].identifier || 'mouse';
|
||||
if (pointers[identifier] && pointers[identifier].painting) {
|
||||
pointers[identifier].addPoint(touches[i].pageX, touches[i].pageY, true);
|
||||
const pointer = pointers.get(identifier);
|
||||
if (pointer && pointer.painting) {
|
||||
pointer.addPoint(touches[i].pageX, touches[i].pageY, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -147,11 +149,12 @@ function test_swipey() {
|
||||
var identifier;
|
||||
for (var i = 0; i < touches.length; i++) {
|
||||
identifier = touches[i].identifier || 'mouse';
|
||||
if (pointers[identifier]) {
|
||||
pointers[identifier].stop();
|
||||
const pointer = pointers.get(identifier);
|
||||
if (pointer) {
|
||||
pointer.stop();
|
||||
(function (identifier) {
|
||||
setTimeout(function () {
|
||||
delete pointers[identifier];
|
||||
pointers.delete(identifier);
|
||||
}, 300);
|
||||
})(identifier);
|
||||
}
|
||||
@ -161,10 +164,10 @@ function test_swipey() {
|
||||
window.setInterval(function () {
|
||||
context.clearRect(0, 0, width, height);
|
||||
var counter = 0, ratio = (<any>window).devicePixelRatio || 1;
|
||||
for (var identifier in pointers) {
|
||||
pointers[identifier].redraw();
|
||||
pointers.forEach(pointer => {
|
||||
pointer.redraw();
|
||||
counter++;
|
||||
}
|
||||
});
|
||||
context.font = (10 * ratio) + 'pt Arial';
|
||||
context.fillText(counter + ' active pointers', 15 * ratio, 25 * ratio);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user