Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 33 additions & 19 deletions packages/fxa-react/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
{
"extends": ["plugin:fxa/recommended"],
"plugins": ["fxa"],
"parserOptions": {
"ecmaVersion": "2020",
"sourceType": "module"
},
"env": {
"browser": true,
"jest": true
},
"root": true,
"extends": ["react-app", "react-app/jest"],
"plugins": ["header"],
"rules": {
"require-atomic-updates": "off",
"space-unary-ops": "off",
"no-useless-escape": "off"
"import/export": "error",
"import/named": "off",
"import/no-deprecated": "error",
"import/no-named-as-default-member": "off",
"import/no-unresolved": "off",
"jest/no-jest-import": "off",
"jest/valid-describe": "off",
"testing-library/no-wait-for-multiple-assertions": "off",
"testing-library/no-render-in-setup": "off",
"testing-library/prefer-find-by": "off",
"testing-library/no-wait-for-side-effects": "off",
"testing-library/prefer-presence-queries": "off",
"testing-library/no-node-access": "off",
"testing-library/render-result-naming-convention": "off",
"testing-library/prefer-screen-queries": "off",
"testing-library/no-unnecessary-act": "off",
"testing-library/no-container": "off",
"header/header": [
2, "block",
" This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. "
]
},
"ignorePatterns": [
"dist",
"node_modules",
"pm2.config.js",
"storybook-static"
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error"
}
}
],
"root": true
"ignorePatterns": ["build/", "scripts/build.js", "dist/"]
}
2 changes: 0 additions & 2 deletions packages/fxa-react/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict';

module.exports = function (grunt) {
const srcPaths = [
'components/**/*.ftl',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import React from 'react';
import { storiesOf } from '@storybook/react';
import AppErrorDialog from './index';
Expand Down
2 changes: 1 addition & 1 deletion packages/fxa-react/components/AppErrorDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import React, { ReactNode } from 'react';
import React from 'react';
import { Localized } from '@fluent/react';

export type ErrorType = 'general' | 'query-parameter-violation';
Expand Down
3 changes: 3 additions & 0 deletions packages/fxa-react/components/Header/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import React from 'react';
import { storiesOf } from '@storybook/react';
import { Header } from './index';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import React from 'react';
import { storiesOf } from '@storybook/react';
import LinkExternal from './index';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import React from 'react';
import { storiesOf } from '@storybook/react';
import LoadingSpinner, { SpinnerType } from './index';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import React from 'react';
import { screen } from '@testing-library/react';

Expand Down Expand Up @@ -30,7 +33,7 @@ it('renders blue spinner as expected', () => {
expect(spinnerType).toBeInTheDocument();
});

it('renders blue spinner as expected', () => {
it('renders white spinner as expected', () => {
renderWithLocalizationProvider(
<LoadingSpinner spinnerType={SpinnerType.White} />
);
Expand Down
3 changes: 3 additions & 0 deletions packages/fxa-react/components/LoadingSpinner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { useLocalization } from '@fluent/react';
import React from 'react';
import classNames from 'classnames';
Expand Down
3 changes: 3 additions & 0 deletions packages/fxa-react/components/LogoLockup/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import React from 'react';
import LogoLockup from '.';
import { renderWithLocalizationProvider } from '../../lib/test-utils/localizationProvider';
Expand Down
3 changes: 3 additions & 0 deletions packages/fxa-react/components/Portal/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import React from 'react';
import { render, screen } from '@testing-library/react';
import Portal from './index';
Expand Down
3 changes: 3 additions & 0 deletions packages/fxa-react/components/Portal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import React, { memo, useEffect } from 'react';
import { createPortal } from 'react-dom';

Expand Down
3 changes: 3 additions & 0 deletions packages/fxa-react/extract-imported-components.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { readdirSync, readFileSync, statSync } = require('fs');
const { resolve } = require('path');

Expand Down
11 changes: 7 additions & 4 deletions packages/fxa-react/lib/hooks.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import React, { useCallback } from 'react';
import { storiesOf } from '@storybook/react';
import { useAwait, PromiseState } from './hooks';
Expand Down Expand Up @@ -43,10 +46,10 @@ const UseAwaitExample = ({
executeImmediately,
initialState,
});
const executeWithApiUrl = useCallback(() => apiExecute(apiUrl), [
apiUrl,
apiExecute,
]);
const executeWithApiUrl = useCallback(
() => apiExecute(apiUrl),
[apiUrl, apiExecute]
);

const buttonClassNames = 'mr-1 py-1 px-2 bg-grey-100 border-grey-600';
return (
Expand Down
13 changes: 4 additions & 9 deletions packages/fxa-react/lib/hooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('useAwait', () => {
} catch (e) {
setThrownState(e);
}
}, [execute]);
}, [execute, fnArgs]);
return (
<div>
{state.pending && <div data-testid="pending">pending</div>}
Expand Down Expand Up @@ -187,9 +187,7 @@ describe('useAwait', () => {
const fn = async () => {
throw expectedError;
};
const { findByTestId, getByTestId, debug } = render(
<Subject {...{ fn }} />
);
const { findByTestId, getByTestId } = render(<Subject {...{ fn }} />);
expect(parseState(getByTestId)).toEqual({
pending: undefined,
result: undefined,
Expand All @@ -213,7 +211,7 @@ describe('useAwait', () => {
const fn = async () => {
throw expectedError;
};
const { findByTestId, getByTestId, debug } = render(
const { findByTestId, getByTestId } = render(
<Subject {...{ fn, rethrowError: true }} />
);
expect(parseState(getByTestId)).toEqual({
Expand Down Expand Up @@ -251,12 +249,9 @@ describe('useAwait', () => {
});

it('does not re-execute when a promise is already pending', async () => {
const expectedError = 'oops!';
let count = 0;
const fn = async () => `count: ${++count}`;
const { findByTestId, getByTestId, debug } = render(
<Subject {...{ fn }} />
);
const { findByTestId, getByTestId } = render(<Subject {...{ fn }} />);
expect(parseState(getByTestId)).toEqual({
pending: undefined,
result: undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/fxa-react/lib/test-utils/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe('testL10n', () => {
expect(() => {
ftlMsgResolver.getMsg('test-straight-quote', `"please, don’t go"`);
}).toThrow(
`Fluent message contains a straight quote (") and must be updated to its curly equivalent (“”). Fluent message: \"please, don’t go\"`
`Fluent message contains a straight quote (") and must be updated to its curly equivalent (“”). Fluent message: "please, don’t go"`
);
});

Expand Down
2 changes: 0 additions & 2 deletions packages/fxa-react/lib/test-utils/localizationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ export function withLocalizationProvider(
</AppLocalizationProvider>
);
}

export default { renderWithLocalizationProvider, withLocalizationProvider };
1 change: 1 addition & 0 deletions packages/fxa-react/lib/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ function _checkPattern(
*/
function _clean(msg: string) {
return msg.replace(
// eslint-disable-next-line
/[\u0000-\u001F\u007F-\u009F\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,
''
);
Expand Down