chore: upgrade to eslint v8 (#38472)

chore: upgrade to eslint@8
This commit is contained in:
Milan Burda 2023-05-30 13:10:22 +02:00 committed by GitHub
parent a6f7c7690d
commit 71fb19ea14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 288 additions and 715 deletions

View file

@ -83,50 +83,50 @@ abstract class TouchBarItem<ConfigType> extends EventEmitter {
class TouchBarButton extends TouchBarItem<Electron.TouchBarButtonConstructorOptions> implements Electron.TouchBarButton { class TouchBarButton extends TouchBarItem<Electron.TouchBarButtonConstructorOptions> implements Electron.TouchBarButton {
@ImmutableProperty(() => 'button') @ImmutableProperty(() => 'button')
type!: string; type!: string;
@LiveProperty<TouchBarButton>(config => config.label) @LiveProperty<TouchBarButton>(config => config.label)
label!: string; label!: string;
@LiveProperty<TouchBarButton>(config => config.accessibilityLabel) @LiveProperty<TouchBarButton>(config => config.accessibilityLabel)
accessibilityLabel!: string; accessibilityLabel!: string;
@LiveProperty<TouchBarButton>(config => config.backgroundColor) @LiveProperty<TouchBarButton>(config => config.backgroundColor)
backgroundColor!: string; backgroundColor!: string;
@LiveProperty<TouchBarButton>(config => config.icon) @LiveProperty<TouchBarButton>(config => config.icon)
icon!: Electron.NativeImage; icon!: Electron.NativeImage;
@LiveProperty<TouchBarButton>(config => config.iconPosition) @LiveProperty<TouchBarButton>(config => config.iconPosition)
iconPosition!: Electron.TouchBarButton['iconPosition']; iconPosition!: Electron.TouchBarButton['iconPosition'];
@LiveProperty<TouchBarButton>(config => typeof config.enabled !== 'boolean' ? true : config.enabled) @LiveProperty<TouchBarButton>(config => typeof config.enabled !== 'boolean' ? true : config.enabled)
enabled!: boolean; enabled!: boolean;
@ImmutableProperty<TouchBarButton>(({ click: onClick }) => typeof onClick === 'function' ? () => onClick() : null) @ImmutableProperty<TouchBarButton>(({ click: onClick }) => typeof onClick === 'function' ? () => onClick() : null)
onInteraction!: Function | null; onInteraction!: Function | null;
} }
class TouchBarColorPicker extends TouchBarItem<Electron.TouchBarColorPickerConstructorOptions> implements Electron.TouchBarColorPicker { class TouchBarColorPicker extends TouchBarItem<Electron.TouchBarColorPickerConstructorOptions> implements Electron.TouchBarColorPicker {
@ImmutableProperty(() => 'colorpicker') @ImmutableProperty(() => 'colorpicker')
type!: string; type!: string;
@LiveProperty<TouchBarColorPicker>(config => config.availableColors) @LiveProperty<TouchBarColorPicker>(config => config.availableColors)
availableColors!: string[]; availableColors!: string[];
@LiveProperty<TouchBarColorPicker>(config => config.selectedColor) @LiveProperty<TouchBarColorPicker>(config => config.selectedColor)
selectedColor!: string; selectedColor!: string;
@ImmutableProperty<TouchBarColorPicker>(({ change: onChange }, setInternalProp) => typeof onChange === 'function' ? (details: { color: string }) => { @ImmutableProperty<TouchBarColorPicker>(({ change: onChange }, setInternalProp) => typeof onChange === 'function' ? (details: { color: string }) => {
setInternalProp('selectedColor', details.color); setInternalProp('selectedColor', details.color);
onChange(details.color); onChange(details.color);
} : null) } : null)
onInteraction!: Function | null; onInteraction!: Function | null;
} }
class TouchBarGroup extends TouchBarItem<Electron.TouchBarGroupConstructorOptions> implements Electron.TouchBarGroup { class TouchBarGroup extends TouchBarItem<Electron.TouchBarGroupConstructorOptions> implements Electron.TouchBarGroup {
@ImmutableProperty(() => 'group') @ImmutableProperty(() => 'group')
type!: string; type!: string;
@LiveProperty<TouchBarGroup>(config => config.items instanceof TouchBar ? config.items : new TouchBar(config.items), (self, newChild: TouchBar) => { @LiveProperty<TouchBarGroup>(config => config.items instanceof TouchBar ? config.items : new TouchBar(config.items), (self, newChild: TouchBar) => {
if (self.child) { if (self.child) {
@ -138,39 +138,39 @@ class TouchBarGroup extends TouchBarItem<Electron.TouchBarGroupConstructorOption
item._addParent(self); item._addParent(self);
} }
}) })
child!: TouchBar; child!: TouchBar;
onInteraction = null; onInteraction = null;
} }
class TouchBarLabel extends TouchBarItem<Electron.TouchBarLabelConstructorOptions> implements Electron.TouchBarLabel { class TouchBarLabel extends TouchBarItem<Electron.TouchBarLabelConstructorOptions> implements Electron.TouchBarLabel {
@ImmutableProperty(() => 'label') @ImmutableProperty(() => 'label')
type!: string; type!: string;
@LiveProperty<TouchBarLabel>(config => config.label) @LiveProperty<TouchBarLabel>(config => config.label)
label!: string; label!: string;
@LiveProperty<TouchBarLabel>(config => config.accessibilityLabel) @LiveProperty<TouchBarLabel>(config => config.accessibilityLabel)
accessibilityLabel!: string; accessibilityLabel!: string;
@LiveProperty<TouchBarLabel>(config => config.textColor) @LiveProperty<TouchBarLabel>(config => config.textColor)
textColor!: string; textColor!: string;
onInteraction = null; onInteraction = null;
} }
class TouchBarPopover extends TouchBarItem<Electron.TouchBarPopoverConstructorOptions> implements Electron.TouchBarPopover { class TouchBarPopover extends TouchBarItem<Electron.TouchBarPopoverConstructorOptions> implements Electron.TouchBarPopover {
@ImmutableProperty(() => 'popover') @ImmutableProperty(() => 'popover')
type!: string; type!: string;
@LiveProperty<TouchBarPopover>(config => config.label) @LiveProperty<TouchBarPopover>(config => config.label)
label!: string; label!: string;
@LiveProperty<TouchBarPopover>(config => config.icon) @LiveProperty<TouchBarPopover>(config => config.icon)
icon!: Electron.NativeImage; icon!: Electron.NativeImage;
@LiveProperty<TouchBarPopover>(config => config.showCloseButton) @LiveProperty<TouchBarPopover>(config => config.showCloseButton)
showCloseButton!: boolean; showCloseButton!: boolean;
@LiveProperty<TouchBarPopover>(config => config.items instanceof TouchBar ? config.items : new TouchBar(config.items), (self, newChild: TouchBar) => { @LiveProperty<TouchBarPopover>(config => config.items instanceof TouchBar ? config.items : new TouchBar(config.items), (self, newChild: TouchBar) => {
if (self.child) { if (self.child) {
@ -182,88 +182,88 @@ class TouchBarPopover extends TouchBarItem<Electron.TouchBarPopoverConstructorOp
item._addParent(self); item._addParent(self);
} }
}) })
child!: TouchBar; child!: TouchBar;
onInteraction = null; onInteraction = null;
} }
class TouchBarSlider extends TouchBarItem<Electron.TouchBarSliderConstructorOptions> implements Electron.TouchBarSlider { class TouchBarSlider extends TouchBarItem<Electron.TouchBarSliderConstructorOptions> implements Electron.TouchBarSlider {
@ImmutableProperty(() => 'slider') @ImmutableProperty(() => 'slider')
type!: string; type!: string;
@LiveProperty<TouchBarSlider>(config => config.label) @LiveProperty<TouchBarSlider>(config => config.label)
label!: string; label!: string;
@LiveProperty<TouchBarSlider>(config => config.minValue) @LiveProperty<TouchBarSlider>(config => config.minValue)
minValue!: number; minValue!: number;
@LiveProperty<TouchBarSlider>(config => config.maxValue) @LiveProperty<TouchBarSlider>(config => config.maxValue)
maxValue!: number; maxValue!: number;
@LiveProperty<TouchBarSlider>(config => config.value) @LiveProperty<TouchBarSlider>(config => config.value)
value!: number; value!: number;
@ImmutableProperty<TouchBarSlider>(({ change: onChange }, setInternalProp) => typeof onChange === 'function' ? (details: { value: number }) => { @ImmutableProperty<TouchBarSlider>(({ change: onChange }, setInternalProp) => typeof onChange === 'function' ? (details: { value: number }) => {
setInternalProp('value', details.value); setInternalProp('value', details.value);
onChange(details.value); onChange(details.value);
} : null) } : null)
onInteraction!: Function | null; onInteraction!: Function | null;
} }
class TouchBarSpacer extends TouchBarItem<Electron.TouchBarSpacerConstructorOptions> implements Electron.TouchBarSpacer { class TouchBarSpacer extends TouchBarItem<Electron.TouchBarSpacerConstructorOptions> implements Electron.TouchBarSpacer {
@ImmutableProperty(() => 'spacer') @ImmutableProperty(() => 'spacer')
type!: string; type!: string;
@ImmutableProperty<TouchBarSpacer>(config => config.size) @ImmutableProperty<TouchBarSpacer>(config => config.size)
size!: Electron.TouchBarSpacer['size']; size!: Electron.TouchBarSpacer['size'];
onInteraction = null; onInteraction = null;
} }
class TouchBarSegmentedControl extends TouchBarItem<Electron.TouchBarSegmentedControlConstructorOptions> implements Electron.TouchBarSegmentedControl { class TouchBarSegmentedControl extends TouchBarItem<Electron.TouchBarSegmentedControlConstructorOptions> implements Electron.TouchBarSegmentedControl {
@ImmutableProperty(() => 'segmented_control') @ImmutableProperty(() => 'segmented_control')
type!: string; type!: string;
@LiveProperty<TouchBarSegmentedControl>(config => config.segmentStyle) @LiveProperty<TouchBarSegmentedControl>(config => config.segmentStyle)
segmentStyle!: Electron.TouchBarSegmentedControl['segmentStyle']; segmentStyle!: Electron.TouchBarSegmentedControl['segmentStyle'];
@LiveProperty<TouchBarSegmentedControl>(config => config.segments || []) @LiveProperty<TouchBarSegmentedControl>(config => config.segments || [])
segments!: Electron.SegmentedControlSegment[]; segments!: Electron.SegmentedControlSegment[];
@LiveProperty<TouchBarSegmentedControl>(config => config.selectedIndex) @LiveProperty<TouchBarSegmentedControl>(config => config.selectedIndex)
selectedIndex!: number; selectedIndex!: number;
@LiveProperty<TouchBarSegmentedControl>(config => config.mode) @LiveProperty<TouchBarSegmentedControl>(config => config.mode)
mode!: Electron.TouchBarSegmentedControl['mode']; mode!: Electron.TouchBarSegmentedControl['mode'];
@ImmutableProperty<TouchBarSegmentedControl>(({ change: onChange }, setInternalProp) => typeof onChange === 'function' ? (details: { selectedIndex: number, isSelected: boolean }) => { @ImmutableProperty<TouchBarSegmentedControl>(({ change: onChange }, setInternalProp) => typeof onChange === 'function' ? (details: { selectedIndex: number, isSelected: boolean }) => {
setInternalProp('selectedIndex', details.selectedIndex); setInternalProp('selectedIndex', details.selectedIndex);
onChange(details.selectedIndex, details.isSelected); onChange(details.selectedIndex, details.isSelected);
} : null) } : null)
onInteraction!: Function | null; onInteraction!: Function | null;
} }
class TouchBarScrubber extends TouchBarItem<Electron.TouchBarScrubberConstructorOptions> implements Electron.TouchBarScrubber { class TouchBarScrubber extends TouchBarItem<Electron.TouchBarScrubberConstructorOptions> implements Electron.TouchBarScrubber {
@ImmutableProperty(() => 'scrubber') @ImmutableProperty(() => 'scrubber')
type!: string; type!: string;
@LiveProperty<TouchBarScrubber>(config => config.items) @LiveProperty<TouchBarScrubber>(config => config.items)
items!: Electron.ScrubberItem[]; items!: Electron.ScrubberItem[];
@LiveProperty<TouchBarScrubber>(config => config.selectedStyle || null) @LiveProperty<TouchBarScrubber>(config => config.selectedStyle || null)
selectedStyle!: Electron.TouchBarScrubber['selectedStyle']; selectedStyle!: Electron.TouchBarScrubber['selectedStyle'];
@LiveProperty<TouchBarScrubber>(config => config.overlayStyle || null) @LiveProperty<TouchBarScrubber>(config => config.overlayStyle || null)
overlayStyle!: Electron.TouchBarScrubber['overlayStyle']; overlayStyle!: Electron.TouchBarScrubber['overlayStyle'];
@LiveProperty<TouchBarScrubber>(config => config.showArrowButtons || false) @LiveProperty<TouchBarScrubber>(config => config.showArrowButtons || false)
showArrowButtons!: boolean; showArrowButtons!: boolean;
@LiveProperty<TouchBarScrubber>(config => config.mode || 'free') @LiveProperty<TouchBarScrubber>(config => config.mode || 'free')
mode!: Electron.TouchBarScrubber['mode']; mode!: Electron.TouchBarScrubber['mode'];
@LiveProperty<TouchBarScrubber>(config => typeof config.continuous === 'undefined' ? true : config.continuous) @LiveProperty<TouchBarScrubber>(config => typeof config.continuous === 'undefined' ? true : config.continuous)
continuous!: boolean; continuous!: boolean;
@ImmutableProperty<TouchBarScrubber>(({ select: onSelect, highlight: onHighlight }) => typeof onSelect === 'function' || typeof onHighlight === 'function' ? (details: { type: 'select'; selectedIndex: number } | { type: 'highlight'; highlightedIndex: number }) => { @ImmutableProperty<TouchBarScrubber>(({ select: onSelect, highlight: onHighlight }) => typeof onSelect === 'function' || typeof onHighlight === 'function' ? (details: { type: 'select'; selectedIndex: number } | { type: 'highlight'; highlightedIndex: number }) => {
if (details.type === 'select') { if (details.type === 'select') {
@ -272,7 +272,7 @@ class TouchBarScrubber extends TouchBarItem<Electron.TouchBarScrubberConstructor
if (onHighlight) onHighlight(details.highlightedIndex); if (onHighlight) onHighlight(details.highlightedIndex);
} }
} : null) } : null)
onInteraction!: Function | null; onInteraction!: Function | null;
} }
class TouchBarOtherItemsProxy extends TouchBarItem<null> implements Electron.TouchBarOtherItemsProxy { class TouchBarOtherItemsProxy extends TouchBarItem<null> implements Electron.TouchBarOtherItemsProxy {

View file

@ -19,14 +19,14 @@ export class IpcMainImpl extends EventEmitter {
throw new Error(`Expected handler to be a function, but found type '${typeof fn}'`); throw new Error(`Expected handler to be a function, but found type '${typeof fn}'`);
} }
this._invokeHandlers.set(method, fn); this._invokeHandlers.set(method, fn);
} };
handleOnce: Electron.IpcMain['handleOnce'] = (method, fn) => { handleOnce: Electron.IpcMain['handleOnce'] = (method, fn) => {
this.handle(method, (e, ...args) => { this.handle(method, (e, ...args) => {
this.removeHandler(method); this.removeHandler(method);
return fn(e, ...args); return fn(e, ...args);
}); });
} };
removeHandler (method: string) { removeHandler (method: string) {
this._invokeHandlers.delete(method); this._invokeHandlers.delete(method);

View file

@ -1,7 +1,7 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
export class MessagePortMain extends EventEmitter { export class MessagePortMain extends EventEmitter {
_internalPort: any _internalPort: any;
constructor (internalPort: any) { constructor (internalPort: any) {
super(); super();
this._internalPort = internalPort; this._internalPort = internalPort;

View file

@ -53,7 +53,7 @@ export class WebViewAttribute implements MutationHandler {
} }
// Called when the attribute's value changes. // Called when the attribute's value changes.
public handleMutation: MutationHandler['handleMutation'] = () => undefined public handleMutation: MutationHandler['handleMutation'] = () => undefined;
} }
// An attribute that is treated as a Boolean. // An attribute that is treated as a Boolean.
@ -73,7 +73,7 @@ class BooleanAttribute extends WebViewAttribute {
// Attribute representing the state of the storage partition. // Attribute representing the state of the storage partition.
export class PartitionAttribute extends WebViewAttribute { export class PartitionAttribute extends WebViewAttribute {
public validPartitionId = true public validPartitionId = true;
constructor (public webViewImpl: WebViewImpl) { constructor (public webViewImpl: WebViewImpl) {
super(WEB_VIEW_ATTRIBUTES.PARTITION, webViewImpl); super(WEB_VIEW_ATTRIBUTES.PARTITION, webViewImpl);
@ -92,7 +92,7 @@ export class PartitionAttribute extends WebViewAttribute {
this.validPartitionId = false; this.validPartitionId = false;
console.error(WEB_VIEW_ERROR_MESSAGES.INVALID_PARTITION_ATTRIBUTE); console.error(WEB_VIEW_ERROR_MESSAGES.INVALID_PARTITION_ATTRIBUTE);
} }
} };
} }
// Attribute that handles the location and navigation of the webview. // Attribute that handles the location and navigation of the webview.
@ -134,7 +134,7 @@ export class SrcAttribute extends WebViewAttribute {
return; return;
} }
this.parse(); this.parse();
} };
// The purpose of this mutation observer is to catch assignment to the src // The purpose of this mutation observer is to catch assignment to the src
// attribute without any changes to its value. This is useful in the case // attribute without any changes to its value. This is useful in the case

View file

@ -19,16 +19,16 @@ export interface WebViewImplHooks {
// Represents the internal state of the WebView node. // Represents the internal state of the WebView node.
export class WebViewImpl { export class WebViewImpl {
public beforeFirstNavigation = true public beforeFirstNavigation = true;
public elementAttached = false public elementAttached = false;
public guestInstanceId?: number public guestInstanceId?: number;
public hasFocus = false public hasFocus = false;
public internalInstanceId?: number; public internalInstanceId?: number;
public viewInstanceId: number public viewInstanceId: number;
// on* Event handlers. // on* Event handlers.
public on: Record<string, any> = {} public on: Record<string, any> = {};
public internalElement: HTMLIFrameElement public internalElement: HTMLIFrameElement;
public attributes: Map<string, WebViewAttribute>; public attributes: Map<string, WebViewAttribute>;

View file

@ -3,7 +3,7 @@ import { MessagePortMain } from '@electron/internal/browser/message-port-main';
const { createParentPort } = process._linkedBinding('electron_utility_parent_port'); const { createParentPort } = process._linkedBinding('electron_utility_parent_port');
export class ParentPort extends EventEmitter { export class ParentPort extends EventEmitter {
#port: ParentPort #port: ParentPort;
constructor () { constructor () {
super(); super();
this.#port = createParentPort(); this.#port = createParentPort();

View file

@ -32,21 +32,20 @@
"@types/uuid": "^3.4.6", "@types/uuid": "^3.4.6",
"@types/webpack": "^5.28.0", "@types/webpack": "^5.28.0",
"@types/webpack-env": "^1.17.0", "@types/webpack-env": "^1.17.0",
"@typescript-eslint/eslint-plugin": "^4.4.1", "@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^4.4.1", "@typescript-eslint/parser": "^5.59.7",
"buffer": "^6.0.3", "buffer": "^6.0.3",
"check-for-leaks": "^1.2.1", "check-for-leaks": "^1.2.1",
"colors": "1.4.0", "colors": "1.4.0",
"dotenv-safe": "^4.0.4", "dotenv-safe": "^4.0.4",
"dugite": "^2.3.0", "dugite": "^2.3.0",
"eslint": "^7.4.0", "eslint": "^8.41.0",
"eslint-config-standard": "^14.1.1", "eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.22.0", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-mocha": "^7.0.1", "eslint-plugin-mocha": "^7.0.1",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1", "eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1", "eslint-plugin-standard": "^4.0.1",
"eslint-plugin-typescript": "^0.14.0",
"events": "^3.2.0", "events": "^3.2.0",
"express": "^4.16.4", "express": "^4.16.4",
"folder-hash": "^2.1.1", "folder-hash": "^2.1.1",

View file

@ -65,11 +65,11 @@ class RemoteControlApp {
req.write(js); req.write(js);
req.end(); req.end();
}); });
} };
remotely = (script: Function, ...args: any[]): Promise<any> => { remotely = (script: Function, ...args: any[]): Promise<any> => {
return this.remoteEval(`(${script})(...${JSON.stringify(args)})`); return this.remoteEval(`(${script})(...${JSON.stringify(args)})`);
} };
} }
export async function startRemoteControlApp (extraArgs: string[] = [], options?: childProcess.SpawnOptionsWithoutStdio) { export async function startRemoteControlApp (extraArgs: string[] = [], options?: childProcess.SpawnOptionsWithoutStdio) {

870
yarn.lock

File diff suppressed because it is too large Load diff