Skip to content

Commit

Permalink
Merge pull request #11345 from qmonmert/reactfixeslint
Browse files Browse the repository at this point in the history
React/ESLint some files are not linted
  • Loading branch information
murdos authored Nov 12, 2024
2 parents 1913444 + 3bee8fe commit daa37b1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
private Consumer<JHipsterModuleBuilder> patchEslintConfig(JHipsterModuleProperties properties) {
String reactConfig =
"""
\t\tfiles: ['src/main/webapp/**/*.{ts,tsx}', 'src/main/webapp/**/*.spec.ts'],
\t\tfiles: ['src/main/webapp/**/*.{ts,tsx}', 'src/test/webapp/unit/**/*.{ts,tsx}'],
\t\textends: [...typescript.configs.recommendedTypeChecked, react],
\t\tsettings: {
\t\t\treact: {
Expand All @@ -143,6 +143,9 @@ private Consumer<JHipsterModuleBuilder> patchEslintConfig(JHipsterModuleProperti
regex("[ \\t]+quotes: \\['error', 'single', \\{ avoidEscape: true }],"),
"""
\t\t\t'react/react-in-jsx-scope': 'off',
\t\t\t'@typescript-eslint/no-explicit-any': 'off',
\t\t\t'@typescript-eslint/no-unsafe-argument': 'off',
\t\t\t'@typescript-eslint/await-thenable': 'off',
\t\t\t'@typescript-eslint/no-misused-promises': [
\t\t\t\t'error',
\t\t\t\t{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
vi.mock('react-i18next', () => ({
useTranslation: () => {
return {
t: vi.fn().mockImplementation((_str: string) => 'Internationalization enabled'),
t: vi.fn().mockImplementation(() => 'Internationalization enabled'),
};
},
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const login = async () => {
const { getByText, getByPlaceholderText, getByTestId } = render(<LoginForm />);
const loginButton = getByText('Log in');
fireEvent.click(loginButton);
await act(async () => {
await act(() => {
fireEvent.change(getByPlaceholderText("Nom d'utilisateur"), {
target: { value: 'admin' },
});
Expand All @@ -40,7 +40,7 @@ describe('loginForm', () => {
fireEvent.click(loginButton);
expect(getByText('Connect')).toBeTruthy();
const submitButton = getByTestId('submit-button');
await act(async () => {
await act(() => {
fireEvent.click(submitButton);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('test login modal', () => {
it('should contain password input', async () => {
const { getByPlaceholderText, getByTestId } = LoginModalRender(true);
const username = getByPlaceholderText('Mot de passe');
await act(async () => {
await act(() => {
const displayPasswordButton = getByTestId('display-password');
fireEvent.click(displayPasswordButton);
});
Expand All @@ -54,7 +54,7 @@ describe('test login modal', () => {
const { getByPlaceholderText, getByTestId } = LoginModalRender(true);
const spy = vi.spyOn(axios, 'post');
spy.mockImplementationOnce((): Promise<any> => Promise.resolve({ data: {} }));
await act(async () => {
await act(() => {
fireEvent.change(getByPlaceholderText("Nom d'utilisateur"), {
target: { value: 'admin' },
});
Expand All @@ -71,7 +71,7 @@ describe('test login modal', () => {
const { getByPlaceholderText, getByRole } = LoginModalRender(true);
const spy = vi.spyOn(axios, 'post');
spy.mockImplementationOnce((): Promise<any> => Promise.resolve({ data: {} }));
await act(async () => {
await act(() => {
fireEvent.change(getByPlaceholderText("Nom d'utilisateur"), {
target: { value: 'admin' },
});
Expand All @@ -86,7 +86,7 @@ describe('test login modal', () => {

it('should contain error message when submit button is clicked with empty value', async () => {
const { getByTestId } = LoginModalRender(true);
await act(async () => {
await act(() => {
const submitButton = getByTestId('submit-button');
fireEvent.click(submitButton);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default typescript.config(
},
js.configs.recommended,
{
files: ['src/main/webapp/**/*.{ts,tsx}', 'src/main/webapp/**/*.spec.ts'],
files: ['src/main/webapp/**/*.{ts,tsx}', 'src/test/webapp/unit/**/*.{ts,tsx}'],
extends: [...typescript.configs.recommendedTypeChecked, react],
settings: {
react: {
Expand All @@ -31,6 +31,9 @@ export default typescript.config(
},
rules: {
'react/react-in-jsx-scope': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/no-misused-promises': [
'error',
{
Expand Down

0 comments on commit daa37b1

Please sign in to comment.