(core) Configure more comprehensive eslint rules for Typescript

Summary:
- Update rules to be more like we've had with tslint
- Switch tsserver plugin to eslint (tsserver makes for a much faster way to lint in editors)
- Apply suggested auto-fixes
- Fix all lint errors and warnings in core/, app/, test/

Test Plan: Some behavior may change subtly (e.g. added missing awaits), relying on existing tests to catch problems.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2785
This commit is contained in:
Dmitry S
2021-04-26 17:54:09 -04:00
parent 91fdef58ac
commit 526b0ad33e
56 changed files with 147 additions and 125 deletions

View File

@@ -241,9 +241,9 @@ AceEditor.prototype._getContentHeight = function() {
let _RangeConstructor = null; //singleton, load it lazily
AceEditor.makeRange = function(a,b,c,d) {
AceEditor.makeRange = function(a, b, c, d) {
_RangeConstructor = _RangeConstructor || ace.acequire('ace/range').Range;
return new _RangeConstructor(a,b,c,d);
return new _RangeConstructor(a, b, c, d);
};
module.exports = AceEditor;

View File

@@ -262,7 +262,7 @@ export class ActionLog extends dispose.Disposable implements IDomComponent {
if (this._loaded || !this._gristDoc) { return; }
this._loading(true);
// Returned actions are ordered with earliest actions first.
const result = await this._gristDoc!.docComm.getActionSummaries();
const result = await this._gristDoc.docComm.getActionSummaries();
this._loading(false);
this._loaded = true;
// Add the actions to our action log.

View File

@@ -15,7 +15,7 @@ import * as ko from 'knockout';
import noop = require('lodash/noop');
// To simplify diff (avoid rearranging methods to satisfy private/public order).
// tslint:disable:member-ordering
/* eslint-disable @typescript-eslint/member-ordering */
type AceEditor = any;
@@ -130,7 +130,7 @@ export class ColumnTransform extends Disposable {
this.transformColumn = this.field.column();
this.transformColumn.origColRef(this.origColumn.getRowId());
this._setTransforming(true);
return await this.postAddTransformColumn();
return this.postAddTransformColumn();
} finally {
this.isCallPending(false);
}
@@ -167,7 +167,7 @@ export class ColumnTransform extends Disposable {
/**
* A derived class can override to do some processing after this.transformColumn has been set.
*/
protected postAddTransformColumn() {
protected postAddTransformColumn(): void {
// Nothing in base class.
}
@@ -207,7 +207,7 @@ export class ColumnTransform extends Disposable {
} finally {
// Wait until the change completed to set column back, to avoid value flickering.
field.colRef(origRef);
tableData.sendTableAction(['RemoveColumn', transformColId]);
void tableData.sendTableAction(['RemoveColumn', transformColId]);
this.dispose();
}
}

View File

@@ -350,11 +350,11 @@ GridView.prototype.fillSelectionDown = function() {
}).filter(colId => colId);
var colInfo = _.object(colIds, colIds.map(colId => {
var val = this.tableModel.tableData.getValue(rowIds[0],colId);
var val = this.tableModel.tableData.getValue(rowIds[0], colId);
return rowIds.map(() => val);
}));
this.tableModel.sendTableAction(["BulkUpdateRecord",rowIds,colInfo]);
this.tableModel.sendTableAction(["BulkUpdateRecord", rowIds, colInfo]);
};

View File

@@ -153,7 +153,7 @@ export class Importer extends Disposable {
} else if (item.kind === "url") {
uploadResult = await fetchURL(this._docComm, item.url);
} else {
throw new Error(`Import source of kind ${item!.kind} are not yet supported!`);
throw new Error(`Import source of kind ${(item as any).kind} are not yet supported!`);
}
}
}
@@ -391,7 +391,7 @@ export class Importer extends Disposable {
}
function getSourceDescription(sourceInfo: SourceInfo, upload: UploadResult) {
const origName = upload!.files[sourceInfo.uploadFileIndex].origName;
const origName = upload.files[sourceInfo.uploadFileIndex].origName;
return sourceInfo.origTableName ? origName + ' - ' + sourceInfo.origTableName : origName;
}

View File

@@ -25,8 +25,8 @@ export function makeSearchToolbarGroup(gristDoc: GristDoc) {
// Active normally.
const commandGroup = createGroup({
find: () => { input.focus(); },
findNext: () => { searcher.findNext(); }, // tslint:disable-line:no-floating-promises TODO
findPrev: () => { searcher.findPrev(); }, // tslint:disable-line:no-floating-promises TODO
findNext: () => { searcher.findNext(); }, // eslint-disable-line @typescript-eslint/no-floating-promises
findPrev: () => { searcher.findPrev(); }, // eslint-disable-line @typescript-eslint/no-floating-promises
}, null, true);
// Return an array of one item (for a toolbar group of a single item). The item is an array of
@@ -49,7 +49,7 @@ export function makeSearchToolbarGroup(gristDoc: GristDoc) {
// the searchbox is created so early that the actions like accept/cancel get overridden).
dom.on('keydown', (e: KeyboardEvent) => {
switch (e.keyCode) {
case 13: searcher.findNext(); break; // tslint:disable-line:no-floating-promises TODO
case 13: searcher.findNext(); break; // eslint-disable-line @typescript-eslint/no-floating-promises
case 27: input.blur(); break;
}
})

View File

@@ -264,7 +264,7 @@ CellSelector.prototype.rowCount = function() {
return this.rowUpper() - this.rowLower() + 1;
};
CellSelector.prototype.selectArea = function(rowStartIdx,colStartIdx,rowEndIdx,colEndIdx) {
CellSelector.prototype.selectArea = function(rowStartIdx, colStartIdx, rowEndIdx, colEndIdx) {
this.row.start(rowStartIdx);
this.col.start(colStartIdx);
this.row.end(rowEndIdx);

View File

@@ -22,7 +22,7 @@ import isEmpty = require('lodash/isEmpty');
import pickBy = require('lodash/pickBy');
// To simplify diff (avoid rearranging methods to satisfy private/public order).
// tslint:disable:member-ordering
/* eslint-disable @typescript-eslint/member-ordering */
/**
* Creates an instance of TypeTransform for a single field. Extends ColumnTransform.

View File

@@ -58,7 +58,7 @@ function ViewConfigTab(options) {
}) || self.viewSectionData.at(0);
}));
this.isDetail = this.autoDispose(ko.computed(function() {
return ['detail','single'].includes(this.viewModel.activeSection().parentKey());
return ['detail', 'single'].includes(this.viewModel.activeSection().parentKey());
}, this));
this.isChart = this.autoDispose(ko.computed(function() {
return this.viewModel.activeSection().parentKey() === 'chart';}, this));