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", "error",
{ {
trailingComma: "all", trailingComma: "all",
useTabs: true
} }
] ]
} }

View file

@ -6,7 +6,7 @@ export const drone = (client, Component) => {
const component = class extends React.Component { const component = class extends React.Component {
getChildContext() { getChildContext() {
return { return {
drone: client drone: client,
}; };
} }
@ -16,7 +16,7 @@ export const drone = (client, Component) => {
}; };
component.childContextTypes = { component.childContextTypes = {
drone: (props, propName) => {} drone: (props, propName) => {},
}; };
return component; return component;

View file

@ -11,62 +11,62 @@ const state = {
data: user, data: user,
error: undefined, error: undefined,
loaded: true, loaded: true,
syncing: sync syncing: sync,
}, },
feed: { feed: {
loaded: false, loaded: false,
error: undefined, error: undefined,
data: {} data: {},
}, },
repos: { repos: {
loaded: false, loaded: false,
error: undefined, error: undefined,
data: {} data: {},
}, },
secrets: { secrets: {
loaded: false, loaded: false,
error: undefined, error: undefined,
data: {} data: {},
}, },
registry: { registry: {
error: undefined, error: undefined,
loaded: false, loaded: false,
data: {} data: {},
}, },
builds: { builds: {
loaded: false, loaded: false,
error: undefined, error: undefined,
data: {} data: {},
}, },
logs: { logs: {
follow: false, follow: false,
loading: true, loading: true,
error: false, error: false,
data: {} data: {},
}, },
token: { token: {
value: undefined, value: undefined,
error: undefined, error: undefined,
loading: false loading: false,
}, },
message: { message: {
show: false, show: false,
text: undefined, text: undefined,
error: false error: false,
}, },
location: { location: {
protocol: window.location.protocol, protocol: window.location.protocol,
host: window.location.host host: window.location.host,
} },
}; };
const tree = new Baobab(state); const tree = new Baobab(state);

View file

@ -26,7 +26,7 @@ export default class Sidebar extends Component {
this.setState({ this.setState({
starred: JSON.parse(localStorage.getItem("starred") || "[]"), starred: JSON.parse(localStorage.getItem("starred") || "[]"),
starredOpen: (localStorage.getItem("starredOpen") || "true") === "true", starredOpen: (localStorage.getItem("starredOpen") || "true") === "true",
reposOpen: (localStorage.getItem("reposOpen") || "true") === "true" reposOpen: (localStorage.getItem("reposOpen") || "true") === "true",
}); });
this.handleFilter = this.handleFilter.bind(this); this.handleFilter = this.handleFilter.bind(this);
@ -44,7 +44,7 @@ export default class Sidebar extends Component {
handleFilter(e) { handleFilter(e) {
this.setState({ this.setState({
filter: e.target.value filter: e.target.value,
}); });
} }
@ -122,13 +122,15 @@ export default class Sidebar extends Component {
triggerOpenedClassName={style.Collapsible__trigger} triggerOpenedClassName={style.Collapsible__trigger}
triggerClassName={style.Collapsible__trigger} triggerClassName={style.Collapsible__trigger}
> >
{feed.loaded === false {feed.loaded === false ? (
? LOADING LOADING
: feed.error ) : feed.error ? (
? ERROR ERROR
: list.length === 0 ) : list.length === 0 ? (
? EMPTY EMPTY
: this.renderFeed(list, true)} ) : (
this.renderFeed(list, true)
)}
</Collapsible> </Collapsible>
<Collapsible <Collapsible
trigger="Repos" trigger="Repos"
@ -145,15 +147,17 @@ export default class Sidebar extends Component {
placeholder="Search …" placeholder="Search …"
onChange={this.handleFilter} onChange={this.handleFilter}
/> />
{feed.loaded === false {feed.loaded === false ? (
? LOADING LOADING
: feed.error ) : feed.error ? (
? ERROR ERROR
: list.length === 0 ) : list.length === 0 ? (
? EMPTY EMPTY
: filtered.length > 0 ) : filtered.length > 0 ? (
? this.renderFeed(filtered.sort(compareFeedItem), false) this.renderFeed(filtered.sort(compareFeedItem), false)
: NO_MATCHES} ) : (
NO_MATCHES
)}
</Collapsible> </Collapsible>
</div> </div>
); );

View file

@ -34,7 +34,7 @@ const binding = (props, context) => {
user: ["user"], user: ["user"],
message: ["message"], message: ["message"],
sidebar: ["sidebar"], sidebar: ["sidebar"],
menu: ["menu"] menu: ["menu"],
}; };
}; };
@ -42,7 +42,7 @@ const mapScreenSizeToProps = screenSize => {
return { return {
isTablet: screenSize["small"], isTablet: screenSize["small"],
isMobile: screenSize["mobile"], isMobile: screenSize["mobile"],
isDesktop: screenSize["> small"] isDesktop: screenSize["> small"],
}; };
}; };
@ -54,7 +54,7 @@ export default class Default extends Component {
super(props, context); super(props, context);
this.state = { this.state = {
menu: false, menu: false,
feed: false feed: false,
}; };
this.openMenu = this.openMenu.bind(this); this.openMenu = this.openMenu.bind(this);

View file

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

View file

@ -5,7 +5,7 @@ export class Elapsed extends Component {
super(props); super(props);
this.state = { this.state = {
elapsed: 0 elapsed: 0,
}; };
this.tick = this.tick.bind(this); this.tick = this.tick.bind(this);
@ -23,7 +23,7 @@ export class Elapsed extends Component {
const { start } = this.props; const { start } = this.props;
const stop = ~~(Date.now() / 1000); const stop = ~~(Date.now() / 1000);
this.setState({ this.setState({
elapsed: stop - start elapsed: stop - start,
}); });
} }
@ -33,11 +33,13 @@ export class Elapsed extends Component {
date.setSeconds(elapsed); date.setSeconds(elapsed);
return ( return (
<time> <time>
{!elapsed {!elapsed ? (
? undefined undefined
: elapsed > 3600 ) : elapsed > 3600 ? (
? date.toISOString().substr(11, 8) date.toISOString().substr(11, 8)
: date.toISOString().substr(14, 5)} ) : (
date.toISOString().substr(14, 5)
)}
</time> </time>
); );
} }

View file

@ -5,7 +5,7 @@ import { fetchBuild, approveBuild, declineBuild } from "shared/utils/build";
import { import {
STATUS_BLOCKED, STATUS_BLOCKED,
STATUS_DECLINED, STATUS_DECLINED,
STATUS_ERROR STATUS_ERROR,
} from "shared/constants/status"; } from "shared/constants/status";
import { findChildProcess } from "shared/utils/proc"; import { findChildProcess } from "shared/utils/proc";
@ -29,7 +29,7 @@ const binding = (props, context) => {
return { return {
repo: ["repos", "data", slug], 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, drone,
repo.owner, repo.owner,
repo.name, repo.name,
build.number build.number,
); );
} }
@ -65,7 +65,7 @@ export default class BuildLogs extends Component {
drone, drone,
repo.owner, repo.owner,
repo.name, repo.name,
build.number build.number,
); );
} }
@ -81,7 +81,7 @@ export default class BuildLogs extends Component {
fetchRepository, fetchRepository,
props.drone, props.drone,
props.match.params.owner, props.match.params.owner,
props.match.params.repo props.match.params.repo,
); );
} }
if (!props.build || !props.build.procs) { if (!props.build || !props.build.procs) {
@ -90,7 +90,7 @@ export default class BuildLogs extends Component {
props.drone, props.drone,
props.match.params.owner, props.match.params.owner,
props.match.params.repo, props.match.params.repo,
props.match.params.build props.match.params.build,
); );
} }
} }
@ -160,9 +160,11 @@ export default class BuildLogs extends Component {
</div> </div>
<div className={styles.left}> <div className={styles.left}>
<div className={styles.logerror}> <div className={styles.logerror}>
{build.status === STATUS_ERROR {build.status === STATUS_ERROR ? (
? build.error build.error
: "Pipeline execution was declined"} ) : (
"Pipeline execution was declined"
)}
</div> </div>
</div> </div>
</div> </div>
@ -247,7 +249,7 @@ export class BuildLogsTitle extends Component {
key={`${owner}-${repo}-${build}`} key={`${owner}-${repo}-${build}`}
> >
{build} {build}
</Link> </Link>,
]} ]}
/> />
); );

View file

@ -24,7 +24,7 @@ const binding = (props, context) => {
eof: ["logs", "data", slug, number, pid, "eof"], eof: ["logs", "data", slug, number, pid, "eof"],
loading: ["logs", "data", slug, number, pid, "loading"], loading: ["logs", "data", slug, number, pid, "loading"],
error: ["logs", "data", slug, number, pid, "error"], 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.owner,
nextProps.match.params.repo, nextProps.match.params.repo,
nextProps.build.number, 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.owner,
nextProps.match.params.repo, nextProps.match.params.repo,
nextProps.build.number, nextProps.build.number,
nextProps.proc nextProps.proc,
); );
} }
} }

View file

@ -15,7 +15,7 @@ const binding = (props, context) => {
const number = parseInt(build); const number = parseInt(build);
return { return {
repo: ["repos", "data", slug], 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.owner,
repo.name, repo.name,
build.number, build.number,
proc.ppid proc.ppid,
); );
} }

View file

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

View file

@ -17,7 +17,7 @@ const binding = (props, context) => {
repo: ["repos", "data", slug], repo: ["repos", "data", slug],
builds: ["builds", "data", slug], builds: ["builds", "data", slug],
loaded: ["builds", "loaded"], loaded: ["builds", "loaded"],
error: ["builds", "error"] error: ["builds", "error"],
}; };
}; };
@ -75,7 +75,7 @@ export default class Main extends Component {
drone, drone,
match.params.owner, match.params.owner,
match.params.repo, 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}`, label: "Builds" },
{ to: `/${owner}/${repo}/settings/secrets`, label: "Secrets" }, { to: `/${owner}/${repo}/settings/secrets`, label: "Secrets" },
{ to: `/${owner}/${repo}/settings/registry`, label: "Registry" }, { 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} />; return <Menu items={menu} {...this.props} />;
} }

View file

@ -8,7 +8,7 @@ export class Form extends Component {
this.state = { this.state = {
address: "", address: "",
username: "", username: "",
password: "" password: "",
}; };
this._handleAddressChange = this._handleAddressChange.bind(this); this._handleAddressChange = this._handleAddressChange.bind(this);
@ -37,7 +37,7 @@ export class Form extends Component {
const detail = { const detail = {
address: this.state.address, address: this.state.address,
username: this.state.username, username: this.state.username,
password: this.state.password password: this.state.password,
}; };
onsubmit({ detail }); onsubmit({ detail });

View file

@ -4,7 +4,7 @@ import { repositorySlug } from "shared/utils/repository";
import { import {
fetchRegistryList, fetchRegistryList,
createRegistry, createRegistry,
deleteRegistry deleteRegistry,
} from "shared/utils/registry"; } from "shared/utils/registry";
import { branch } from "baobab-react/higher-order"; import { branch } from "baobab-react/higher-order";
@ -19,7 +19,7 @@ const binding = (props, context) => {
const slug = repositorySlug(owner, repo); const slug = repositorySlug(owner, repo);
return { return {
loaded: ["registry", "loaded"], loaded: ["registry", "loaded"],
registries: ["registry", "data", slug] registries: ["registry", "data", slug],
}; };
}; };
@ -49,7 +49,7 @@ export default class RepoRegistry extends Component {
const registry = { const registry = {
address: e.detail.address, address: e.detail.address,
username: e.detail.username, username: e.detail.username,
password: e.detail.password password: e.detail.password,
}; };
dispatch(createRegistry, drone, owner, repo, registry); dispatch(createRegistry, drone, owner, repo, registry);

View file

@ -4,7 +4,7 @@ import {
EVENT_PUSH, EVENT_PUSH,
EVENT_TAG, EVENT_TAG,
EVENT_PULL_REQUEST, EVENT_PULL_REQUEST,
EVENT_DEPLOY EVENT_DEPLOY,
} from "shared/constants/events"; } from "shared/constants/events";
import styles from "./form.less"; import styles from "./form.less";
@ -16,7 +16,7 @@ export class Form extends Component {
this.state = { this.state = {
name: "", name: "",
value: "", value: "",
event: [EVENT_PUSH, EVENT_TAG, EVENT_DEPLOY] event: [EVENT_PUSH, EVENT_TAG, EVENT_DEPLOY],
}; };
this._handleNameChange = this._handleNameChange.bind(this); this._handleNameChange = this._handleNameChange.bind(this);
@ -55,7 +55,7 @@ export class Form extends Component {
const detail = { const detail = {
name: this.state.name, name: this.state.name,
value: this.state.value, value: this.state.value,
event: this.state.event event: this.state.event,
}; };
onsubmit({ detail }); onsubmit({ detail });

View file

@ -4,7 +4,7 @@ import { repositorySlug } from "shared/utils/repository";
import { import {
fetchSecretList, fetchSecretList,
createSecret, createSecret,
deleteSecret deleteSecret,
} from "shared/utils/secrets"; } from "shared/utils/secrets";
import { branch } from "baobab-react/higher-order"; import { branch } from "baobab-react/higher-order";
@ -19,7 +19,7 @@ const binding = (props, context) => {
const slug = repositorySlug(owner, repo); const slug = repositorySlug(owner, repo);
return { return {
loaded: ["secrets", "loaded"], loaded: ["secrets", "loaded"],
secrets: ["secrets", "data", slug] secrets: ["secrets", "data", slug],
}; };
}; };
@ -47,7 +47,7 @@ export default class RepoSecrets extends Component {
const secret = { const secret = {
name: e.detail.name, name: e.detail.name,
value: e.detail.value, value: e.detail.value,
event: e.detail.event event: e.detail.event,
}; };
dispatch(createSecret, drone, owner, repo, secret); dispatch(createSecret, drone, owner, repo, secret);

View file

@ -6,13 +6,13 @@ import { inject } from "config/client/inject";
import { import {
fetchRepository, fetchRepository,
updateRepository, updateRepository,
repositorySlug repositorySlug,
} from "shared/utils/repository"; } from "shared/utils/repository";
import { import {
VISIBILITY_PUBLIC, VISIBILITY_PUBLIC,
VISIBILITY_PRIVATE, VISIBILITY_PRIVATE,
VISIBILITY_INTERNAL VISIBILITY_INTERNAL,
} from "shared/constants/visibility"; } from "shared/constants/visibility";
import styles from "./index.less"; import styles from "./index.less";
@ -22,7 +22,7 @@ const binding = (props, context) => {
const slug = repositorySlug(owner, repo); const slug = repositorySlug(owner, repo);
return { return {
user: ["user", "data"], user: ["user", "data"],
repo: ["repos", "data", slug] repo: ["repos", "data", slug],
}; };
}; };

View file

@ -6,7 +6,7 @@ import { inject } from "config/client/inject";
import { import {
fetchRepostoryList, fetchRepostoryList,
disableRepository, disableRepository,
enableRepository enableRepository,
} from "shared/utils/repository"; } from "shared/utils/repository";
import { List, Item } from "./components"; import { List, Item } from "./components";
@ -18,7 +18,7 @@ const binding = (props, context) => {
return { return {
repos: ["repos", "data"], repos: ["repos", "data"],
loaded: ["repos", "loaded"], loaded: ["repos", "loaded"],
error: ["repos", "error"] error: ["repos", "error"],
}; };
}; };
@ -35,7 +35,7 @@ export default class UserRepos extends Component {
handleFilter(e) { handleFilter(e) {
this.setState({ 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) => { const binding = (props, context) => {
return { return {
repos: ["repos"] repos: ["repos"],
}; };
}; };

View file

@ -8,7 +8,7 @@ import styles from "./index.less";
const binding = (props, context) => { const binding = (props, context) => {
return { return {
location: ["location"], location: ["location"],
token: ["token"] token: ["token"],
}; };
}; };
@ -48,9 +48,7 @@ export default class Tokens extends Component {
} }
const usageWithCURL = (location, token) => { const usageWithCURL = (location, token) => {
return `curl -i ${location.protocol}//${ return `curl -i ${location.protocol}//${location.host}/api/user -H "Authorization: Bearer ${token}"`;
location.host
}/api/user -H "Authorization: Bearer ${token}"`;
}; };
const usageWithCLI = (location, token) => { const usageWithCLI = (location, token) => {

View file

@ -5,7 +5,7 @@ import Status from "../status";
import { import {
STATUS_FAILURE, STATUS_FAILURE,
STATUS_RUNNING, STATUS_RUNNING,
STATUS_SUCCESS STATUS_SUCCESS,
} from "shared/constants/status"; } from "shared/constants/status";
jest.dontMock("../status"); jest.dontMock("../status");
@ -16,10 +16,10 @@ describe("Status component", () => {
const instance = status.instance(); const instance = status.instance();
expect( expect(
instance.shouldComponentUpdate({ status: STATUS_FAILURE }) instance.shouldComponentUpdate({ status: STATUS_FAILURE }),
).toBeFalsy(); ).toBeFalsy();
expect( expect(
instance.shouldComponentUpdate({ status: STATUS_SUCCESS }) instance.shouldComponentUpdate({ status: STATUS_SUCCESS }),
).toBeTruthy(); ).toBeTruthy();
expect(status.hasClass("failure")).toBeTruthy(); expect(status.hasClass("failure")).toBeTruthy();
}); });

View file

@ -5,7 +5,7 @@ export default class Avatar extends Component {
render() { render() {
const image = this.props.image; const image = this.props.image;
const style = { const style = {
backgroundImage: `url(${image})` backgroundImage: `url(${image})`,
}; };
return <div className={styles.avatar} style={style} />; return <div className={styles.avatar} style={style} />;
} }

View file

@ -5,12 +5,12 @@ import {
DeployIcon, DeployIcon,
LaunchIcon, LaunchIcon,
MergeIcon, MergeIcon,
TagIcon TagIcon,
} from "shared/components/icons/index"; } from "shared/components/icons/index";
import { import {
EVENT_TAG, EVENT_TAG,
EVENT_PULL_REQUEST, EVENT_PULL_REQUEST,
EVENT_DEPLOY EVENT_DEPLOY,
} from "shared/constants/events"; } from "shared/constants/events";
import styles from "./build_event.less"; import styles from "./build_event.less";
@ -40,13 +40,15 @@ export default class BuildEvent extends Component {
)} )}
</div> </div>
<div> <div>
{event === EVENT_TAG && refs {event === EVENT_TAG && refs ? (
? trimTagRef(refs) trimTagRef(refs)
: event === EVENT_PULL_REQUEST && refspec ) : event === EVENT_PULL_REQUEST && refspec ? (
? trimMergeRef(refs) trimMergeRef(refs)
: event === EVENT_DEPLOY && target ) : event === EVENT_DEPLOY && target ? (
? target target
: branch} ) : (
branch
)}
</div> </div>
</div> </div>
<a href={link} target="_blank"> <a href={link} target="_blank">

View file

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

View file

@ -10,7 +10,7 @@ import {
STATUS_RUNNING, STATUS_RUNNING,
STATUS_SKIPPED, STATUS_SKIPPED,
STATUS_STARTED, STATUS_STARTED,
STATUS_SUCCESS STATUS_SUCCESS,
} from "shared/constants/status"; } from "shared/constants/status";
import style from "./status.less"; import style from "./status.less";
@ -19,7 +19,7 @@ import {
CloseIcon, CloseIcon,
ClockIcon, ClockIcon,
RefreshIcon, RefreshIcon,
RemoveIcon RemoveIcon,
} from "./icons/index"; } from "./icons/index";
const defaultIconSize = 15; const defaultIconSize = 15;

View file

@ -19,5 +19,5 @@ export {
STATUS_RUNNING, STATUS_RUNNING,
STATUS_SKIPPED, STATUS_SKIPPED,
STATUS_SUCCESS, 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 slug = repositorySlug(owner, repo);
const init = { const init = {
data: [], data: [],
loading: true loading: true,
}; };
tree.set(["logs", "data", slug, build, proc], init); tree.set(["logs", "data", slug, build, proc], init);