From 439ed964e676d117e483aee4c0aa8957fa6dbf83 Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 11 Nov 2024 22:08:14 +0100 Subject: [PATCH] React/ESLint some files are not linting --- .../client/react/core/domain/ReactCoreModulesFactory.java | 7 ++++++- .../client/react/i18n/domain/ReactI18nModuleFactory.java | 2 +- .../unit/login/primary/loginForm/index.test.tsx.mustache | 4 ++-- .../unit/login/primary/loginModal/index.test.tsx.mustache | 8 ++++---- src/main/resources/generator/typescript/tsconfig.json | 2 +- ...ouldBuildModuleWithStyle.eslint.config.js.approved.txt | 7 ++++++- ....shouldBuildModuleWithStyle.tsconfig.json.approved.txt | 2 +- ...yTest.shouldCreateVueModule.tsconfig.json.approved.txt | 2 +- 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java index 86467a94cb2..11c86c32199 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java @@ -116,7 +116,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) { private Consumer patchEslintConfig(JHipsterModuleProperties properties) { String reactConfig = """ - \t\tfiles: ['src/main/webapp/**/*.{ts,tsx}', 'src/main/webapp/**/*.spec.ts'], + \t\tfiles: ['src/*/webapp/**/*.{ts,tsx}'], \t\textends: [...typescript.configs.recommendedTypeChecked, react], \t\tsettings: { \t\t\treact: { @@ -143,6 +143,11 @@ private Consumer patchEslintConfig(JHipsterModuleProperti regex("[ \\t]+quotes: \\['error', 'single', \\{ avoidEscape: true }],"), """ \t\t\t'react/react-in-jsx-scope': 'off', + \t\t\t'@typescript-eslint/no-redundant-type-constituents': '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-unsafe-call': 'off', \t\t\t'@typescript-eslint/no-misused-promises': [ \t\t\t\t'error', \t\t\t\t{ diff --git a/src/main/java/tech/jhipster/lite/generator/client/react/i18n/domain/ReactI18nModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/client/react/i18n/domain/ReactI18nModuleFactory.java index 59d68cd6879..6243dc7f596 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/react/i18n/domain/ReactI18nModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/client/react/i18n/domain/ReactI18nModuleFactory.java @@ -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'), }; }, })); diff --git a/src/main/resources/generator/client/react/security/jwt/src/test/webapp/unit/login/primary/loginForm/index.test.tsx.mustache b/src/main/resources/generator/client/react/security/jwt/src/test/webapp/unit/login/primary/loginForm/index.test.tsx.mustache index 513c72e1621..3cac8855967 100644 --- a/src/main/resources/generator/client/react/security/jwt/src/test/webapp/unit/login/primary/loginForm/index.test.tsx.mustache +++ b/src/main/resources/generator/client/react/security/jwt/src/test/webapp/unit/login/primary/loginForm/index.test.tsx.mustache @@ -14,7 +14,7 @@ const login = async () => { const { getByText, getByPlaceholderText, getByTestId } = render(); const loginButton = getByText('Log in'); fireEvent.click(loginButton); - await act(async () => { + await act(() => { fireEvent.change(getByPlaceholderText("Nom d'utilisateur"), { target: { value: 'admin' }, }); @@ -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); }); }); diff --git a/src/main/resources/generator/client/react/security/jwt/src/test/webapp/unit/login/primary/loginModal/index.test.tsx.mustache b/src/main/resources/generator/client/react/security/jwt/src/test/webapp/unit/login/primary/loginModal/index.test.tsx.mustache index 0bfd9b2e3fb..e7d2756581c 100644 --- a/src/main/resources/generator/client/react/security/jwt/src/test/webapp/unit/login/primary/loginModal/index.test.tsx.mustache +++ b/src/main/resources/generator/client/react/security/jwt/src/test/webapp/unit/login/primary/loginModal/index.test.tsx.mustache @@ -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); }); @@ -54,7 +54,7 @@ describe('test login modal', () => { const { getByPlaceholderText, getByTestId } = LoginModalRender(true); const spy = vi.spyOn(axios, 'post'); spy.mockImplementationOnce((): Promise => Promise.resolve({ data: {} })); - await act(async () => { + await act(() => { fireEvent.change(getByPlaceholderText("Nom d'utilisateur"), { target: { value: 'admin' }, }); @@ -71,7 +71,7 @@ describe('test login modal', () => { const { getByPlaceholderText, getByRole } = LoginModalRender(true); const spy = vi.spyOn(axios, 'post'); spy.mockImplementationOnce((): Promise => Promise.resolve({ data: {} })); - await act(async () => { + await act(() => { fireEvent.change(getByPlaceholderText("Nom d'utilisateur"), { target: { value: 'admin' }, }); @@ -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); }); diff --git a/src/main/resources/generator/typescript/tsconfig.json b/src/main/resources/generator/typescript/tsconfig.json index 83bccfee785..e64273841ef 100644 --- a/src/main/resources/generator/typescript/tsconfig.json +++ b/src/main/resources/generator/typescript/tsconfig.json @@ -7,5 +7,5 @@ "@/*": ["src/main/webapp/app/*"] } }, - "include": ["src/main/webapp/**/*", "src/test/webapp/unit/**/*"] + "include": ["src/main/webapp/**/*", "src/test/webapp/**/*"] } diff --git a/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.eslint.config.js.approved.txt b/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.eslint.config.js.approved.txt index e8134c13e44..062024d8663 100644 --- a/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.eslint.config.js.approved.txt +++ b/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.eslint.config.js.approved.txt @@ -16,7 +16,7 @@ export default typescript.config( }, js.configs.recommended, { - files: ['src/main/webapp/**/*.{ts,tsx}', 'src/main/webapp/**/*.spec.ts'], + files: ['src/*/webapp/**/*.{ts,tsx}'], extends: [...typescript.configs.recommendedTypeChecked, react], settings: { react: { @@ -31,6 +31,11 @@ export default typescript.config( }, rules: { 'react/react-in-jsx-scope': 'off', + '@typescript-eslint/no-redundant-type-constituents': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/await-thenable': 'off', + '@typescript-eslint/no-unsafe-call': 'off', '@typescript-eslint/no-misused-promises': [ 'error', { diff --git a/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.tsconfig.json.approved.txt b/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.tsconfig.json.approved.txt index 480eede51b5..1ca1cf2ad44 100644 --- a/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.tsconfig.json.approved.txt +++ b/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.tsconfig.json.approved.txt @@ -11,5 +11,5 @@ "@assets/*": ["src/main/webapp/assets/*"] } }, - "include": ["src/main/webapp/**/*", "src/test/webapp/unit/**/*"] + "include": ["src/main/webapp/**/*", "src/test/webapp/**/*"] } diff --git a/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.tsconfig.json.approved.txt b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.tsconfig.json.approved.txt index 6bef65ee0e8..a462a452632 100644 --- a/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.tsconfig.json.approved.txt +++ b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.tsconfig.json.approved.txt @@ -9,5 +9,5 @@ "@/*": ["src/main/webapp/app/*"] } }, - "include": ["src/main/webapp/**/*", "src/test/webapp/unit/**/*"] + "include": ["src/main/webapp/**/*", "src/test/webapp/**/*"] }