Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.

Commit 0927ca2

Browse files
committed
fixes after rebase
1 parent 96b10a4 commit 0927ca2

File tree

10 files changed

+40
-17
lines changed

10 files changed

+40
-17
lines changed

.eslintrc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
"plugin:jest/recommended",
66
"plugin:@typescript-eslint/recommended"
77
],
8-
"globals": {
9-
"document": true
10-
},
118
"parser": "@typescript-eslint/parser",
129
"rules": {
1310
// TS configuration for the `indent` rule.
1411
// https://github.com/typescript-eslint/typescript-eslint/blob/5b0b3d9edbcb3ab588a34c431037d9deece30824/packages/eslint-plugin/docs/rules/indent.md#options
1512
"indent": "off",
1613
"@typescript-eslint/indent": ["error", 2],
1714
"import/no-extraneous-dependencies": ["error", {
18-
"devDependencies": ["**/*.test.*"]
15+
"devDependencies": ["**/*.test.*", "**/*.spec.*"]
1916
}
2017
],
2118
// We use `.tsx` instead of `.jsx` for files with JSX inside.
@@ -25,7 +22,14 @@
2522
],
2623
// We decided to prefer types over interfaces.
2724
"@typescript-eslint/prefer-interface": "off",
28-
"@typescript-eslint/explicit-member-accessibility": "off"
25+
"@typescript-eslint/explicit-member-accessibility": "off",
26+
// This rule conflicts with our convention.
27+
"jest/valid-describe": "off",
28+
// These rules are not compatible with Prettier.
29+
"implicit-arrow-linebreak": "off",
30+
"no-mixed-operators": "off",
31+
"operator-linebreak": "off",
32+
"react/jsx-one-expression-per-line": "off"
2933
},
3034
"settings": {
3135
"import/resolver": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@types/redux-logger": "3.0.6",
1313
"express": "4.16.4",
1414
"http-proxy-middleware": "0.19.1",
15+
"http-proxy-response-rewrite": "^0.0.1",
1516
"node-sass": "4.11.0",
1617
"react": "16.7.0",
1718
"react-dom": "16.7.0",
@@ -38,7 +39,6 @@
3839
"enzyme-adapter-react-16": "^1.7.1",
3940
"eslint-config-amo": "^1.11.0",
4041
"eslint-plugin-amo": "^1.9.1",
41-
"http-proxy-response-rewrite": "^0.0.1",
4242
"jest-enzyme": "^7.0.1",
4343
"jest-enzyme": "^7.0.1",
4444
"jest-fetch-mock": "^2.1.0",

src/api/index.spec.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import { HttpMethod, callApi, logOutFromServer } from '.';
1+
/* global fetch, fetchMock */
22
import {
3-
initialState as defaultApiState,
3+
ApiState,
44
actions as apiActions,
5+
initialState as defaultApiState,
56
} from '../reducers/api';
67
import configureStore from '../configureStore';
78

9+
import { HttpMethod, callApi, logOutFromServer } from '.';
10+
811
describe(__filename, () => {
9-
const getApiState = ({ authToken = '12345' } = {}) => {
12+
const getApiState = ({ authToken = '12345' } = {}): ApiState => {
1013
const store = configureStore();
1114

1215
store.dispatch(apiActions.setAuthToken({ authToken }));
@@ -16,7 +19,7 @@ describe(__filename, () => {
1619
};
1720

1821
describe('callApi', () => {
19-
const callApiWithDefaultApiState = (params = {}) => {
22+
const callApiWithDefaultApiState = (params = {}): object => {
2023
return callApi({ apiState: defaultApiState, endpoint: '/', ...params });
2124
};
2225

src/api/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* global fetch */
12
import { ApiState } from '../reducers/api';
23

34
export enum HttpMethod {
@@ -26,15 +27,17 @@ export const callApi = async ({
2627
version = 'v4',
2728
}: CallApiParams): Promise<object | { error: Error }> => {
2829
if (!endpoint.startsWith('/')) {
30+
// eslint-disable-next-line no-param-reassign
2931
endpoint = `/${endpoint}`;
3032
}
3133
if (!endpoint.endsWith('/')) {
34+
// eslint-disable-next-line no-param-reassign
3235
endpoint = `${endpoint}/`;
3336
}
3437

35-
const headers = {} as Headers;
38+
const headers: Headers = {};
3639
if (apiState.authToken) {
37-
headers['Authorization'] = `Bearer ${apiState.authToken}`;
40+
headers.Authorization = `Bearer ${apiState.authToken}`;
3841
}
3942

4043
try {
@@ -51,6 +54,7 @@ export const callApi = async ({
5154

5255
return await response.json();
5356
} catch (error) {
57+
// eslint-disable-next-line amo/only-log-strings, no-console
5458
console.error(error);
5559

5660
return {

src/components/App/index.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import React from 'react';
22
import { shallow } from 'enzyme';
33
import { Store } from 'redux';
44

5-
import App from '.';
65
import styles from './styles.module.scss';
76
import configureStore from '../../configureStore';
87
import { actions as apiActions } from '../../reducers/api';
98

9+
import App from '.';
10+
1011
describe(__filename, () => {
1112
type RenderParams = {
1213
store?: Store;

src/components/App/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class AppBase extends React.Component<Props, State> {
6262
})) as State['profile'];
6363

6464
if (profile && profile.name) {
65+
// eslint-disable-next-line react/no-did-update-set-state
6566
this.setState({ profile });
6667
}
6768
}
@@ -92,13 +93,17 @@ class AppBase extends React.Component<Props, State> {
9293
<header className={styles.header}>
9394
{profile ? (
9495
<React.Fragment>
95-
<h3>Hello {profile.name}!</h3>
96+
<h3>
97+
Hello
98+
{profile.name}!
99+
</h3>
96100

97101
<p>Toggle this on and off to test out Redux:</p>
98102
<p>
99103
<button
100104
onClick={this.handleToggleClick}
101105
style={{ padding: '32px' }}
106+
type="button"
102107
>
103108
{toggledOn ? 'OFF' : 'ON'}
104109
</button>
@@ -108,7 +113,9 @@ class AppBase extends React.Component<Props, State> {
108113
{isLoggingOut ? (
109114
'See you next time... 😕'
110115
) : (
111-
<button onClick={this.logOut}>Log out</button>
116+
<button type="button" onClick={this.logOut}>
117+
Log out
118+
</button>
112119
)}
113120
</p>
114121
</React.Fragment>

src/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global: document */
1+
/* global document */
22
import React from 'react';
33
import ReactDOM from 'react-dom';
44
import { BrowserRouter } from 'react-router-dom';
@@ -7,7 +7,6 @@ import { Provider } from 'react-redux';
77
import './index.css';
88
import App from './components/App';
99
import configureStore from './configureStore';
10-
import { actions as apiActions } from './reducers/api';
1110

1211
const store = configureStore();
1312

src/reducers/api.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import reducer, { actions, initialState } from './api';
33
describe(__filename, () => {
44
describe('reducer', () => {
55
it('initializes the state', () => {
6+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
67
const state = reducer(undefined, { type: 'SOME_ACTION' } as any);
78

89
expect(state).toEqual(initialState);

src/server/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint @typescript-eslint/no-var-requires: 0, no-console: 0, global-require: 0 */
12
// @ts-ignore
23
const fs = require('fs');
34
const path = require('path');
@@ -57,6 +58,7 @@ const createServer = ({
5758
const cookies = proxyResponse.headers['set-cookie'].map((cookie) =>
5859
cookie.replace(/;\s*?(Secure)/i, ''),
5960
);
61+
// eslint-disable-next-line no-param-reassign
6062
proxyResponse.headers['set-cookie'] = cookies;
6163
}
6264
},
@@ -100,6 +102,7 @@ const createServer = ({
100102
ws: true,
101103
onProxyRes: (proxyResponse, req, res) => {
102104
if (req.url === '/') {
105+
// eslint-disable-next-line no-param-reassign
103106
proxyResponse.headers['cache-control'] = 'private, no-store';
104107

105108
modifyResponse(

src/server/index.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from 'path';
2+
23
import request from 'supertest';
34

45
import { createServer, injectAuthenticationToken } from '.';

0 commit comments

Comments
 (0)