Skip to content

Commit

Permalink
eslintを適用
Browse files Browse the repository at this point in the history
  • Loading branch information
parrot-studio committed Jun 28, 2020
1 parent 8c8a1be commit 749ce55
Show file tree
Hide file tree
Showing 40 changed files with 93 additions and 58 deletions.
15 changes: 9 additions & 6 deletions app/javascript/bundles/browser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare var window
declare var document
declare var history
declare var $
declare let window
declare let document
declare let history
declare let $

// ブラウザ代理オブジェクト(クライアント)
export default class Browser {
Expand Down Expand Up @@ -59,7 +59,8 @@ export default class Browser {
})
}

public static addDropHandler(div: HTMLDivElement, code: string, callback): void {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
public static addDropHandler(div: HTMLLIElement | HTMLDivElement | null, code: string, callback): void {
if (!div) {
return
}
Expand All @@ -72,6 +73,7 @@ export default class Browser {
})
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
public static addSwipeHandler(div: HTMLDivElement, callbackLeft, callbackRight): void {
if (!div) {
return
Expand All @@ -89,7 +91,8 @@ export default class Browser {
})
}

public static addSwitchHandler(div: HTMLDivElement, state: boolean, callback, params: any): void {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
public static addSwitchHandler(div: HTMLDivElement, state: boolean, callback, params): void {
if (!div) {
return
}
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/bundles/ccpts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import FastClick from "fastclick"
import AppView from "./ccpts/components/AppView"
import Browser from "./ccpts/lib/BrowserProxy"

declare var document
declare var window
declare var FastClick
declare let document
declare let window
declare let FastClick

document.addEventListener("DOMContentLoaded", () => {
// init
Expand Down
1 change: 1 addition & 0 deletions app/javascript/bundles/ccpts/components/AppView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as _ from "lodash"
import * as React from "react"
import { Alert, Modal } from "react-bootstrap"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class ArcanaViewModal extends React.Component<ArcanaViewModalProp
}
}

private addFavHandler(inp: HTMLElement | null, a: Arcana): void {
private addFavHandler(inp: HTMLDivElement | null, a: Arcana): void {
if (!inp) {
return
}
Expand Down Expand Up @@ -420,7 +420,7 @@ export default class ArcanaViewModal extends React.Component<ArcanaViewModalProp
const small = [this.renderNoramlDetail(a)]
const normal = [
(
<Tab eventKey="normal" title="通常アビリティ" tabClassName="small">
<Tab eventKey="normal" key="normal" title="通常アビリティ" tabClassName="small">
{this.renderNoramlDetail(a)}
</Tab>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class ConditionView extends React.Component<ConditionViewProps, C

private notifier: Bacon.Bus<QueryParam>

constructor(props) {
constructor(props: Readonly<ConditionViewProps>) {
super(props)
let q = {}
if (this.props.query) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as _ from "lodash"
import * as React from "react"
import { Alert } from "react-bootstrap"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
Expand All @@ -25,7 +24,7 @@ export default class LatestInfoArea extends React.Component<LatestInfoAreaProps,
let visible = false
if (this.props.latestInfo) {
const ver = String(this.props.latestInfo.version) || ""
const cs: any = {}
const cs = {}
cs[LatestInfoArea.COOKIE_NAME] = ver
Cookie.set(cs)
visible = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ interface NameSearchFormState {
name: string
}

// eslint-disable-next-line @typescript-eslint/ban-types
export default class NameSearchForm extends React.Component<{}, NameSearchFormState> {

private nameStream: Bacon.Bus<QueryParam> = new Bacon.Bus()

constructor(props) {
// eslint-disable-next-line @typescript-eslint/ban-types
constructor(props: Readonly<{}>) {
super(props)

this.state = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as _ from "lodash"
import * as React from "react"
import { Nav, NavItem } from "react-bootstrap"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface PagerAreaProps {

export default class PagerArea extends React.Component<PagerAreaProps> {

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
public render() {
const pager = this.props.pager

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/prop-types */
import * as React from "react"
import { Pagination } from "react-bootstrap"
import { createUltimatePagination, ITEM_TYPES } from "react-ultimate-pagination"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import QueryResult from "../../model/QueryResult"

export interface ResultViewProps {
pagerSize: number
// eslint-disable-next-line @typescript-eslint/no-explicit-any
firstResults: any
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ interface SearchMenuButtonState {
querys: Query[]
}

// eslint-disable-next-line @typescript-eslint/ban-types
export default class SearchMenuButton extends React.Component<{}, SearchMenuButtonState> {

constructor(props) {
// eslint-disable-next-line @typescript-eslint/ban-types
constructor(props: Readonly<{}>) {
super(props)
this.state = {
querys: QueryRepository.querys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface DatabaseAreaHeaderState {

export default class DatabaseAreaHeader extends React.Component<DatabaseAreaHeaderProps, DatabaseAreaHeaderState> {

constructor(props) {
constructor(props: Readonly<DatabaseAreaHeaderProps>) {
super(props)
this.state = {
showShareModal: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface DatabaseModeViewProps {
pagerSize: number
latestInfo: LatestInfo | null
firstQuery: Query | null
// eslint-disable-next-line @typescript-eslint/no-explicit-any
firstResults: any
switchConditionMode(): void
}
Expand All @@ -27,7 +28,7 @@ interface DatabaseModeViewState {

export default class DatabaseModeView extends React.Component<DatabaseModeViewProps, DatabaseModeViewState> {

constructor(props) {
constructor(props: Readonly<DatabaseModeViewProps>) {
super(props)

let showHeader = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default abstract class ArcanaRenderer<T, S> extends React.Component<T, S>
}
}

protected isSameArcana(ba: Arcana | null, na: Arcana | null) {
protected isSameArcana(ba: Arcana | null, na: Arcana | null): boolean {
if (ba == null && na == null) {
return true
}
Expand All @@ -40,12 +40,13 @@ export default abstract class ArcanaRenderer<T, S> extends React.Component<T, S>
return false
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
protected openArcanaViewModal(a: Arcana, e): void {
e.preventDefault()
MessageStream.arcanaViewStream.push(a)
}

protected setDraggable(code: string, memkey?: string | null) {
protected setDraggable(code: string, memkey?: string | null): void {
if (!this.div) {
return
}
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/bundles/ccpts/components/edit/EditModeView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as _ from "lodash"
import * as React from "react"

import Arcana from "../../model/Arcana"
import Party from "../../model/Party"
import PartyRepositroy, { PartyLog } from "../../model/PartyRepositroy"
import LatestInfo from "../../model/LatestInfo"
Expand Down Expand Up @@ -49,7 +49,7 @@ export default class EditModeView extends React.Component<EditModeViewProps, Edi
private editArea: HTMLDivElement | null = null
private partyArea: HTMLDivElement | null = null

constructor(props) {
constructor(props: Readonly<EditModeViewProps>) {
super(props)

Party.ptver = this.props.ptver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ interface EditTutorialAreaState {
visible: boolean
}

// eslint-disable-next-line @typescript-eslint/ban-types
export default class EditTutorialArea extends React.Component<{}, EditTutorialAreaState> {

constructor(props) {
// eslint-disable-next-line @typescript-eslint/ban-types
constructor(props: Readonly<{}>) {
super(props)
Cookie.set({ tutorial: true })
this.state = { visible: true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Browser from "../../lib/BrowserProxy"

interface MemberAreaBodyProps {
party: Party
// eslint-disable-next-line @typescript-eslint/no-explicit-any
heroes: any[]
}

Expand All @@ -26,7 +27,7 @@ interface MemberAreaBodyState {

export default class MemberAreaBody extends React.Component<MemberAreaBodyProps, MemberAreaBodyState> {

constructor(props) {
constructor(props: Readonly<MemberAreaBodyProps>) {
super(props)

this.state = {
Expand Down Expand Up @@ -63,7 +64,7 @@ export default class MemberAreaBody extends React.Component<MemberAreaBodyProps,
)
}

private addDropHandler(div: HTMLLIElement | null, code: string): void {
private addDropHandler(div: HTMLLIElement | HTMLDivElement | null, code: string): void {
if (!div) {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface MemberAreaHeaderState {

export default class MemberAreaHeader extends React.Component<MemberAreaHeaderProps, MemberAreaHeaderState> {

constructor(props) {
constructor(props: Readonly<MemberAreaHeaderProps>) {
super(props)

this.state = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface MemberControlAreaState {

export default class MemberControlArea extends React.Component<MemberControlAreaProps, MemberControlAreaState> {

constructor(props) {
constructor(props: Readonly<MemberControlAreaProps>) {
super(props)

this.state = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as _ from "lodash"
import * as React from "react"

import Member from "../../model/Member"
Expand All @@ -9,13 +8,14 @@ export interface MemberRendererProps {
member: Member | null
}

// eslint-disable-next-line @typescript-eslint/ban-types
export abstract class MemberRenderer<T extends MemberRendererProps> extends ArcanaRenderer<T, {}> {

public shouldComponentUpdate(nextProps: T): boolean {
return !this.isSameMember(this.props.member, nextProps.member)
}

protected isSameMember(bm: Member | null, nm: Member | null) {
protected isSameMember(bm: Member | null, nm: Member | null): boolean {
if (bm == null && nm == null) {
return true
}
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/bundles/ccpts/components/edit/TargetArcana.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface TargetArcanaState {

export default class TargetArcana extends ArcanaRenderer<TargetArcanaProps, TargetArcanaState> {

constructor(props) {
constructor(props: Readonly<TargetArcanaProps>) {
super(props)

const code = this.props.arcana.jobCode
Expand All @@ -37,7 +37,7 @@ export default class TargetArcana extends ArcanaRenderer<TargetArcanaProps, Targ
})
}

public shouldComponentUpdate(nextProps): boolean {
public shouldComponentUpdate(nextProps: { arcana: Arcana | null }): boolean {
return !this.isSameArcana(this.props.arcana, nextProps.arcana)
}

Expand Down
21 changes: 12 additions & 9 deletions app/javascript/bundles/ccpts/lib/BrowserProxy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare var window
// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare let window: any

// NOTE: SSRするなら切り離す
import Browser from "../../browser"
Expand Down Expand Up @@ -54,7 +55,7 @@ export default class BrowserProxy {
}
}

public static fadeIn(el): void {
public static fadeIn(el: HTMLDivElement): void {
if (!el) {
return
}
Expand All @@ -63,15 +64,15 @@ export default class BrowserProxy {
el.style.display = ""
}

public static show(el): void {
public static show(el: HTMLDivElement): void {
if (!el) {
return
}
el.classList.remove("hide")
el.style.display = ""
}

public static hide(el): void {
public static hide(el: HTMLDivElement): void {
if (!el) {
return
}
Expand All @@ -80,13 +81,14 @@ export default class BrowserProxy {
el.style.display = ""
}

public static setDraggable(div, code: string, memkey?: string | null): void {
public static setDraggable(div: HTMLDivElement, code: string, memkey?: string | null): void {
if (BrowserProxy.isWindowDefined) {
Browser.setDraggable(div, code, memkey)
}
}

public static addDropHandler(div, code: string, callback): void {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public static addDropHandler(div: HTMLLIElement | HTMLDivElement | null, code: string, callback: (targetKey: string, drag: any) => void): void {
if (BrowserProxy.isWindowDefined) {
Browser.addDropHandler(div, code, callback)
}
Expand All @@ -99,13 +101,14 @@ export default class BrowserProxy {
return ""
}

public static addSwipeHandler(div, callbackLeft, callbackRight): void {
if (BrowserProxy.isWindowDefined && BrowserProxy.isPhoneDevice()) {
public static addSwipeHandler(div: HTMLDivElement | null, callbackLeft: () => void, callbackRight: () => void): void {
if (BrowserProxy.isWindowDefined && BrowserProxy.isPhoneDevice() && div) {
Browser.addSwipeHandler(div, callbackLeft, callbackRight)
}
}

public static addSwitchHandler(div, state: boolean, callback, params): void {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
public static addSwitchHandler(div: HTMLDivElement, state: boolean, callback, params): void {
if (BrowserProxy.isWindowDefined) {
Browser.addSwitchHandler(div, state, callback, params)
}
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/bundles/ccpts/lib/Cookie.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
import CookieBase from "./CookieBase"

export default class Cookie {
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/bundles/ccpts/lib/CookieBase.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as _ from "lodash"
import * as Cookies from "js-cookie"

Expand Down
Loading

0 comments on commit 749ce55

Please sign in to comment.