Skip to content

Commit 3e9343e

Browse files
authored
Merge pull request #10 from jsdrupal/prettier
Prettier
2 parents 48c7a4c + de74c79 commit 3e9343e

File tree

13 files changed

+444
-123
lines changed

13 files changed

+444
-123
lines changed

.circleci/config.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,23 @@ jobs:
3232
- node_modules
3333
key: build-v1-{{ .Branch }}-{{ .Revision }}
3434

35-
test:
35+
lint:
3636
<<: *defaults
3737
steps:
3838
- checkout
3939
- *restore-build
40-
- run: yarn test
40+
- run: yarn test:lint:ci
41+
- store_test_results:
42+
path: reports
43+
44+
unit:
45+
<<: *defaults
46+
steps:
47+
- checkout
48+
- *restore-build
49+
- run: yarn test:unit:ci
50+
- store_test_results:
51+
path: reports
4152

4253
dist:
4354
<<: *defaults
@@ -64,12 +75,16 @@ workflows:
6475
package:
6576
jobs:
6677
- build
67-
- test:
78+
- lint:
79+
requires:
80+
- build
81+
- unit:
6882
requires:
6983
- build
7084
- dist:
7185
requires:
72-
- test
86+
- lint
87+
- unit
7388
- build
7489
filters:
7590
branches:

.eslintrc.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": [
3+
"airbnb",
4+
"plugin:prettier/recommended"
5+
],
6+
"parser": "babel-eslint",
7+
"env": {
8+
"browser": true,
9+
"es6": true,
10+
"jest": true,
11+
"serviceworker": true
12+
},
13+
"rules": {
14+
"react/jsx-filename-extension": [1, { "extensions": [".js"] }],
15+
"jsx-a11y/anchor-is-valid": [ "error", {
16+
"aspects": [ "noHref" ]
17+
}],
18+
"no-param-reassign": [2, { "props": false }]
19+
}
20+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
# testing
77
/coverage
8+
/reports
89

910
# production
1011
/build

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 80,
3+
"semi": true,
4+
"singleQuote": true,
5+
"trailingComma": "all"
6+
}

package.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,33 @@
44
"private": true,
55
"dependencies": {
66
"emotion": "^9.0.2",
7+
"prop-types": "^15.6.1",
78
"react": "^16.2.0",
89
"react-dom": "^16.2.0",
910
"react-router-dom": "^4.2.2"
1011
},
1112
"devDependencies": {
13+
"babel-eslint": "^8.2.2",
14+
"eslint": "^4.9.0",
15+
"eslint-config-airbnb": "^16.1.0",
16+
"eslint-config-prettier": "^2.9.0",
17+
"eslint-plugin-import": "^2.7.0",
18+
"eslint-plugin-jsx-a11y": "^6.0.2",
19+
"eslint-plugin-prettier": "^2.6.0",
20+
"eslint-plugin-react": "^7.4.0",
21+
"jest-junit": "^3.6.0",
22+
"prettier": "^1.11.1",
1223
"react-scripts": "1.1.1"
1324
},
1425
"scripts": {
26+
"prettier": "prettier --write 'src/**/*.js'",
1527
"start": "react-scripts start",
1628
"build": "react-scripts build",
17-
"test": "react-scripts test --env=jsdom",
29+
"test": "yarn test:lint && yarn test:unit",
30+
"test:unit": "react-scripts test --env=jsdom",
31+
"test:unit:ci": "CI=true JEST_JUNIT_OUTPUT=reports/jest-junit.xml react-scripts test --testResultsProcessor ./node_modules/jest-junit --env=jsdom",
32+
"test:lint": "eslint ./src --max-warnings=0",
33+
"test:lint:ci": "eslint ./src --max-warnings=0 --format junit -o reports/eslint-junit.xml",
1834
"eject": "react-scripts eject"
1935
}
2036
}

src/App.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React, { Component } from 'react';
2+
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
3+
4+
import routes from './routes';
5+
6+
import Home from './components/05_pages/Home/Home';
7+
import NoMatch from './NoMatch';
8+
9+
import normalize from './styles/normalize'; // eslint-disable-line no-unused-vars
10+
import base from './styles/base'; // eslint-disable-line no-unused-vars
11+
12+
class App extends Component {
13+
componentDidMount() {
14+
window.history.replaceState(null, null, '/');
15+
}
16+
render() {
17+
return (
18+
<Router>
19+
<div>
20+
<ul>
21+
<li>
22+
<Link to="/">Home</Link>
23+
</li>
24+
<li>
25+
<Link to="/admin/people/permissions">Permissions</Link>
26+
</li>
27+
<li>
28+
<Link to="/admin/appearance">Appearance</Link>
29+
</li>
30+
<li>
31+
<Link to="/node/add">Content</Link>
32+
</li>
33+
</ul>
34+
35+
<hr />
36+
37+
<Route exact path="/" component={Home} />
38+
{Object.keys(routes).map(route => (
39+
<Route path={route} component={routes[route]} key={route} />
40+
))}
41+
<Route component={NoMatch} />
42+
</div>
43+
</Router>
44+
);
45+
}
46+
}
47+
48+
export default App;

src/App.jsx

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/NoMatch.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Component } from 'react';
2+
import { shape, string } from 'prop-types';
3+
4+
import routes from './routes';
5+
6+
const NoMatch = class NoMatch extends Component {
7+
static propTypes = {
8+
location: shape({
9+
pathname: string.isRequired,
10+
}).isRequired,
11+
};
12+
componentWillReceiveProps(nextProps) {
13+
if (!Object.keys(routes).includes(nextProps.location.pathname)) {
14+
window.location = window.location.href;
15+
}
16+
}
17+
render() {
18+
return null;
19+
}
20+
};
21+
22+
export default NoMatch;
File renamed without changes.
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import React from 'react';
22
import { css } from 'emotion';
33

4+
const styles = {
5+
title: css`
6+
text-decoration: underline;
7+
`,
8+
};
9+
410
const Permissions = () => (
511
<div>
612
<h1 className={styles.title}>Permissions</h1>
713
<p>This will be the permissions page.</p>
814
</div>
915
);
1016

11-
const styles = {
12-
title: css`
13-
text-decoration: underline;
14-
`,
15-
};
16-
1717
export default Permissions;
18-

0 commit comments

Comments
 (0)