Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump @typescript-eslint/eslint-plugin from 7.17.0 to 8.0.1 #8479

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ function buildTSOverride({files, tsconfig}) {
'@typescript-eslint/no-empty-function': ['off'],
// Temporarily disable. 3 problems.
'@typescript-eslint/no-empty-interface': ['off'],
// We use this pattern extensively for block (e.g. controls_if) interfaces.
'@typescript-eslint/no-empty-object-type': ['off'],

// TsDoc rules (using JsDoc plugin)
// Disable built-in jsdoc verifier.
Expand Down
12 changes: 7 additions & 5 deletions core/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export class Block implements IASTNodeLocation {
/**
* String for block help, or function that returns a URL. Null for no help.
*/
helpUrl: string | Function | null = null;
helpUrl: string | (() => string) | null = null;

/** A bound callback function to use when the parent workspace changes. */
private onchangeWrapper_: ((p1: Abstract) => void) | null = null;
Expand Down Expand Up @@ -997,7 +997,7 @@ export class Block implements IASTNodeLocation {
* @param url URL string for block help, or function that returns a URL. Null
* for no help.
*/
setHelpUrl(url: string | Function) {
setHelpUrl(url: string | (() => string)) {
BeksOmega marked this conversation as resolved.
Show resolved Hide resolved
this.helpUrl = url;
}

Expand Down Expand Up @@ -1864,7 +1864,7 @@ export class Block implements IASTNodeLocation {
const rawValue = json['colour'];
try {
this.setColour(rawValue);
} catch (e) {
} catch {
console.warn(warningPrefix + 'Illegal colour value: ', rawValue);
}
}
Expand All @@ -1881,7 +1881,7 @@ export class Block implements IASTNodeLocation {
const blockStyleName = json['style'];
try {
this.setStyle(blockStyleName);
} catch (styleError) {
} catch {
console.warn(warningPrefix + 'Style does not exist: ', blockStyleName);
}
}
Expand Down Expand Up @@ -2461,7 +2461,9 @@ export class Block implements IASTNodeLocation {
const event = new (eventUtils.get(eventUtils.BLOCK_MOVE))(
this,
) as BlockMove;
reason && event.setReason(reason);
if (reason) {
event.setReason(reason);
}
this.xy_.translate(dx, dy);
event.recordNew();
eventUtils.fire(event);
Expand Down
4 changes: 3 additions & 1 deletion core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ export class BlockSvg
let event: BlockMove | null = null;
if (eventsEnabled) {
event = new (eventUtils.get(eventUtils.BLOCK_MOVE)!)(this) as BlockMove;
reason && event.setReason(reason);
if (reason) {
event.setReason(reason);
}
}

const delta = new Coordinate(dx, dy);
Expand Down
8 changes: 6 additions & 2 deletions core/browser_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

// Former goog.module ID: Blockly.browserEvents

// Theoretically we could figure out a way to type the event params correctly,
// but it's not high priority.
/* eslint-disable @typescript-eslint/no-unsafe-function-type */

import * as Touch from './touch.js';
import * as userAgent from './utils/useragent.js';

Expand Down Expand Up @@ -47,7 +51,7 @@ const PAGE_MODE_MULTIPLIER = 125;
export function conditionalBind(
node: EventTarget,
name: string,
thisObject: Object | null,
thisObject: object | null,
BeksOmega marked this conversation as resolved.
Show resolved Hide resolved
func: Function,
opt_noCaptureIdentifier?: boolean,
): Data {
Expand Down Expand Up @@ -96,7 +100,7 @@ export function conditionalBind(
export function bind(
node: EventTarget,
name: string,
thisObject: Object | null,
thisObject: object | null,
func: Function,
): Data {
/**
Expand Down
4 changes: 3 additions & 1 deletion core/dragging/bubble_drag_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export class BubbleDragStrategy implements IDragStrategy {
this.startLoc = this.bubble.getRelativeToSurfaceXY();
this.workspace.setResizesEnabled(false);
this.workspace.getLayerManager()?.moveToDragLayer(this.bubble);
this.bubble.setDragging && this.bubble.setDragging(true);
if (this.bubble.setDragging) {
this.bubble.setDragging(true);
}
BeksOmega marked this conversation as resolved.
Show resolved Hide resolved
}

drag(newLoc: Coordinate): void {
Expand Down
10 changes: 5 additions & 5 deletions core/dropdowndiv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const ANIMATION_TIME = 0.25;
let animateOutTimer: ReturnType<typeof setTimeout> | null = null;

/** Callback for when the drop-down is hidden. */
let onHide: Function | null = null;
let onHide: (() => void) | null = null;

/** A class name representing the current owner's workspace renderer. */
let renderedClassName = '';
Expand Down Expand Up @@ -202,7 +202,7 @@ export function setColour(backgroundColour: string, borderColour: string) {
export function showPositionedByBlock<T>(
field: Field<T>,
block: BlockSvg,
opt_onHide?: Function,
opt_onHide?: () => void,
opt_secondaryYOffset?: number,
): boolean {
return showPositionedByRect(
Expand All @@ -226,7 +226,7 @@ export function showPositionedByBlock<T>(
*/
export function showPositionedByField<T>(
field: Field<T>,
opt_onHide?: Function,
opt_onHide?: () => void,
opt_secondaryYOffset?: number,
): boolean {
positionToField = true;
Expand Down Expand Up @@ -278,7 +278,7 @@ function getScaledBboxOfField(field: Field): Rect {
function showPositionedByRect(
bBox: Rect,
field: Field,
opt_onHide?: Function,
opt_onHide?: () => void,
opt_secondaryYOffset?: number,
): boolean {
// If we can fit it, render below the block.
Expand Down Expand Up @@ -334,7 +334,7 @@ export function show<T>(
primaryY: number,
secondaryX: number,
secondaryY: number,
opt_onHide?: Function,
opt_onHide?: () => void,
): boolean {
owner = newOwner as Field;
onHide = opt_onHide || null;
Expand Down
2 changes: 1 addition & 1 deletion core/events/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function fireInternal(event: Abstract) {
requestAnimationFrame(() => {
setTimeout(fireNow, 0);
});
} catch (e) {
} catch {
// Otherwise we just want to delay so events can be coallesced.
// requestAnimationFrame will error triggering this.
setTimeout(fireNow, 0);
Expand Down
5 changes: 4 additions & 1 deletion core/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export const TEST_ONLY = {allExtensions};
* @throws {Error} if the extension name is empty, the extension is already
* registered, or extensionFn is not a function.
*/
export function register(name: string, initFn: Function) {
export function register<T extends Block>(
name: string,
initFn: (this: T) => void,
) {
BeksOmega marked this conversation as resolved.
Show resolved Hide resolved
if (typeof name !== 'string' || name.trim() === '') {
throw Error('Error: Invalid extension name "' + name + '"');
}
Expand Down
12 changes: 6 additions & 6 deletions core/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ export abstract class Field<T = any>
setValue(newValue: AnyDuringMigration, fireChangeEvent = true) {
const doLogging = false;
if (newValue === null) {
doLogging && console.log('null, return');
if (doLogging) console.log('null, return');
// Not a valid value to check.
return;
}
Expand All @@ -1092,7 +1092,7 @@ export abstract class Field<T = any>
fireChangeEvent,
);
if (classValue instanceof Error) {
doLogging && console.log('invalid class validation, return');
if (doLogging) console.log('invalid class validation, return');
return;
}

Expand All @@ -1103,19 +1103,19 @@ export abstract class Field<T = any>
fireChangeEvent,
);
if (localValue instanceof Error) {
doLogging && console.log('invalid local validation, return');
if (doLogging) console.log('invalid local validation, return');
return;
}

const source = this.sourceBlock_;
if (source && source.disposed) {
doLogging && console.log('source disposed, return');
if (doLogging) console.log('source disposed, return');
return;
}

const oldValue = this.getValue();
if (oldValue === localValue) {
doLogging && console.log('same, doValueUpdate_, return');
if (doLogging) console.log('same, doValueUpdate_, return');
this.doValueUpdate_(localValue);
return;
}
Expand All @@ -1135,7 +1135,7 @@ export abstract class Field<T = any>
if (this.isDirty_) {
this.forceRerender();
}
doLogging && console.log(this.value_);
if (doLogging) console.log(this.value_);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/flyout_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ export abstract class Flyout
* @param block The flyout block to copy.
* @returns Function to call when block is clicked.
*/
private blockMouseDown(block: BlockSvg): Function {
private blockMouseDown(block: BlockSvg) {
return (e: PointerEvent) => {
const gesture = this.targetWorkspace.getGesture(e);
if (gesture) {
Expand Down
2 changes: 1 addition & 1 deletion core/flyout_metrics_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class FlyoutMetricsManager extends MetricsManager {
let blockBoundingBox;
try {
blockBoundingBox = this.workspace_.getCanvas().getBBox();
} catch (e) {
} catch {
// Firefox has trouble with hidden elements (Bug 528969).
// 2021 Update: It looks like this was fixed around Firefox 77 released in
// 2020.
Expand Down
2 changes: 1 addition & 1 deletion core/insertion_marker_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ export class InsertionMarkerManager {
local.getSourceBlock(),
local,
);
} catch (e) {
} catch {
// It's possible that the number of connections on the local block has
// changed since the insertion marker was originally created. Let's
// recreate the insertion marker and try again. In theory we could
Expand Down
2 changes: 1 addition & 1 deletion core/interfaces/i_comment_icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface ICommentIcon extends IIcon, IHasBubble, ISerializable {
}

/** Checks whether the given object is an ICommentIcon. */
export function isCommentIcon(obj: Object): obj is ICommentIcon {
export function isCommentIcon(obj: object): obj is ICommentIcon {
return (
isIcon(obj) &&
hasBubble(obj) &&
Expand Down
4 changes: 2 additions & 2 deletions core/interfaces/i_legacy_procedure_blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface LegacyProcedureDefBlock {

/** @internal */
export function isLegacyProcedureDefBlock(
block: Object,
block: object,
BeksOmega marked this conversation as resolved.
Show resolved Hide resolved
): block is LegacyProcedureDefBlock {
return (block as any).getProcedureDef !== undefined;
}
Expand All @@ -41,7 +41,7 @@ export interface LegacyProcedureCallBlock {

/** @internal */
export function isLegacyProcedureCallBlock(
block: Object,
block: object,
): block is LegacyProcedureCallBlock {
return (
(block as any).getProcedureCall !== undefined &&
Expand Down
2 changes: 1 addition & 1 deletion core/interfaces/i_selectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface ISelectable {
}

/** Checks whether the given object is an ISelectable. */
export function isSelectable(obj: Object): obj is ISelectable {
export function isSelectable(obj: object): obj is ISelectable {
return (
typeof (obj as any).id === 'string' &&
(obj as any).workspace !== undefined &&
Expand Down
4 changes: 2 additions & 2 deletions core/interfaces/i_serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface ISerializer {
* @returns A JS object containing the system's state, or null if there is no
* state to record.
*/
save(workspace: Workspace): Object | null;
save(workspace: Workspace): object | null;
/* eslint-enable valid-jsdoc */

/**
Expand All @@ -42,7 +42,7 @@ export interface ISerializer {
* @param workspace The workspace the system to deserialize is associated
* with.
*/
load(state: Object, workspace: Workspace): void;
load(state: object, workspace: Workspace): void;

/**
* Clears the state of the plugin or system.
Expand Down
2 changes: 1 addition & 1 deletion core/menuitem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class MenuItem {
private highlight = false;

/** Bound function to call when this menu item is clicked. */
private actionHandler: Function | null = null;
private actionHandler: ((obj: this) => void) | null = null;

/**
* @param content Text caption to display as the content of the item, or a
Expand Down
2 changes: 1 addition & 1 deletion core/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export function register<T>(
* @param registryItem A class or object that we are checking for the required
* properties.
*/
function validate(type: string, registryItem: Function | AnyDuringMigration) {
function validate(type: string, registryItem: AnyDuringMigration) {
switch (type) {
case String(Type.FIELD):
if (typeof registryItem.fromJson !== 'function') {
Expand Down
11 changes: 6 additions & 5 deletions core/rendered_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class RenderedConnection extends Connection {
}
// Raise it to the top for extra visibility.
const selected = common.getSelected() == rootBlock;
selected || rootBlock.addSelect();
if (!selected) rootBlock.addSelect();
let dx =
staticConnection.x +
config.snapRadius +
Expand All @@ -169,7 +169,7 @@ export class RenderedConnection extends Connection {
this.x;
}
rootBlock.moveBy(dx, dy, ['bump']);
selected || rootBlock.removeSelect();
if (!selected) rootBlock.removeSelect();
}

/**
Expand Down Expand Up @@ -389,9 +389,10 @@ export class RenderedConnection extends Connection {
if (block.isCollapsed()) {
// This block should only be partially revealed since it is collapsed.
connections = [];
block.outputConnection && connections.push(block.outputConnection);
block.nextConnection && connections.push(block.nextConnection);
block.previousConnection && connections.push(block.previousConnection);
if (block.outputConnection) connections.push(block.outputConnection);
if (block.nextConnection) connections.push(block.nextConnection);
if (block.previousConnection)
connections.push(block.previousConnection);
} else {
// Show all connections of this block.
connections = block.getConnections_(true);
Expand Down
5 changes: 4 additions & 1 deletion core/renderers/common/block_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ import {Renderer} from './renderer.js';
* @param rendererClass The new renderer class to register.
* @throws {Error} if a renderer with the same name has already been registered.
*/
export function register(name: string, rendererClass: Function) {
export function register(
name: string,
rendererClass: new (name: string) => Renderer,
) {
registry.register(registry.Type.RENDERER, name, rendererClass);
}

Expand Down
8 changes: 5 additions & 3 deletions core/renderers/common/marker_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ export class MarkerSvg {

// Ensures the marker will be visible immediately after the move.
const animate = this.currentMarkerSvg!.childNodes[0];
if (animate !== undefined) {
(animate as SVGAnimationElement).beginElement &&
(animate as SVGAnimationElement).beginElement();
if (
animate !== undefined &&
(animate as SVGAnimationElement).beginElement
) {
(animate as SVGAnimationElement).beginElement();
BeksOmega marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
3 changes: 3 additions & 0 deletions core/renderers/measurables/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import type {Row} from './row.js';
* Types of rendering elements.
*/
class TypesContainer {
// This class is very non-idiomatic for typescript, so we have to use
// the Function type to make it happy.
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
[index: string]: number | Function;

NONE = 0; // None
Expand Down
Loading