mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(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:
@@ -315,7 +315,7 @@ function readAclRules(docData: DocData, {log, compile}: ReadAclOptions): ReadAcl
|
||||
}
|
||||
|
||||
for (const [resourceId, rules] of rulesByResource.entries()) {
|
||||
const resourceRec = resourcesTable.getRecord(resourceId as number);
|
||||
const resourceRec = resourcesTable.getRecord(resourceId);
|
||||
if (!resourceRec) {
|
||||
throw new Error(`ACLRule ${rules[0].id} refers to an invalid ACLResource ${resourceId}`);
|
||||
continue;
|
||||
|
||||
@@ -82,7 +82,8 @@ const SCHEMA_ACTIONS = new Set(['AddTable', 'RemoveTable', 'RenameTable', 'AddCo
|
||||
/**
|
||||
* Determines whether a given action is a schema action or not.
|
||||
*/
|
||||
export function isSchemaAction(action: DocAction): action is AddTable | RemoveTable | RenameTable | AddColumn | RemoveColumn | RenameColumn | ModifyColumn {
|
||||
export function isSchemaAction(action: DocAction):
|
||||
action is AddTable | RemoveTable | RenameTable | AddColumn | RemoveColumn | RenameColumn | ModifyColumn {
|
||||
return SCHEMA_ACTIONS.has(action[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ export interface OpenLocalDocResult {
|
||||
userOverride?: UserOverride;
|
||||
}
|
||||
|
||||
export class UserOverride {
|
||||
export interface UserOverride {
|
||||
user: FullUser|null;
|
||||
access: Role|null;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ export abstract class BaseComponent implements IForwarderDest {
|
||||
public async forwardMessage(msg: IMsgCustom): Promise<any> {
|
||||
if (!this._activated) { await this.activate(); }
|
||||
this.inactivityTimer.ping();
|
||||
this.doForwardMessage(msg); // tslint:disable-line:no-floating-promises TODO
|
||||
this.doForwardMessage(msg); // eslint-disable-line @typescript-eslint/no-floating-promises
|
||||
}
|
||||
|
||||
protected abstract doForwardCall(c: IMsgRpcCall): Promise<any>;
|
||||
|
||||
@@ -629,7 +629,7 @@ export class UserAPIImpl extends BaseAPI implements UserAPI {
|
||||
}
|
||||
|
||||
export class DocWorkerAPIImpl extends BaseAPI implements DocWorkerAPI {
|
||||
constructor(readonly url: string, _options: IOptions = {}) {
|
||||
constructor(public readonly url: string, _options: IOptions = {}) {
|
||||
super(_options);
|
||||
}
|
||||
|
||||
@@ -682,7 +682,7 @@ export class DocWorkerAPIImpl extends BaseAPI implements DocWorkerAPI {
|
||||
export class DocAPIImpl extends BaseAPI implements DocAPI {
|
||||
private _url: string;
|
||||
|
||||
constructor(url: string, readonly docId: string, options: IOptions = {}) {
|
||||
constructor(url: string, public readonly docId: string, options: IOptions = {}) {
|
||||
super(options);
|
||||
this._url = `${url}/api/docs/${docId}`;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
export function tbind<T, R, Args extends any[]>(func: (this: T, ...a: Args) => R, context: T): (...a: Args) => R;
|
||||
|
||||
// Bind context and first arg for a function of up to 5 args.
|
||||
export function tbind<T, R, X, Args extends any[]>(func: (this: T, x: X, ...a: Args) => R, context: T, x: X): (...a: Args) => R;
|
||||
export function tbind<T, R, X, Args extends any[]>(
|
||||
func: (this: T, x: X, ...a: Args) => R, context: T, x: X
|
||||
): (...a: Args) => R;
|
||||
|
||||
export function tbind(func: any, context: any, ...boundArgs: any[]): any {
|
||||
return func.bind(context, ...boundArgs);
|
||||
|
||||
@@ -12,7 +12,8 @@ type PromisifiedFunction<T extends AnyFunction> =
|
||||
T extends (a1: infer A1) => infer U ? (a1: A1) => Promise<Unpacked<U>> :
|
||||
T extends (a1: infer A1, a2: infer A2) => infer U ? (a1: A1, a2: A2) => Promise<Unpacked<U>> :
|
||||
T extends (a1: infer A1, a2: infer A2, a3: infer A3) => infer U ? (a1: A1, a2: A2, a3: A3) => Promise<Unpacked<U>> :
|
||||
T extends (a1: infer A1, a2: infer A2, a3: infer A3, a4: infer A4) => infer U ? (a1: A1, a2: A2, a3: A3, a4: A4) => Promise<Unpacked<U>> :
|
||||
T extends (a1: infer A1, a2: infer A2, a3: infer A3, a4: infer A4) =>
|
||||
infer U ? (a1: A1, a2: A2, a3: A3, a4: A4) => Promise<Unpacked<U>> :
|
||||
// ...
|
||||
T extends (...args: any[]) => infer U ? (...args: any[]) => Promise<Unpacked<U>> : T;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user