comply with @typescript-eslint/no-inferrable-types

pull/8592/head
Niklas Fiekas 2021-04-07 18:47:59 +02:00
parent 95ead27316
commit c55086b6e6
34 changed files with 64 additions and 69 deletions

View File

@ -9,26 +9,21 @@
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended"
],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"linebreak-style": ["error", "unix"],
"no-duplicate-imports": "error",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"eqeqeq": "off",
"prefer-const": "off",
"no-var": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"prefer-spread": "off",
"prefer-rest-params": "off",
"no-useless-escape": "off",

View File

@ -153,7 +153,7 @@ function studyButton(ctrl: AnalyseCtrl) {
}
export class ActionMenuCtrl {
open: boolean = false;
open = false;
toggle = (): void => {
this.open = !this.open;
};

View File

@ -76,16 +76,16 @@ export default class AnalyseCtrl {
justPlayed?: string; // pos
justDropped?: string; // role
justCaptured?: JustCaptured;
autoScrollRequested: boolean = false;
redirecting: boolean = false;
onMainline: boolean = true;
autoScrollRequested = false;
redirecting = false;
onMainline = true;
synthetic: boolean; // false if coming from a real game
ongoing: boolean; // true if real game is ongoing
// display flags
flipped: boolean = false;
flipped = false;
embed: boolean;
showComments: boolean = true; // whether to display comments in the move tree
showComments = true; // whether to display comments in the move tree
showAutoShapes: StoredBooleanProp = storedProp('show-auto-shapes', true);
showGauge: StoredBooleanProp = storedProp('show-gauge', true);
showComputer: StoredBooleanProp = storedProp('show-computer', true);

View File

@ -18,7 +18,7 @@ export interface ForkCtrl {
export function make(root: AnalyseCtrl): ForkCtrl {
let prev: Tree.Node | undefined;
let selected: number = 0;
let selected = 0;
function displayed() {
return root.node.children.length > 1;
}

View File

@ -63,7 +63,7 @@ export function make(root: AnalyseCtrl, playableDepth: () => number): PracticeCt
if (root.threatMode()) root.toggleThreatMode();
}
function commentable(node: Tree.Node, bonus: number = 0): boolean {
function commentable(node: Tree.Node, bonus = 0): boolean {
if (node.tbhit || root.outcome(node)) return true;
const ceval = node.ceval;
return ceval ? ceval.depth + bonus >= 15 || (ceval.depth >= 13 && ceval.millis > 3000) : false;

View File

@ -5,7 +5,7 @@ import { bind, richHTML, onInsert } from '../util';
export type Save = (string) => void;
export class DescriptionCtrl {
edit: boolean = false;
edit = false;
constructor(public text: string | undefined, readonly doSave: Save, readonly redraw: () => void) {}

View File

@ -7,10 +7,10 @@ import { bind, spinner } from '../util';
import * as domData from 'common/data';
export class MultiBoardCtrl {
loading: boolean = false;
page: number = 1;
loading = false;
page = 1;
pager?: Paginator<ChapterPreview>;
playing: boolean = false;
playing = false;
constructor(readonly studyId: string, readonly redraw: () => void, readonly trans: Trans) {}

View File

@ -4,7 +4,7 @@ import { isFinished } from '../studyChapters';
export default class RelayCtrl {
log: LogEvent[] = [];
cooldown: boolean = false;
cooldown = false;
clockInterval?: number;
intro: RelayIntro;

View File

@ -135,7 +135,7 @@ export function innerHTML<A>(a: A, toHtml: (a: A) => string): Hooks {
};
}
export function richHTML(text: string, newLines: boolean = true): Hooks {
export function richHTML(text: string, newLines = true): Hooks {
return innerHTML(text, t => enrichText(t, newLines));
}
@ -192,7 +192,7 @@ function toLink(url: string) {
return `<a target="_blank" rel="nofollow noopener noreferrer" href="${url}">${show}</a>`;
}
export function enrichText(text: string, allowNewlines: boolean = true): string {
export function enrichText(text: string, allowNewlines = true): string {
let html = autolink(lichess.escapeHtml(text), toLink);
if (allowNewlines) html = html.replace(newLineRegex, '<br>');
return html;

View File

@ -1,6 +1,6 @@
import throttle from './throttle';
export const runner = (hacks: () => void, throttleMs: number = 100): void => {
export const runner = (hacks: () => void, throttleMs = 100): void => {
let timeout: number | undefined;
const runHacks = throttle(throttleMs, () =>

View File

@ -164,7 +164,7 @@ export default function (token: string) {
*
* @param {number} ms - The number of milliseconds to sleep
*/
function sleep(ms: number = 0) {
function sleep(ms = 0) {
return new Promise(r => setTimeout(r, ms));
}

View File

@ -19,8 +19,8 @@ export default class LobbyController {
mode: Mode;
sort: Sort;
stepHooks: Hook[] = [];
stepping: boolean = false;
redirecting: boolean = false;
stepping = false;
redirecting = false;
poolMember?: PoolMember;
trans: Trans;
pools: Pool[];

View File

@ -15,7 +15,7 @@ interface Filtered {
export default class Filter {
store: FormStore;
data: FilterData | null;
open: boolean = false;
open = false;
constructor(storage: LichessStorage, readonly root: LobbyController) {
this.store = makeStore(storage);

View File

@ -183,7 +183,7 @@ export default class Setup {
const showRating = () => {
const timeMode = $timeModeSelect.val();
let key: string = 'correspondence';
let key = 'correspondence';
switch ($variantSelect.val()) {
case '1':
case '3':

View File

@ -1,7 +1,7 @@
import throttle from 'common/throttle';
class Scroller {
enabled: boolean = false;
enabled = false;
element?: HTMLElement;
marker?: HTMLElement;

View File

@ -107,7 +107,7 @@ export function palantir(opts: PalantirOpts) {
console.log('[palantir]', msg);
}
function setState(s: State, msg: string = '') {
function setState(s: State, msg = '') {
log(`state: ${state} -> ${s} ${msg}`);
state = s;
opts.redraw();

View File

@ -5,7 +5,7 @@ export class Clock {
startAt: number | undefined;
initialMillis: number;
public constructor(readonly config: Config, startedMillisAgo: number = 0) {
public constructor(readonly config: Config, startedMillisAgo = 0) {
this.initialMillis = config.clock.initial * 1000 - (startedMillisAgo || 0);
}

View File

@ -6,7 +6,7 @@ import { getNow } from './util';
export default class CurrentPuzzle {
line: Uci[];
startAt: number;
moveIndex: number = 0;
moveIndex = 0;
pov: Color;
constructor(readonly index: number, readonly puzzle: Puzzle) {

View File

@ -15,7 +15,7 @@ interface StreakData {
export default class PuzzleStreak {
data: StreakData;
fail: boolean = false;
fail = false;
store: StoredJsonProp<StreakData | null>;
constructor(data: PuzzleData) {

View File

@ -29,7 +29,7 @@ function dataAct(e: Event): string | null {
return target.getAttribute('data-act') || (target.parentNode as HTMLElement).getAttribute('data-act');
}
function jumpButton(icon: string, effect: string, disabled: boolean, glowing: boolean = false): VNode {
function jumpButton(icon: string, effect: string, disabled: boolean, glowing = false): VNode {
return h('button.fbt', {
class: { disabled, glowing },
attrs: {

View File

@ -61,11 +61,11 @@ export default class RoundController {
moveOn: MoveOn;
ply: number;
firstSeconds: boolean = true;
flip: boolean = false;
loading: boolean = false;
firstSeconds = true;
flip = false;
loading = false;
loadingTimeout: number;
redirecting: boolean = false;
redirecting = false;
transientMove: TransientMove;
moveToSubmit?: SocketMove;
dropToSubmit?: SocketDrop;
@ -74,10 +74,10 @@ export default class RoundController {
drawConfirm?: Timeout = undefined;
// will be replaced by view layer
autoScroll: () => void = () => {};
challengeRematched: boolean = false;
challengeRematched = false;
justDropped?: cg.Role;
justCaptured?: cg.Piece;
shouldSendMoveTime: boolean = false;
shouldSendMoveTime = false;
preDrop?: cg.Role;
lastDrawOfferAtPly?: Ply;
nvui?: NvuiPlugin;
@ -615,7 +615,7 @@ export default class RoundController {
this.redraw();
};
setLoading = (v: boolean, duration: number = 1500) => {
setLoading = (v: boolean, duration = 1500) => {
clearTimeout(this.loadingTimeout);
if (v) {
this.loading = true;

View File

@ -70,7 +70,7 @@ export function ctrl(root: RoundController, step: Step, redraw: Redraw): Keyboar
root.chessground.cancelMove();
sendPromotion(root, orig, dest, role, { premove: false });
},
update(step, yourMove: boolean = false) {
update(step, yourMove = false) {
if (handler) handler(step.fen, cgState.movable.dests, yourMove);
else preHandlerBuffer = step.fen;
},

View File

@ -28,7 +28,7 @@ export const onInsert = (f: (el: HTMLElement) => void): Hooks => ({
},
});
export const bind = (eventName: string, f: (e: Event) => void, redraw?: Redraw, passive: boolean = true): Hooks =>
export const bind = (eventName: string, f: (e: Event) => void, redraw?: Redraw, passive = true): Hooks =>
onInsert(el => {
el.addEventListener(
eventName,

View File

@ -212,7 +212,7 @@ export function cancelTakebackProposition(ctrl: RoundController) {
: null;
}
function acceptButton(ctrl: RoundController, klass: string, action: () => void, i18nKey: string = 'accept') {
function acceptButton(ctrl: RoundController, klass: string, action: () => void, i18nKey: I18nKey = 'accept') {
const text = ctrl.noarg(i18nKey);
return ctrl.nvui
? h(
@ -230,7 +230,7 @@ function acceptButton(ctrl: RoundController, klass: string, action: () => void,
hook: util.bind('click', action),
});
}
function declineButton(ctrl: RoundController, action: () => void, i18nKey: string = 'decline') {
function declineButton(ctrl: RoundController, action: () => void, i18nKey: I18nKey = 'decline') {
const text = ctrl.noarg(i18nKey);
return ctrl.nvui
? h(

View File

@ -46,7 +46,7 @@ export function main(ctrl: RoundController): VNode {
topColor = d[ctrl.flip ? 'player' : 'opponent'].color,
bottomColor = d[ctrl.flip ? 'opponent' : 'player'].color;
let material: MaterialDiff,
score: number = 0;
score = 0;
if (d.pref.showCaptured) {
const pieces = cgState ? cgState.pieces : fenRead(plyStep(ctrl.data, ctrl.ply).fen);
material = util.getMaterialDiff(pieces);

View File

@ -14,7 +14,7 @@ interface Friend {
export default class OnlineFriends {
titleEl: HTMLElement;
loaded: boolean = false;
loaded = false;
trans: Trans;
users: Map<string, Friend>;

View File

@ -54,11 +54,11 @@ export default class StrongSocket {
connectSchedule: Timeout;
ackable: Ackable = new Ackable((t, d, o) => this.send(t, d, o));
lastPingTime: number = performance.now();
pongCount: number = 0;
averageLag: number = 0;
tryOtherUrl: boolean = false;
autoReconnect: boolean = true;
nbConnects: number = 0;
pongCount = 0;
averageLag = 0;
tryOtherUrl = false;
autoReconnect = true;
nbConnects = 0;
storage: LichessStorage = makeStorage.make('surl15');
private _sign?: string;

View File

@ -63,7 +63,7 @@ const sound = new (class {
return this.speechStorage.get();
};
say = (text: any, cut: boolean = false, force: boolean = false) => {
say = (text: any, cut = false, force = false) => {
if (!this.speechStorage.get() && !force) return false;
const msg = text.text ? (text as SpeechSynthesisUtterance) : new SpeechSynthesisUtterance(text);
msg.volume = this.getVolume();

View File

@ -76,7 +76,7 @@ lichess.load.then(() => {
return $iframe;
}
function expandYoutubes(as: Candidate[], wait: number = 100) {
function expandYoutubes(as: Candidate[], wait = 100) {
var a = as.shift(),
wait = Math.min(1500, wait);
if (a)
@ -103,7 +103,7 @@ lichess.load.then(() => {
});
}
function expandStudies(as: Candidate[], wait: number = 100) {
function expandStudies(as: Candidate[], wait = 100) {
const a = as.shift();
wait = Math.min(1500, wait);
if (a)

View File

@ -7,7 +7,7 @@ export default function InfiniteScroll(selector: string) {
});
}
function register(el: HTMLElement, selector: string, backoff: number = 500) {
function register(el: HTMLElement, selector: string, backoff = 500) {
const nav = el.querySelector('.pager') as HTMLAnchorElement | null,
next = nav?.querySelector('.pager a') as HTMLAnchorElement | null,
nextUrl = next?.href;

View File

@ -62,7 +62,7 @@ lichess.load.then(() => {
function userMod($inZone: Cash) {
lichess.contentLoaded($inZone[0]);
const makeReady = (selector: string, f: (el: HTMLElement, i: number) => void, cls: string = 'ready') => {
const makeReady = (selector: string, f: (el: HTMLElement, i: number) => void, cls = 'ready') => {
$inZone.find(selector + `:not(.${cls})`).each(function (this: HTMLElement, i: number) {
f($(this).addClass(cls)[0] as HTMLElement, i);
});

View File

@ -12,10 +12,10 @@ export default class SwissCtrl {
pages: Pages = {};
lastPageDisplayed: number | undefined;
focusOnMe: boolean;
joinSpinner: boolean = false;
joinSpinner = false;
playerInfoId?: string;
disableClicks: boolean = true;
searching: boolean = false;
disableClicks = true;
searching = false;
private lastStorage = lichess.storage.make('last-redirect');

View File

@ -21,12 +21,12 @@ export default class TournamentController {
pages: Pages = {};
lastPageDisplayed: number | undefined;
focusOnMe: boolean;
joinSpinner: boolean = false;
joinSpinner = false;
playerInfo: PlayerInfo = {};
teamInfo: CtrlTeamInfo = {};
disableClicks: boolean = true;
searching: boolean = false;
joinWithTeamSelector: boolean = false;
disableClicks = true;
searching = false;
joinWithTeamSelector = false;
redraw: () => void;
private lastStorage = lichess.storage.make('last-redirect');

View File

@ -33,7 +33,7 @@ export function playerName(p) {
return p.title ? [h('span.utitle', p.title), ' ' + p.name] : p.name;
}
export function player(p, asLink: boolean, withRating: boolean, defender: boolean = false, leader: boolean = false) {
export function player(p, asLink: boolean, withRating: boolean, defender = false, leader = false) {
return h(
'a.ulpt.user-link' + (((p.title || '') + p.name).length > 15 ? '.long' : ''),
{