Skip to content

Commit

Permalink
Add linting check into Ci (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
slai11 authored Jul 31, 2019
1 parent c016bb1 commit a3f35bf
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ matrix:
- cd ui/
- npm install
script:
- npm test
- npm run lint && npm test
before_deploy:
- docker login ${DOCKER_REGISTRY} -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
- docker build . -t ${UI_IMAGE_NAME}:${TRAVIS_TAG}
Expand Down
3 changes: 2 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"webpack-dev-server": "^3.2.1"
},
"scripts": {
"flow": "flow",
"flow": "flow check --show-all-errors",
"start": "npm run dev",
"lint": "npm run flow && npm run eslint",
"build": "webpack --config webpack.prod.js",
"dev": "webpack-dev-server --display-error-details --progress --colors --config webpack.dev.js",
"eslint": "eslint --ext .js --ext .jsx src/ tests/",
Expand Down
14 changes: 5 additions & 9 deletions ui/src/components/DeleteButtonWithWarning.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// @flow

import React, { useState } from "react";
import PropTypes from "prop-types";
import TextField from "@material-ui/core/TextField";
import { Card, CardContent, CardHeader } from "@material-ui/core";
import Fab from "@material-ui/core/Fab";
import DeleteIcon from "@material-ui/icons/Delete";
import MenuItem from "@material-ui/core/MenuItem";
import Button from "@material-ui/core/Button";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
Expand All @@ -22,8 +18,8 @@ const DeleteButtonWithWarning = (props: Props) => {
const [open, setOpen] = useState(false);

function triggerFn() {
setOpen(false);
props.fn();
setOpen(false);
props.fn();
}

return (
Expand All @@ -42,11 +38,11 @@ const DeleteButtonWithWarning = (props: Props) => {
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">{"Delete Resource?"}</DialogTitle>
<DialogTitle id="alert-dialog-title">Delete Resource?</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
Doing this will delete the resource and you cannot undo it. Unless you
click refresh to fetch the persisted state which might undo any
Doing this will delete the resource and you cannot undo it. Unless
you click refresh to fetch the persisted state which might undo any
other changes you currently have.
</DialogContentText>
</DialogContent>
Expand Down
3 changes: 0 additions & 3 deletions ui/src/components/Resource.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import React from "react";
import TextField from "@material-ui/core/TextField";
import Fab from "@material-ui/core/Fab";
import DeleteIcon from "@material-ui/icons/Delete";
import {
Card,
CardContent,
CardHeader
} from "../../node_modules/@material-ui/core";
import Button from "@material-ui/core/Button";
import NomadParameters from "../containers/NomadParameters";
import EC2Parameters from "../containers/EC2Parameters";
import DeleteButtonWithWarning from "./DeleteButtonWithWarning";
Expand Down
2 changes: 0 additions & 2 deletions ui/src/components/Subpolicy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import React from "react";
import TextField from "@material-ui/core/TextField";
import { Card, CardContent, CardHeader } from "@material-ui/core";
import Fab from "@material-ui/core/Fab";
import DeleteIcon from "@material-ui/icons/Delete";
import MenuItem from "@material-ui/core/MenuItem";
import Button from "@material-ui/core/Button";
import ManagedResources from "../containers/ManagedResources";
Expand Down
5 changes: 2 additions & 3 deletions ui/tests/components/DeleteButtonWithWarning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import Fab from "@material-ui/core/Fab";
import DeleteButtonWithWarning from "../../src/components/DeleteButtonWithWarning";

function shallowSetup() {
const props = {
const props = {
fn: jest.fn()
};
const enzymeWrapper = shallow(<DeleteButtonWithWarning {...props} />);
return {
props,
props,
enzymeWrapper
};
}
Expand All @@ -37,5 +37,4 @@ describe("DeleteButtonWithWarning", () => {
expect(props.fn.mock.calls.length).toBe(1);
});
});

});
6 changes: 4 additions & 2 deletions ui/tests/components/Resource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ describe("Resource", () => {

describe("clicks", () => {
it("clicking delete should not immediately trigger deleteResource", () => {
const { enzymeWrapper, props } = shallowSetup();
expect(enzymeWrapper.find(DeleteButtonWithWarning).exists()).toEqual(true);
const { enzymeWrapper } = shallowSetup();
expect(enzymeWrapper.find(DeleteButtonWithWarning).exists()).toEqual(
true
);
});
});
});
7 changes: 4 additions & 3 deletions ui/tests/components/Subpolicy.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import Adapter from "enzyme-adapter-react-16";
import { shallow, configure } from "enzyme";
import Fab from "@material-ui/core/Fab";
import TextField from "@material-ui/core/TextField";
import Subpolicy from "../../src/components/Subpolicy";
import ManagedResources from "../../src/containers/ManagedResources";
Expand Down Expand Up @@ -44,8 +43,10 @@ describe("Subpolicy", () => {

describe("clicks", () => {
it("clicking delete should NOT immediately trigger deleteSubpolicy", () => {
const { enzymeWrapper, props } = shallowSetup();
expect(enzymeWrapper.find(DeleteButtonWithWarning).exists()).toEqual(true);
const { enzymeWrapper } = shallowSetup();
expect(enzymeWrapper.find(DeleteButtonWithWarning).exists()).toEqual(
true
);
});
});
});

0 comments on commit a3f35bf

Please sign in to comment.