Updated project linter rules and ran it

This commit is contained in:
Laszlo Fogas 2019-11-15 10:50:46 +01:00
parent 12279686e8
commit 824a206ee4
28 changed files with 109 additions and 102 deletions

View file

@ -27,7 +27,6 @@ module.exports = {
"error",
{
trailingComma: "all",
useTabs: true
}
]
}

View file

@ -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;

View file

@ -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);

View file

@ -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)
)}
</Collapsible>
<Collapsible
trigger="Repos"
@ -145,15 +147,17 @@ export default class Sidebar extends Component {
placeholder="Search …"
onChange={this.handleFilter}
/>
{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
)}
</Collapsible>
</div>
);

View file

@ -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);

View file

@ -7,7 +7,7 @@ const binding = (props, context) => {
return {
feed: ["feed"],
user: ["user", "data"],
syncing: ["user", "syncing"]
syncing: ["user", "syncing"],
};
};

View file

@ -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 (
<time>
{!elapsed
? undefined
: elapsed > 3600
? date.toISOString().substr(11, 8)
: date.toISOString().substr(14, 5)}
{!elapsed ? (
undefined
) : elapsed > 3600 ? (
date.toISOString().substr(11, 8)
) : (
date.toISOString().substr(14, 5)
)}
</time>
);
}

View file

@ -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 {
</div>
<div className={styles.left}>
<div className={styles.logerror}>
{build.status === STATUS_ERROR
? build.error
: "Pipeline execution was declined"}
{build.status === STATUS_ERROR ? (
build.error
) : (
"Pipeline execution was declined"
)}
</div>
</div>
</div>
@ -247,7 +249,7 @@ export class BuildLogsTitle extends Component {
key={`${owner}-${repo}-${build}`}
>
{build}
</Link>
</Link>,
]}
/>
);

View file

@ -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,
);
}
}

View file

@ -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,
);
}

View file

@ -11,7 +11,7 @@ export default class Header extends Component {
elements={[
<Link to={`/${owner}/${repo}`} key={`${owner}-${repo}`}>
{owner} / {repo}
</Link>
</Link>,
]}
/>
</div>

View file

@ -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,
);
}

View file

@ -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 <Menu items={menu} {...this.props} />;
}

View file

@ -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 });

View file

@ -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);

View file

@ -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 });

View file

@ -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);

View file

@ -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],
};
};

View file

@ -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,
});
}

View file

@ -7,7 +7,7 @@ import Menu from "shared/components/menu";
const binding = (props, context) => {
return {
repos: ["repos"]
repos: ["repos"],
};
};

View file

@ -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) => {

View file

@ -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();
});

View file

@ -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 <div className={styles.avatar} style={style} />;
}

View file

@ -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 {
)}
</div>
<div>
{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
)}
</div>
</div>
<a href={link} target="_blank">

View file

@ -41,5 +41,5 @@ export {
StarIcon,
SyncIcon,
TagIcon,
TimelapseIcon
TimelapseIcon,
};

View file

@ -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;

View file

@ -19,5 +19,5 @@ export {
STATUS_RUNNING,
STATUS_SKIPPED,
STATUS_SUCCESS,
STATUS_STARTED
STATUS_STARTED,
};

View file

@ -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);