From 824a206ee461e79f8a048e83abccae3d512bbf72 Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Fri, 15 Nov 2019 10:50:46 +0100 Subject: [PATCH] Updated project linter rules and ran it --- web/.eslintrc.js | 1 - web/src/config/client/inject.js | 4 +- web/src/config/state.js | 22 +++++----- web/src/screens/feed/index.js | 40 ++++++++++--------- web/src/screens/layout.js | 6 +-- web/src/screens/redirect.js | 2 +- .../repo/screens/build/components/elapsed.js | 16 ++++---- web/src/screens/repo/screens/build/index.js | 22 +++++----- .../screens/repo/screens/build/logs/index.js | 6 +-- web/src/screens/repo/screens/build/menu.js | 4 +- web/src/screens/repo/screens/builds/header.js | 2 +- web/src/screens/repo/screens/builds/index.js | 4 +- web/src/screens/repo/screens/builds/menu.js | 2 +- .../repo/screens/registry/components/form.js | 4 +- .../screens/repo/screens/registry/index.js | 6 +-- .../repo/screens/secrets/components/form.js | 6 +-- web/src/screens/repo/screens/secrets/index.js | 6 +-- .../screens/repo/screens/settings/index.js | 6 +-- web/src/screens/user/screens/repos/index.js | 6 +-- web/src/screens/user/screens/repos/menu.js | 2 +- web/src/screens/user/screens/tokens/index.js | 6 +-- .../components/__tests__/status.test.js | 6 +-- web/src/shared/components/avatar.js | 2 +- web/src/shared/components/build_event.js | 20 +++++----- web/src/shared/components/icons/index.js | 2 +- web/src/shared/components/status.js | 4 +- web/src/shared/constants/status.js | 2 +- web/src/shared/utils/logs.js | 2 +- 28 files changed, 109 insertions(+), 102 deletions(-) diff --git a/web/.eslintrc.js b/web/.eslintrc.js index ce8de9dfd..235507f91 100644 --- a/web/.eslintrc.js +++ b/web/.eslintrc.js @@ -27,7 +27,6 @@ module.exports = { "error", { trailingComma: "all", - useTabs: true } ] } diff --git a/web/src/config/client/inject.js b/web/src/config/client/inject.js index 23d987fbb..e5f3f9513 100644 --- a/web/src/config/client/inject.js +++ b/web/src/config/client/inject.js @@ -6,7 +6,7 @@ export const drone = (client, Component) => { const component = class extends React.Component { getChildContext() { return { - drone: client + drone: client, }; } @@ -16,7 +16,7 @@ export const drone = (client, Component) => { }; component.childContextTypes = { - drone: (props, propName) => {} + drone: (props, propName) => {}, }; return component; diff --git a/web/src/config/state.js b/web/src/config/state.js index 1ac8d9b16..bf5a8dfed 100644 --- a/web/src/config/state.js +++ b/web/src/config/state.js @@ -11,62 +11,62 @@ const state = { data: user, error: undefined, loaded: true, - syncing: sync + syncing: sync, }, feed: { loaded: false, error: undefined, - data: {} + data: {}, }, repos: { loaded: false, error: undefined, - data: {} + data: {}, }, secrets: { loaded: false, error: undefined, - data: {} + data: {}, }, registry: { error: undefined, loaded: false, - data: {} + data: {}, }, builds: { loaded: false, error: undefined, - data: {} + data: {}, }, logs: { follow: false, loading: true, error: false, - data: {} + data: {}, }, token: { value: undefined, error: undefined, - loading: false + loading: false, }, message: { show: false, text: undefined, - error: false + error: false, }, location: { protocol: window.location.protocol, - host: window.location.host - } + host: window.location.host, + }, }; const tree = new Baobab(state); diff --git a/web/src/screens/feed/index.js b/web/src/screens/feed/index.js index 43455bc50..7d6b54f57 100644 --- a/web/src/screens/feed/index.js +++ b/web/src/screens/feed/index.js @@ -26,7 +26,7 @@ export default class Sidebar extends Component { this.setState({ starred: JSON.parse(localStorage.getItem("starred") || "[]"), starredOpen: (localStorage.getItem("starredOpen") || "true") === "true", - reposOpen: (localStorage.getItem("reposOpen") || "true") === "true" + reposOpen: (localStorage.getItem("reposOpen") || "true") === "true", }); this.handleFilter = this.handleFilter.bind(this); @@ -44,7 +44,7 @@ export default class Sidebar extends Component { handleFilter(e) { this.setState({ - filter: e.target.value + filter: e.target.value, }); } @@ -122,13 +122,15 @@ export default class Sidebar extends Component { triggerOpenedClassName={style.Collapsible__trigger} triggerClassName={style.Collapsible__trigger} > - {feed.loaded === false - ? LOADING - : feed.error - ? ERROR - : list.length === 0 - ? EMPTY - : this.renderFeed(list, true)} + {feed.loaded === false ? ( + LOADING + ) : feed.error ? ( + ERROR + ) : list.length === 0 ? ( + EMPTY + ) : ( + this.renderFeed(list, true) + )} - {feed.loaded === false - ? LOADING - : feed.error - ? ERROR - : list.length === 0 - ? EMPTY - : filtered.length > 0 - ? this.renderFeed(filtered.sort(compareFeedItem), false) - : NO_MATCHES} + {feed.loaded === false ? ( + LOADING + ) : feed.error ? ( + ERROR + ) : list.length === 0 ? ( + EMPTY + ) : filtered.length > 0 ? ( + this.renderFeed(filtered.sort(compareFeedItem), false) + ) : ( + NO_MATCHES + )} ); diff --git a/web/src/screens/layout.js b/web/src/screens/layout.js index e3fec6e28..785792ef0 100644 --- a/web/src/screens/layout.js +++ b/web/src/screens/layout.js @@ -34,7 +34,7 @@ const binding = (props, context) => { user: ["user"], message: ["message"], sidebar: ["sidebar"], - menu: ["menu"] + menu: ["menu"], }; }; @@ -42,7 +42,7 @@ const mapScreenSizeToProps = screenSize => { return { isTablet: screenSize["small"], isMobile: screenSize["mobile"], - isDesktop: screenSize["> small"] + isDesktop: screenSize["> small"], }; }; @@ -54,7 +54,7 @@ export default class Default extends Component { super(props, context); this.state = { menu: false, - feed: false + feed: false, }; this.openMenu = this.openMenu.bind(this); diff --git a/web/src/screens/redirect.js b/web/src/screens/redirect.js index 5101ef785..1b36f7d38 100644 --- a/web/src/screens/redirect.js +++ b/web/src/screens/redirect.js @@ -7,7 +7,7 @@ const binding = (props, context) => { return { feed: ["feed"], user: ["user", "data"], - syncing: ["user", "syncing"] + syncing: ["user", "syncing"], }; }; diff --git a/web/src/screens/repo/screens/build/components/elapsed.js b/web/src/screens/repo/screens/build/components/elapsed.js index f08275a24..e3b7ec18c 100644 --- a/web/src/screens/repo/screens/build/components/elapsed.js +++ b/web/src/screens/repo/screens/build/components/elapsed.js @@ -5,7 +5,7 @@ export class Elapsed extends Component { super(props); this.state = { - elapsed: 0 + elapsed: 0, }; this.tick = this.tick.bind(this); @@ -23,7 +23,7 @@ export class Elapsed extends Component { const { start } = this.props; const stop = ~~(Date.now() / 1000); this.setState({ - elapsed: stop - start + elapsed: stop - start, }); } @@ -33,11 +33,13 @@ export class Elapsed extends Component { date.setSeconds(elapsed); return ( ); } diff --git a/web/src/screens/repo/screens/build/index.js b/web/src/screens/repo/screens/build/index.js index 35062a3b4..c63c96a03 100644 --- a/web/src/screens/repo/screens/build/index.js +++ b/web/src/screens/repo/screens/build/index.js @@ -5,7 +5,7 @@ import { fetchBuild, approveBuild, declineBuild } from "shared/utils/build"; import { STATUS_BLOCKED, STATUS_DECLINED, - STATUS_ERROR + STATUS_ERROR, } from "shared/constants/status"; import { findChildProcess } from "shared/utils/proc"; @@ -29,7 +29,7 @@ const binding = (props, context) => { return { repo: ["repos", "data", slug], - build: ["builds", "data", slug, number] + build: ["builds", "data", slug, number], }; }; @@ -54,7 +54,7 @@ export default class BuildLogs extends Component { drone, repo.owner, repo.name, - build.number + build.number, ); } @@ -65,7 +65,7 @@ export default class BuildLogs extends Component { drone, repo.owner, repo.name, - build.number + build.number, ); } @@ -81,7 +81,7 @@ export default class BuildLogs extends Component { fetchRepository, props.drone, props.match.params.owner, - props.match.params.repo + props.match.params.repo, ); } if (!props.build || !props.build.procs) { @@ -90,7 +90,7 @@ export default class BuildLogs extends Component { props.drone, props.match.params.owner, props.match.params.repo, - props.match.params.build + props.match.params.build, ); } } @@ -160,9 +160,11 @@ export default class BuildLogs extends Component {
- {build.status === STATUS_ERROR - ? build.error - : "Pipeline execution was declined"} + {build.status === STATUS_ERROR ? ( + build.error + ) : ( + "Pipeline execution was declined" + )}
@@ -247,7 +249,7 @@ export class BuildLogsTitle extends Component { key={`${owner}-${repo}-${build}`} > {build} - + , ]} /> ); diff --git a/web/src/screens/repo/screens/build/logs/index.js b/web/src/screens/repo/screens/build/logs/index.js index ce2dd186d..384ab3af2 100644 --- a/web/src/screens/repo/screens/build/logs/index.js +++ b/web/src/screens/repo/screens/build/logs/index.js @@ -24,7 +24,7 @@ const binding = (props, context) => { eof: ["logs", "data", slug, number, pid, "eof"], loading: ["logs", "data", slug, number, pid, "loading"], error: ["logs", "data", slug, number, pid, "error"], - follow: ["logs", "follow"] + follow: ["logs", "follow"], }; }; @@ -57,7 +57,7 @@ export default class Output extends Component { nextProps.match.params.owner, nextProps.match.params.repo, nextProps.build.number, - nextProps.proc.pid + nextProps.proc.pid, ); } @@ -68,7 +68,7 @@ export default class Output extends Component { nextProps.match.params.owner, nextProps.match.params.repo, nextProps.build.number, - nextProps.proc + nextProps.proc, ); } } diff --git a/web/src/screens/repo/screens/build/menu.js b/web/src/screens/repo/screens/build/menu.js index 6b7e8e6d6..51780d055 100644 --- a/web/src/screens/repo/screens/build/menu.js +++ b/web/src/screens/repo/screens/build/menu.js @@ -15,7 +15,7 @@ const binding = (props, context) => { const number = parseInt(build); return { repo: ["repos", "data", slug], - build: ["builds", "data", slug, number] + build: ["builds", "data", slug, number], }; }; @@ -44,7 +44,7 @@ export default class BuildMenu extends Component { repo.owner, repo.name, build.number, - proc.ppid + proc.ppid, ); } diff --git a/web/src/screens/repo/screens/builds/header.js b/web/src/screens/repo/screens/builds/header.js index cd53eb3e3..e82650c6f 100644 --- a/web/src/screens/repo/screens/builds/header.js +++ b/web/src/screens/repo/screens/builds/header.js @@ -11,7 +11,7 @@ export default class Header extends Component { elements={[ {owner} / {repo} - + , ]} /> diff --git a/web/src/screens/repo/screens/builds/index.js b/web/src/screens/repo/screens/builds/index.js index 9607c086d..a6ebb867d 100644 --- a/web/src/screens/repo/screens/builds/index.js +++ b/web/src/screens/repo/screens/builds/index.js @@ -17,7 +17,7 @@ const binding = (props, context) => { repo: ["repos", "data", slug], builds: ["builds", "data", slug], loaded: ["builds", "loaded"], - error: ["builds", "error"] + error: ["builds", "error"], }; }; @@ -75,7 +75,7 @@ export default class Main extends Component { drone, match.params.owner, match.params.repo, - page + page, ); } diff --git a/web/src/screens/repo/screens/builds/menu.js b/web/src/screens/repo/screens/builds/menu.js index 898ca58f5..71788860d 100644 --- a/web/src/screens/repo/screens/builds/menu.js +++ b/web/src/screens/repo/screens/builds/menu.js @@ -8,7 +8,7 @@ export default class RepoMenu extends Component { { to: `/${owner}/${repo}`, label: "Builds" }, { to: `/${owner}/${repo}/settings/secrets`, label: "Secrets" }, { to: `/${owner}/${repo}/settings/registry`, label: "Registry" }, - { to: `/${owner}/${repo}/settings`, label: "Settings" } + { to: `/${owner}/${repo}/settings`, label: "Settings" }, ]; return ; } diff --git a/web/src/screens/repo/screens/registry/components/form.js b/web/src/screens/repo/screens/registry/components/form.js index ea6bfba7e..b9e71592f 100644 --- a/web/src/screens/repo/screens/registry/components/form.js +++ b/web/src/screens/repo/screens/registry/components/form.js @@ -8,7 +8,7 @@ export class Form extends Component { this.state = { address: "", username: "", - password: "" + password: "", }; this._handleAddressChange = this._handleAddressChange.bind(this); @@ -37,7 +37,7 @@ export class Form extends Component { const detail = { address: this.state.address, username: this.state.username, - password: this.state.password + password: this.state.password, }; onsubmit({ detail }); diff --git a/web/src/screens/repo/screens/registry/index.js b/web/src/screens/repo/screens/registry/index.js index 7b74e386e..fe6fbd0e0 100644 --- a/web/src/screens/repo/screens/registry/index.js +++ b/web/src/screens/repo/screens/registry/index.js @@ -4,7 +4,7 @@ import { repositorySlug } from "shared/utils/repository"; import { fetchRegistryList, createRegistry, - deleteRegistry + deleteRegistry, } from "shared/utils/registry"; import { branch } from "baobab-react/higher-order"; @@ -19,7 +19,7 @@ const binding = (props, context) => { const slug = repositorySlug(owner, repo); return { loaded: ["registry", "loaded"], - registries: ["registry", "data", slug] + registries: ["registry", "data", slug], }; }; @@ -49,7 +49,7 @@ export default class RepoRegistry extends Component { const registry = { address: e.detail.address, username: e.detail.username, - password: e.detail.password + password: e.detail.password, }; dispatch(createRegistry, drone, owner, repo, registry); diff --git a/web/src/screens/repo/screens/secrets/components/form.js b/web/src/screens/repo/screens/secrets/components/form.js index 0e1b3d75e..183e7520d 100644 --- a/web/src/screens/repo/screens/secrets/components/form.js +++ b/web/src/screens/repo/screens/secrets/components/form.js @@ -4,7 +4,7 @@ import { EVENT_PUSH, EVENT_TAG, EVENT_PULL_REQUEST, - EVENT_DEPLOY + EVENT_DEPLOY, } from "shared/constants/events"; import styles from "./form.less"; @@ -16,7 +16,7 @@ export class Form extends Component { this.state = { name: "", value: "", - event: [EVENT_PUSH, EVENT_TAG, EVENT_DEPLOY] + event: [EVENT_PUSH, EVENT_TAG, EVENT_DEPLOY], }; this._handleNameChange = this._handleNameChange.bind(this); @@ -55,7 +55,7 @@ export class Form extends Component { const detail = { name: this.state.name, value: this.state.value, - event: this.state.event + event: this.state.event, }; onsubmit({ detail }); diff --git a/web/src/screens/repo/screens/secrets/index.js b/web/src/screens/repo/screens/secrets/index.js index 0bbafb66b..c07dddac1 100644 --- a/web/src/screens/repo/screens/secrets/index.js +++ b/web/src/screens/repo/screens/secrets/index.js @@ -4,7 +4,7 @@ import { repositorySlug } from "shared/utils/repository"; import { fetchSecretList, createSecret, - deleteSecret + deleteSecret, } from "shared/utils/secrets"; import { branch } from "baobab-react/higher-order"; @@ -19,7 +19,7 @@ const binding = (props, context) => { const slug = repositorySlug(owner, repo); return { loaded: ["secrets", "loaded"], - secrets: ["secrets", "data", slug] + secrets: ["secrets", "data", slug], }; }; @@ -47,7 +47,7 @@ export default class RepoSecrets extends Component { const secret = { name: e.detail.name, value: e.detail.value, - event: e.detail.event + event: e.detail.event, }; dispatch(createSecret, drone, owner, repo, secret); diff --git a/web/src/screens/repo/screens/settings/index.js b/web/src/screens/repo/screens/settings/index.js index 8600a90d0..a7acc8a16 100644 --- a/web/src/screens/repo/screens/settings/index.js +++ b/web/src/screens/repo/screens/settings/index.js @@ -6,13 +6,13 @@ import { inject } from "config/client/inject"; import { fetchRepository, updateRepository, - repositorySlug + repositorySlug, } from "shared/utils/repository"; import { VISIBILITY_PUBLIC, VISIBILITY_PRIVATE, - VISIBILITY_INTERNAL + VISIBILITY_INTERNAL, } from "shared/constants/visibility"; import styles from "./index.less"; @@ -22,7 +22,7 @@ const binding = (props, context) => { const slug = repositorySlug(owner, repo); return { user: ["user", "data"], - repo: ["repos", "data", slug] + repo: ["repos", "data", slug], }; }; diff --git a/web/src/screens/user/screens/repos/index.js b/web/src/screens/user/screens/repos/index.js index 3144fe862..18876cddd 100644 --- a/web/src/screens/user/screens/repos/index.js +++ b/web/src/screens/user/screens/repos/index.js @@ -6,7 +6,7 @@ import { inject } from "config/client/inject"; import { fetchRepostoryList, disableRepository, - enableRepository + enableRepository, } from "shared/utils/repository"; import { List, Item } from "./components"; @@ -18,7 +18,7 @@ const binding = (props, context) => { return { repos: ["repos", "data"], loaded: ["repos", "loaded"], - error: ["repos", "error"] + error: ["repos", "error"], }; }; @@ -35,7 +35,7 @@ export default class UserRepos extends Component { handleFilter(e) { this.setState({ - search: e.target.value + search: e.target.value, }); } diff --git a/web/src/screens/user/screens/repos/menu.js b/web/src/screens/user/screens/repos/menu.js index 53a48a945..28a467d12 100644 --- a/web/src/screens/user/screens/repos/menu.js +++ b/web/src/screens/user/screens/repos/menu.js @@ -7,7 +7,7 @@ import Menu from "shared/components/menu"; const binding = (props, context) => { return { - repos: ["repos"] + repos: ["repos"], }; }; diff --git a/web/src/screens/user/screens/tokens/index.js b/web/src/screens/user/screens/tokens/index.js index f1977bec5..c6b3e12b3 100644 --- a/web/src/screens/user/screens/tokens/index.js +++ b/web/src/screens/user/screens/tokens/index.js @@ -8,7 +8,7 @@ import styles from "./index.less"; const binding = (props, context) => { return { location: ["location"], - token: ["token"] + token: ["token"], }; }; @@ -48,9 +48,7 @@ export default class Tokens extends Component { } const usageWithCURL = (location, token) => { - return `curl -i ${location.protocol}//${ - location.host - }/api/user -H "Authorization: Bearer ${token}"`; + return `curl -i ${location.protocol}//${location.host}/api/user -H "Authorization: Bearer ${token}"`; }; const usageWithCLI = (location, token) => { diff --git a/web/src/shared/components/__tests__/status.test.js b/web/src/shared/components/__tests__/status.test.js index d7e73cd49..10285ee70 100644 --- a/web/src/shared/components/__tests__/status.test.js +++ b/web/src/shared/components/__tests__/status.test.js @@ -5,7 +5,7 @@ import Status from "../status"; import { STATUS_FAILURE, STATUS_RUNNING, - STATUS_SUCCESS + STATUS_SUCCESS, } from "shared/constants/status"; jest.dontMock("../status"); @@ -16,10 +16,10 @@ describe("Status component", () => { const instance = status.instance(); expect( - instance.shouldComponentUpdate({ status: STATUS_FAILURE }) + instance.shouldComponentUpdate({ status: STATUS_FAILURE }), ).toBeFalsy(); expect( - instance.shouldComponentUpdate({ status: STATUS_SUCCESS }) + instance.shouldComponentUpdate({ status: STATUS_SUCCESS }), ).toBeTruthy(); expect(status.hasClass("failure")).toBeTruthy(); }); diff --git a/web/src/shared/components/avatar.js b/web/src/shared/components/avatar.js index ba09306e3..4d38e2461 100644 --- a/web/src/shared/components/avatar.js +++ b/web/src/shared/components/avatar.js @@ -5,7 +5,7 @@ export default class Avatar extends Component { render() { const image = this.props.image; const style = { - backgroundImage: `url(${image})` + backgroundImage: `url(${image})`, }; return
; } diff --git a/web/src/shared/components/build_event.js b/web/src/shared/components/build_event.js index e77e079a2..0d62e0938 100644 --- a/web/src/shared/components/build_event.js +++ b/web/src/shared/components/build_event.js @@ -5,12 +5,12 @@ import { DeployIcon, LaunchIcon, MergeIcon, - TagIcon + TagIcon, } from "shared/components/icons/index"; import { EVENT_TAG, EVENT_PULL_REQUEST, - EVENT_DEPLOY + EVENT_DEPLOY, } from "shared/constants/events"; import styles from "./build_event.less"; @@ -40,13 +40,15 @@ export default class BuildEvent extends Component { )}
- {event === EVENT_TAG && refs - ? trimTagRef(refs) - : event === EVENT_PULL_REQUEST && refspec - ? trimMergeRef(refs) - : event === EVENT_DEPLOY && target - ? target - : branch} + {event === EVENT_TAG && refs ? ( + trimTagRef(refs) + ) : event === EVENT_PULL_REQUEST && refspec ? ( + trimMergeRef(refs) + ) : event === EVENT_DEPLOY && target ? ( + target + ) : ( + branch + )}
diff --git a/web/src/shared/components/icons/index.js b/web/src/shared/components/icons/index.js index 0597a707d..52574d93a 100644 --- a/web/src/shared/components/icons/index.js +++ b/web/src/shared/components/icons/index.js @@ -41,5 +41,5 @@ export { StarIcon, SyncIcon, TagIcon, - TimelapseIcon + TimelapseIcon, }; diff --git a/web/src/shared/components/status.js b/web/src/shared/components/status.js index 39e53ca30..15d93f960 100644 --- a/web/src/shared/components/status.js +++ b/web/src/shared/components/status.js @@ -10,7 +10,7 @@ import { STATUS_RUNNING, STATUS_SKIPPED, STATUS_STARTED, - STATUS_SUCCESS + STATUS_SUCCESS, } from "shared/constants/status"; import style from "./status.less"; @@ -19,7 +19,7 @@ import { CloseIcon, ClockIcon, RefreshIcon, - RemoveIcon + RemoveIcon, } from "./icons/index"; const defaultIconSize = 15; diff --git a/web/src/shared/constants/status.js b/web/src/shared/constants/status.js index 0f86e2dda..75ffff4df 100644 --- a/web/src/shared/constants/status.js +++ b/web/src/shared/constants/status.js @@ -19,5 +19,5 @@ export { STATUS_RUNNING, STATUS_SKIPPED, STATUS_SUCCESS, - STATUS_STARTED + STATUS_STARTED, }; diff --git a/web/src/shared/utils/logs.js b/web/src/shared/utils/logs.js index 5d33bca3b..290f80ae1 100644 --- a/web/src/shared/utils/logs.js +++ b/web/src/shared/utils/logs.js @@ -20,7 +20,7 @@ export function fetchLogs(tree, client, owner, repo, build, proc) { const slug = repositorySlug(owner, repo); const init = { data: [], - loading: true + loading: true, }; tree.set(["logs", "data", slug, build, proc], init);