Skip to content

Commit c6be6f2

Browse files
authored
Fix most linter warnings. (#853)
* Add back type checking and fix errors. * Fix most linter warnings. * Fix glob pattern and more things. * Fix prettier formatting too. * Fix disabled button test.
1 parent 5f21fc0 commit c6be6f2

38 files changed

+113
-111
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ module.exports = {
2222
'plugin:jest/recommended',
2323
'plugin:react-hooks/recommended',
2424
],
25-
plugins: ['jest'],
25+
plugins: ['jest', 'unused-imports'],
2626
rules: {
2727
'jest/no-jasmine-globals': 'error',
28+
'unused-imports/no-unused-imports-ts': 'error',
2829
'no-restricted-globals': [
2930
'error',
3031
{

package-lock.json

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
"test:debug": "react-scripts --inspect-brk test --env=./custom-jest-environment.js --runInBand",
8888
"test:coverage": "react-scripts test --coverage --watchAll=false --env=./custom-jest-environment.js",
8989
"eject": "react-scripts eject",
90-
"lint": "prettier --check . && eslint 'src/**/*.{ts,tsx}'",
91-
"lint:fix": "eslint --fix 'src/**/*.{ts,tsx}' && npm run format",
90+
"lint": "prettier --check . && eslint --ext .js,.jsx,.ts,.tsx src/",
91+
"lint:fix": "eslint --ext .js,.jsx,.ts,.tsx src/ && npm run format",
9292
"fmt": "npm run format",
9393
"format": "prettier --write .",
9494
"prepare": "husky install"
@@ -122,6 +122,7 @@
122122
"confusing-browser-globals": "^1.0.11",
123123
"eslint-plugin-jest": "^23.11.0",
124124
"eslint-plugin-react-hooks": "^4.0.0",
125+
"eslint-plugin-unused-imports": "^2.0.0",
125126
"globalthis": "^1.0.1",
126127
"husky": "^8.0.0",
127128
"import-sort-config": "^6.0.0",

src/__mocks__/react-markdown.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
const React = require('react');
1617

1718
function ReactMarkdown({ children }) {
18-
return <>Markdown: {children}</>;
19+
return React.createElement(React.Fragment, {}, 'Markdown: ', children);
1920
}
2021

2122
export default ReactMarkdown;

src/components/App/index.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
*/
1616

1717
import { fireEvent, render } from '@testing-library/react';
18-
import { createMemoryHistory } from 'history';
1918
import React from 'react';
20-
import ReactDOM from 'react-dom';
2119
import { act } from 'react-dom/test-utils';
2220
import { BrowserRouter } from 'react-router-dom';
2321

src/components/Auth/OneAccountPerEmailCard/OneAccountPerEmailCard.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import { Portal } from '@rmwc/base';
1818
import { fireEvent, render } from '@testing-library/react';
1919
import React from 'react';
2020
import { Provider } from 'react-redux';
21-
import configureStore from 'redux-mock-store';
2221

23-
import { AppState } from '../../../store';
2422
import { waitForDialogsToOpen } from '../../../test_utils';
2523
import { getMockAuthStore } from '../test_utils';
2624
import {

src/components/Auth/UserFormDialog/UserForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ export const UserForm: React.FC<React.PropsWithChildren<UserFormProps>> = ({
147147
const {
148148
register,
149149
handleSubmit,
150-
formState: { errors, isValid },
150+
formState: { errors },
151151
reset,
152152
} = form;
153153

154-
// FIXME: Should be able to just check isValid, instead of checking
154+
// FIXME: Should be able to just check form.isValid, instead of checking
155155
// that there are no errors. This only happens when `atLeastOneMethodRequired`
156156
// is the only error present and is causing the "Save" and "Save and create
157157
// another" buttons to remain enabled even when neither email/password or

src/components/Auth/UserFormDialog/controls/CustomAttributes.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react';
18-
1917
import { wrapWithForm } from '../../../../test_utils';
2018
import { CustomAttributes } from './CustomAttributes';
2119

@@ -60,7 +58,7 @@ describe('CustomAttributes', () => {
6058
});
6159

6260
it('displays an error if a forbidden key was used', async () => {
63-
const { triggerValidation, getByRole, getByText } = setup(
61+
const { triggerValidation, getByRole } = setup(
6462
'{"firebase": "is awesome"}'
6563
);
6664
await triggerValidation();

src/components/Auth/UserFormDialog/controls/ImageUrlInput.test.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react';
1817
import { act } from 'react-dom/test-utils';
1918

2019
import { wrapWithForm } from '../../../../test_utils';
@@ -51,7 +50,7 @@ describe('ImageUrlInput', () => {
5150
});
5251

5352
await triggerValidation();
54-
getByText('Error loading image');
53+
expect(getByText('Error loading image')).not.toBeNull();
5554
});
5655

5756
it('displays an image if image loaded', async () => {
@@ -64,13 +63,13 @@ describe('ImageUrlInput', () => {
6463
});
6564

6665
await triggerValidation();
67-
getByAltText('Profile preview');
66+
expect(getByAltText('Profile preview')).not.toBeNull();
6867
});
6968

7069
it('displays loading spinner', async () => {
7170
const { getByTestId, triggerValidation } = setup({ photoUrl: 'lol.png' });
7271
await triggerValidation();
73-
getByTestId('spinner');
72+
expect(getByTestId('spinner')).not.toBeNull();
7473
});
7574

7675
it('displays nothing if there is no image', async () => {

src/components/Auth/UserFormDialog/controls/PhoneControl.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
import { fireEvent } from '@testing-library/react';
18-
import React from 'react';
1918

2019
import { wrapWithForm } from '../../../../test_utils';
2120
import { PhoneControl, PhoneControlProps } from './PhoneControl';

0 commit comments

Comments
 (0)