mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 17:49:58 +00:00
Switch to eslint and fix issues
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* tslint:disable:max-line-length */
|
||||
/* eslint-disable max-len */
|
||||
"use strict";
|
||||
|
||||
import React, { Component } from "react";
|
||||
@@ -79,7 +79,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
private updateData: any;
|
||||
private updateStatusTimeout?: number;
|
||||
|
||||
constructor (props: BridgeProps) {
|
||||
constructor(props: BridgeProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@@ -95,7 +95,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
this.onUpdate = this.onUpdate.bind(this);
|
||||
}
|
||||
|
||||
public render () {
|
||||
public render() {
|
||||
const [ backupMessageStart, backupMessageEnd ]
|
||||
= _("optionsBridgeBackupEnabled", "\0").split("\0");
|
||||
|
||||
@@ -177,7 +177,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
);
|
||||
}
|
||||
|
||||
private renderStatus () {
|
||||
private renderStatus() {
|
||||
const infoClasses = `bridge__info ${!this.props.info
|
||||
? this.props.loadingTimedOut
|
||||
? "bridge__info--timed-out"
|
||||
@@ -228,7 +228,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
);
|
||||
}
|
||||
|
||||
private onCheckUpdates () {
|
||||
private onCheckUpdates() {
|
||||
this.setState({
|
||||
isCheckingUpdates: true
|
||||
});
|
||||
@@ -249,7 +249,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
.catch(this.onCheckUpdatesError);
|
||||
}
|
||||
|
||||
private async onCheckUpdatesResponse (res: any) {
|
||||
private async onCheckUpdatesResponse(res: any) {
|
||||
let latestBridgeRelease;
|
||||
for (const release of res) {
|
||||
if (release.assets.find((asset: any) =>
|
||||
@@ -290,7 +290,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
this.showUpdateStatus();
|
||||
}
|
||||
|
||||
private onCheckUpdatesError () {
|
||||
private onCheckUpdatesError() {
|
||||
this.setState({
|
||||
isCheckingUpdates: false
|
||||
, wasErrorCheckingUpdates: true
|
||||
@@ -300,7 +300,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
this.showUpdateStatus();
|
||||
}
|
||||
|
||||
private showUpdateStatus () {
|
||||
private showUpdateStatus() {
|
||||
if (this.updateStatusTimeout) {
|
||||
window.clearTimeout(this.updateStatusTimeout);
|
||||
}
|
||||
@@ -311,7 +311,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
private async onUpdate () {
|
||||
private async onUpdate() {
|
||||
// Open downloads page
|
||||
if (this.updateData.html_url) {
|
||||
browser.tabs.create({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* tslint:disable:max-line-length */
|
||||
/* eslint-disable max-len */
|
||||
"use strict";
|
||||
|
||||
import React, { Component } from "react";
|
||||
@@ -24,7 +24,7 @@ export default class EditableList extends Component<
|
||||
|
||||
private rawViewTextArea: (HTMLTextAreaElement | null) = null;
|
||||
|
||||
constructor (props: EditableListProps) {
|
||||
constructor(props: EditableListProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@@ -43,7 +43,7 @@ export default class EditableList extends Component<
|
||||
this.handleNewItemEdit = this.handleNewItemEdit.bind(this);
|
||||
}
|
||||
|
||||
public render () {
|
||||
public render() {
|
||||
return (
|
||||
<div className="editable-list">
|
||||
{ this.state.rawView
|
||||
@@ -102,21 +102,21 @@ export default class EditableList extends Component<
|
||||
);
|
||||
}
|
||||
|
||||
private handleItemRemove (item: string) {
|
||||
private handleItemRemove(item: string) {
|
||||
const newItems = new Set(this.props.data);
|
||||
newItems.delete(item);
|
||||
|
||||
this.props.onChange([...newItems]);
|
||||
}
|
||||
|
||||
private handleItemEdit (item: string, newValue: string) {
|
||||
private handleItemEdit(item: string, newValue: string) {
|
||||
this.props.onChange(this.props.data.map(
|
||||
currentItem => currentItem === item
|
||||
? newValue
|
||||
: currentItem));
|
||||
}
|
||||
|
||||
private handleSwitchView () {
|
||||
private handleSwitchView() {
|
||||
this.setState(currentState => {
|
||||
if (currentState.rawView) {
|
||||
return {
|
||||
@@ -132,7 +132,7 @@ export default class EditableList extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private handleSaveRaw () {
|
||||
private handleSaveRaw() {
|
||||
this.setState(currentState => {
|
||||
const newItems = currentState.rawViewValue.split("\n")
|
||||
.filter(item => item !== "");
|
||||
@@ -153,7 +153,7 @@ export default class EditableList extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private handleRawViewTextAreaChange (ev: React.ChangeEvent<HTMLTextAreaElement>) {
|
||||
private handleRawViewTextAreaChange(ev: React.ChangeEvent<HTMLTextAreaElement>) {
|
||||
if (!this.rawViewTextArea) {
|
||||
return;
|
||||
}
|
||||
@@ -167,19 +167,19 @@ export default class EditableList extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private handleAddItem () {
|
||||
private handleAddItem() {
|
||||
this.setState({
|
||||
addingNewItem: true
|
||||
});
|
||||
}
|
||||
|
||||
private handleNewItemRemove () {
|
||||
private handleNewItemRemove() {
|
||||
this.setState({
|
||||
addingNewItem: false
|
||||
});
|
||||
}
|
||||
|
||||
private handleNewItemEdit (_item: string, newItem: string) {
|
||||
private handleNewItemEdit(_item: string, newItem: string) {
|
||||
this.setState({
|
||||
addingNewItem: false
|
||||
}, () => {
|
||||
@@ -208,7 +208,7 @@ class EditableListItem extends Component<
|
||||
|
||||
private input: (HTMLInputElement | null) = null;
|
||||
|
||||
constructor (props: EditableListItemProps) {
|
||||
constructor(props: EditableListItemProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@@ -223,7 +223,7 @@ class EditableListItem extends Component<
|
||||
this.handleInputKeyPress = this.handleInputKeyPress.bind(this);
|
||||
}
|
||||
|
||||
public render () {
|
||||
public render() {
|
||||
const selected = this.state.editing
|
||||
? "editable-list__item--selected" : "";
|
||||
|
||||
@@ -260,7 +260,7 @@ class EditableListItem extends Component<
|
||||
);
|
||||
}
|
||||
|
||||
private stopEditing (input: HTMLInputElement) {
|
||||
private stopEditing(input: HTMLInputElement) {
|
||||
if (this.props.editing
|
||||
&& !this.props.itemPattern.test(this.state.editValue)) {
|
||||
input.setCustomValidity(this.props.itemPatternError());
|
||||
@@ -277,11 +277,11 @@ class EditableListItem extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private handleRemove () {
|
||||
private handleRemove() {
|
||||
this.props.onRemove(this.props.text);
|
||||
}
|
||||
|
||||
private handleEditBegin () {
|
||||
private handleEditBegin() {
|
||||
if (!this.state.editing) {
|
||||
this.setState({
|
||||
editing: true
|
||||
@@ -293,11 +293,11 @@ class EditableListItem extends Component<
|
||||
}
|
||||
}
|
||||
|
||||
private handleEditEnd (ev: React.FocusEvent<HTMLInputElement>) {
|
||||
private handleEditEnd(ev: React.FocusEvent<HTMLInputElement>) {
|
||||
this.stopEditing(ev.target);
|
||||
}
|
||||
|
||||
private handleInputChange (ev: React.ChangeEvent<HTMLInputElement>) {
|
||||
private handleInputChange(ev: React.ChangeEvent<HTMLInputElement>) {
|
||||
this.setState({
|
||||
editValue: ev.target.value
|
||||
});
|
||||
@@ -308,7 +308,7 @@ class EditableListItem extends Component<
|
||||
: "");
|
||||
}
|
||||
|
||||
private handleInputKeyPress (ev: React.KeyboardEvent<HTMLInputElement>) {
|
||||
private handleInputKeyPress(ev: React.KeyboardEvent<HTMLInputElement>) {
|
||||
if (ev.key === "Enter") {
|
||||
this.stopEditing(ev.target as HTMLInputElement);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* tslint:disable:max-line-length */
|
||||
/* eslint-disable max-len */
|
||||
"use strict";
|
||||
|
||||
import React, { Component } from "react";
|
||||
@@ -40,7 +40,7 @@ browser.runtime.getPlatformInfo()
|
||||
});
|
||||
|
||||
|
||||
function getInputValue (input: HTMLInputElement) {
|
||||
function getInputValue(input: HTMLInputElement) {
|
||||
switch (input.type) {
|
||||
case "checkbox":
|
||||
return input.checked;
|
||||
@@ -78,7 +78,7 @@ class OptionsApp extends Component<
|
||||
, hasSaved: false
|
||||
};
|
||||
|
||||
constructor (props: OptionsAppProps) {
|
||||
constructor(props: OptionsAppProps) {
|
||||
super(props);
|
||||
|
||||
this.handleReset = this.handleReset.bind(this);
|
||||
@@ -94,7 +94,7 @@ class OptionsApp extends Component<
|
||||
this.getWhitelistItemPatternError.bind(this);
|
||||
}
|
||||
|
||||
public async componentDidMount () {
|
||||
public async componentDidMount() {
|
||||
this.setState({
|
||||
hasLoaded: true
|
||||
, options: await options.getAll()
|
||||
@@ -131,7 +131,7 @@ class OptionsApp extends Component<
|
||||
}
|
||||
}
|
||||
|
||||
public render () {
|
||||
public render() {
|
||||
if (!this.state.hasLoaded) {
|
||||
return;
|
||||
}
|
||||
@@ -402,6 +402,7 @@ class OptionsApp extends Component<
|
||||
{ _("optionsReset") }
|
||||
</button>
|
||||
<button type="submit"
|
||||
// @ts-ignore
|
||||
default
|
||||
disabled={ !this.state.isFormValid }>
|
||||
{ _("optionsSave") }
|
||||
@@ -413,13 +414,13 @@ class OptionsApp extends Component<
|
||||
}
|
||||
|
||||
|
||||
private handleReset () {
|
||||
private handleReset() {
|
||||
this.setState({
|
||||
options: { ...defaultOptions }
|
||||
});
|
||||
}
|
||||
|
||||
private async handleFormSubmit (ev: React.FormEvent<HTMLFormElement>) {
|
||||
private async handleFormSubmit(ev: React.FormEvent<HTMLFormElement>) {
|
||||
ev.preventDefault();
|
||||
|
||||
this.form?.reportValidity();
|
||||
@@ -443,7 +444,7 @@ class OptionsApp extends Component<
|
||||
}
|
||||
}
|
||||
|
||||
private handleFormChange (ev: React.FormEvent<HTMLFormElement>) {
|
||||
private handleFormChange(ev: React.FormEvent<HTMLFormElement>) {
|
||||
ev.preventDefault();
|
||||
|
||||
const isFormValid = this.form?.checkValidity();
|
||||
@@ -454,7 +455,7 @@ class OptionsApp extends Component<
|
||||
}
|
||||
}
|
||||
|
||||
private handleInputChange (ev: React.ChangeEvent<HTMLInputElement>) {
|
||||
private handleInputChange(ev: React.ChangeEvent<HTMLInputElement>) {
|
||||
this.setState(currentState => {
|
||||
if (currentState.options) {
|
||||
currentState.options[ev.target.name] = getInputValue(ev.target);
|
||||
@@ -464,19 +465,20 @@ class OptionsApp extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private handleReceiverSelectorTypeChange (
|
||||
private handleReceiverSelectorTypeChange(
|
||||
ev: React.ChangeEvent<HTMLSelectElement>) {
|
||||
|
||||
this.setState(currentState => {
|
||||
if (currentState.options) {
|
||||
currentState.options[ev.target.name] = parseInt(ev.target.value);
|
||||
currentState.options[ev.target.name] =
|
||||
parseInt(ev.target.value);
|
||||
}
|
||||
|
||||
return currentState;
|
||||
});
|
||||
}
|
||||
|
||||
private handleWhitelistChange (whitelist: string[]) {
|
||||
private handleWhitelistChange(whitelist: string[]) {
|
||||
this.setState(currentState => {
|
||||
if (currentState.options) {
|
||||
currentState.options.userAgentWhitelist = whitelist;
|
||||
@@ -486,7 +488,7 @@ class OptionsApp extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private getWhitelistItemPatternError (info: string): string {
|
||||
private getWhitelistItemPatternError(info: string): string {
|
||||
return _("optionsUserAgentWhitelistInvalidMatchPattern", info);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user