Skip to content

Commit cb2d6b9

Browse files
Add Prettier, stylelint, and adjust linting command
1 parent a16855d commit cb2d6b9

File tree

250 files changed

+38460
-15556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+38460
-15556
lines changed

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true
3+
}
4+

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true,
4+
"editor.formatOnPaste": false
5+
}
6+

package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scripts": {
2020
"build": "node scripts/build.js",
2121
"dev-flow": "node scripts/test.js --env=jsdom --coverage --watch",
22-
"lint": "yarn eslint ./src --ext .jsx --fix",
22+
"lint": "yarn prettier \"src/**/*.{js,jsx,ts,tsx,json,md}\" --write && yarn eslint ./src --fix && yarn stylelint \"src/**/*.{css,less}\" --fix",
2323
"release": "yarn run build && release-it --only-version --npm.skipChecks",
2424
"start": "node scripts/start.js",
2525
"test": "node scripts/test.js --env=jsdom --coverage"
@@ -80,6 +80,7 @@
8080
"enzyme": "^3.11.0",
8181
"enzyme-adapter-react-16": "^1.15.2",
8282
"eslint": "^8.23.1",
83+
"eslint-config-prettier": "^8.5.0",
8384
"eslint-config-react-app": "^7.0.1",
8485
"eslint-plugin-flowtype": "^8.0.3",
8586
"eslint-plugin-import": "^2.26.0",
@@ -111,11 +112,14 @@
111112
"object-assign": "4.1.1",
112113
"optimize-css-assets-webpack-plugin": "^6.0.1",
113114
"pnp-webpack-plugin": "^1.7.0",
115+
"postcss": "^8.4.16",
114116
"postcss-flexbugs-fixes": "4.1.0",
117+
"postcss-less": "^6.0.0",
115118
"postcss-loader": "3.0.0",
116119
"postcss-normalize": "7.0.1",
117120
"postcss-preset-env": "6.7.0",
118121
"postcss-safe-parser": "4.0.1",
122+
"prettier": "^2.7.1",
119123
"promise": "8.0.1",
120124
"prop-types": "^15.5.10",
121125
"query-string": "^5.0.0",
@@ -140,6 +144,8 @@
140144
"semver": "6.3.0",
141145
"string-replace-loader": "^1.2.0",
142146
"style-loader": "1.0.0",
147+
"stylelint": "^14.11.0",
148+
"stylelint-config-recommended-less": "^1.0.4",
143149
"terser-webpack-plugin": "^5.3.6",
144150
"ts-pnp": "1.1.2",
145151
"url-loader": "2.1.0",

src/App.jsx

+27-29
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
import './css/App.less'
2-
import { applyMiddleware, createStore } from 'redux'
3-
import {
4-
Route,
5-
BrowserRouter as Router,
6-
Switch
7-
} from 'react-router-dom'
8-
import ComplaintDetail from './components/ComplaintDetail'
9-
import { composeWithDevTools } from 'redux-devtools-extension'
10-
import { IntlProvider } from 'react-intl'
11-
import { Provider } from 'react-redux'
12-
import queryManager from './middleware/queryManager'
13-
import React from 'react'
1+
import './css/App.less';
2+
import { applyMiddleware, createStore } from 'redux';
3+
import { Route, BrowserRouter as Router, Switch } from 'react-router-dom';
4+
import ComplaintDetail from './components/ComplaintDetail';
5+
import { composeWithDevTools } from 'redux-devtools-extension';
6+
import { IntlProvider } from 'react-intl';
7+
import { Provider } from 'react-redux';
8+
import queryManager from './middleware/queryManager';
9+
import React from 'react';
1410
// Required so that the expose-loader test works which moves the ReactDOM
1511
// variable into the global space
1612
// eslint-disable-next-line
17-
import ReactDOM from 'react-dom'
18-
import reducers from './reducers'
19-
import SearchComponents from './components/Search/SearchComponents'
20-
import thunkMiddleware from 'redux-thunk'
13+
import ReactDOM from 'react-dom';
14+
import reducers from './reducers';
15+
import SearchComponents from './components/Search/SearchComponents';
16+
import thunkMiddleware from 'redux-thunk';
2117

22-
const middleware = [ thunkMiddleware, queryManager ];
18+
const middleware = [thunkMiddleware, queryManager];
2319

24-
const composeEnhancers = composeWithDevTools( {
20+
const composeEnhancers = composeWithDevTools({
2521
// required for redux-devtools-extension
2622
// Specify name here, actionsBlacklist, actionsCreators and other options
2723
// if needed
28-
} )
24+
});
2925

3026
// required format for redux-devtools-extension
31-
const store = createStore( reducers, composeEnhancers(
32-
applyMiddleware( ...middleware ),
33-
// other store enhancers if any
34-
) )
35-
27+
const store = createStore(
28+
reducers,
29+
composeEnhancers(
30+
applyMiddleware(...middleware)
31+
// other store enhancers if any
32+
)
33+
);
3634

3735
/* eslint-disable camelcase */
3836

@@ -43,10 +41,10 @@ export class DetailComponents extends React.Component {
4341
return (
4442
<IntlProvider locale="en">
4543
<main role="main">
46-
<ComplaintDetail complaint_id={complaint_id}/>
44+
<ComplaintDetail complaint_id={complaint_id} />
4745
</main>
4846
</IntlProvider>
49-
)
47+
);
5048
}
5149
}
5250

@@ -58,8 +56,8 @@ export class App extends React.Component {
5856
<Provider store={store}>
5957
<Router>
6058
<Switch>
61-
<Route path="*/detail/:id" component={DetailComponents}/>
62-
<Route path="/" component={SearchComponents}/>
59+
<Route path="*/detail/:id" component={DetailComponents} />
60+
<Route path="/" component={SearchComponents} />
6361
</Switch>
6462
</Router>
6563
</Provider>

src/__tests__/App.spec.jsx

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import { act, create } from 'react-test-renderer';
22
import { App, DetailComponents } from '../App';
3-
import configureMockStore from 'redux-mock-store'
4-
import { defaultQuery } from '../reducers/query'
3+
import configureMockStore from 'redux-mock-store';
4+
import { defaultQuery } from '../reducers/query';
55
import { MemoryRouter } from 'react-router';
6-
import { Provider } from 'react-redux'
6+
import { Provider } from 'react-redux';
77
import React from 'react';
8-
import thunk from 'redux-thunk'
8+
import thunk from 'redux-thunk';
99
import 'regenerator-runtime/runtime';
1010

11-
jest.mock( 'highcharts/modules/accessibility' )
12-
jest.mock( 'highcharts/highmaps' )
11+
jest.mock('highcharts/modules/accessibility');
12+
jest.mock('highcharts/highmaps');
1313

1414
describe('initial state', () => {
1515
it('renders without crashing', async () => {
16-
1716
// set the date so snapshot will always be the same.
1817
const DATE_TO_USE = new Date('1/1/2016');
1918
const _Date = Date;
@@ -23,32 +22,31 @@ describe('initial state', () => {
2322
global.Date.now = _Date.now;
2423
defaultQuery.searchText = 'foo';
2524

26-
let target
27-
await act( async () => {
25+
let target;
26+
await act(async () => {
2827
target = create(
29-
<MemoryRouter initialEntries={[ '/' ]}>
28+
<MemoryRouter initialEntries={['/']}>
3029
<App />
3130
</MemoryRouter>
32-
)
33-
} )
31+
);
32+
});
3433

3534
let tree = target.toJSON();
3635
expect(tree).toMatchSnapshot();
37-
3836
});
3937

4038
it('renders the detail route', () => {
41-
const middlewares = [thunk]
42-
const mockStore = configureMockStore(middlewares)
39+
const middlewares = [thunk];
40+
const mockStore = configureMockStore(middlewares);
4341
const store = mockStore({
44-
detail: { data: {}, error: '' }
45-
})
42+
detail: { data: {}, error: '' },
43+
});
4644

4745
const match = { params: { id: '1234' } };
4846
const detailTarget = create(
49-
<MemoryRouter initialEntries={[ '/detail/1234' ]}>
47+
<MemoryRouter initialEntries={['/detail/1234']}>
5048
<Provider store={store}>
51-
<DetailComponents match={ match }/>
49+
<DetailComponents match={match} />
5250
</Provider>
5351
</MemoryRouter>
5452
);

0 commit comments

Comments
 (0)