Skip to content

Commit

Permalink
Merge pull request #10598 from qmonmert/eslint990
Browse files Browse the repository at this point in the history
ESLint 9
  • Loading branch information
murdos authored Sep 2, 2024
2 parents b7faf51 + ae9ee34 commit 6f77e5a
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.addDevDependency(packageName("@typescript-eslint/eslint-plugin"), COMMON)
.addDevDependency(packageName("@vitejs/plugin-react"), REACT)
.addDevDependency(packageName("@vitest/coverage-istanbul"), COMMON)
.addDevDependency(packageName("typescript-eslint"), COMMON)
.addDevDependency(packageName("globals"), COMMON)
.addDevDependency(packageName("eslint"), COMMON)
.addDevDependency(packageName("eslint-plugin-react"), REACT)
.addDevDependency(packageName("jsdom"), COMMON)
Expand All @@ -61,7 +63,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.addScript(scriptKey("build"), scriptCommand("tsc && vite build --emptyOutDir"))
.addScript(scriptKey("preview"), scriptCommand("vite preview"))
.addScript(scriptKey("start"), scriptCommand("vite"))
.addScript(scriptKey("lint"), scriptCommand("eslint --ext .js,.ts,.tsx src/"))
.addScript(scriptKey("lint"), scriptCommand("eslint ."))
.addScript(scriptKey("tsc:watch"), scriptCommand("tsc --noEmit --watch"))
.addScript(scriptKey("test"), scriptCommand("npm run test:watch"))
.addScript(scriptKey("test:coverage"), scriptCommand("vitest run --coverage"))
Expand All @@ -72,10 +74,9 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.addFile("tsconfig.json")
.addTemplate("vite.config.ts")
.addTemplate("vitest.config.ts")
.addFile(".eslintrc.cjs")
.addTemplate("eslint.config.js")
.and()
.batch(SOURCE_COMMON, to("."))
.addFile(".eslintignore")
.addFile(".npmrc")
.and()
.batch(APP_SOURCE, APP_DESTINATION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public JHipsterModule buildVueModule(JHipsterModuleProperties properties) {
.addDependency(packageName("vue-router"), VUE)
.addDevDependency(packageName("@typescript-eslint/parser"), COMMON)
.addDevDependency(packageName("@vitejs/plugin-vue"), VUE)
.addDevDependency(packageName("@vue/eslint-config-typescript"), VUE)
.addDevDependency(packageName("typescript-eslint"), COMMON)
.addDevDependency(packageName("globals"), COMMON)
.addDevDependency(packageName("@vue/test-utils"), VUE)
.addDevDependency(packageName("@vue/tsconfig"), VUE)
.addDevDependency(packageName("@vitest/coverage-istanbul"), COMMON)
Expand All @@ -74,7 +75,7 @@ public JHipsterModule buildVueModule(JHipsterModuleProperties properties) {
.addDevDependency(packageName("sinon"), VUE)
.addScript(scriptKey("build"), scriptCommand("vue-tsc -p tsconfig.build.json --noEmit && vite build --emptyOutDir"))
.addScript(scriptKey("dev"), scriptCommand("vite"))
.addScript(scriptKey("lint"), scriptCommand("eslint --ext .js,.ts,.vue src/"))
.addScript(scriptKey("lint"), scriptCommand("eslint ."))
.addScript(scriptKey("preview"), scriptCommand("vite preview"))
.addScript(scriptKey("start"), scriptCommand("vite"))
.addScript(scriptKey("tsc:watch"), scriptCommand("vue-tsc -p tsconfig.build.json --noEmit --watch"))
Expand All @@ -83,7 +84,7 @@ public JHipsterModule buildVueModule(JHipsterModuleProperties properties) {
.addScript(scriptKey("test:watch"), scriptCommand("vitest --"))
.and()
.files()
.add(SOURCE.file(".eslintrc.cjs"), to(".eslintrc.cjs"))
.add(SOURCE.template("eslint.config.js.mustache"), to("eslint.config.js"))
.add(SOURCE.file("tsconfig.json"), to("tsconfig.json"))
.add(SOURCE.file("tsconfig.build.json"), to("tsconfig.build.json"))
.add(SOURCE.template("webapp/app/http/AxiosHttp.ts.mustache"), MAIN_DESTINATION.append("http/AxiosHttp.ts"))
Expand All @@ -92,7 +93,6 @@ public JHipsterModule buildVueModule(JHipsterModuleProperties properties) {
.addTemplate("vitest.config.ts")
.and()
.batch(SOURCE_COMMON, to("."))
.addFile(".eslintignore")
.addFile(".npmrc")
.and()
.batch(SOURCE.file("test/unit/http"), to("src/test/webapp/unit/http"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.addDevDependency(packageName("@vitest/coverage-istanbul"), COMMON)
.addDevDependency(packageName("eslint"), COMMON)
.addDevDependency(packageName("eslint-config-prettier"), COMMON)
.addDevDependency(packageName("eslint-import-resolver-typescript"), COMMON)
.addDevDependency(packageName("eslint-plugin-import"), COMMON)
.addDevDependency(packageName("eslint-plugin-import-x"), COMMON)
.addDevDependency(packageName("globals"), COMMON)
.addDevDependency(packageName("typescript-eslint"), COMMON)
.addDevDependency(packageName("vite-tsconfig-paths"), COMMON)
.addDevDependency(packageName("vitest"), COMMON)
.addDevDependency(packageName("vitest-sonar-reporter"), COMMON)
.addScript(scriptKey("lint"), scriptCommand("eslint --ext .js,.ts,.tsx src/"))
.addScript(scriptKey("lint"), scriptCommand("eslint ."))
.addScript(scriptKey("test"), scriptCommand("npm run test:watch"))
.addScript(scriptKey("test:coverage"), scriptCommand("vitest run --coverage"))
.addScript(scriptKey("test:watch"), scriptCommand("vitest --"))
Expand All @@ -41,7 +42,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.batch(SOURCE, to("."))
.addFile("tsconfig.json")
.addTemplate("vitest.config.ts")
.addFile(".eslintrc.cjs")
.addTemplate("eslint.config.js")
.and()
.and()
.build();
Expand Down
24 changes: 0 additions & 24 deletions src/main/resources/generator/client/react/core/.eslintrc.cjs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import globals from 'globals';
import typescript from 'typescript-eslint';
import eslint from '@eslint/js';
import react from 'eslint-plugin-react/configs/recommended.js';

export default typescript.config(
{
languageOptions: {
globals: {
...globals.node,
},
},
},
{
ignores: ['{{projectBuildDirectory}}/'],
},
eslint.configs.recommended,
{
files: ['src/main/webapp/**/*.{ts,tsx}', 'src/main/webapp/**/*.spec.ts'],
extends: [...typescript.configs.recommendedTypeChecked, react],
settings: {
react: {
version: 'detect',
},
},
languageOptions: {
globals: {
...globals.browser,
},
parserOptions: {
project: ['./tsconfig.json'],
},
},
rules: {
'react/react-in-jsx-scope': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
},
},
);
13 changes: 0 additions & 13 deletions src/main/resources/generator/client/vue/.eslintrc.cjs

This file was deleted.

40 changes: 40 additions & 0 deletions src/main/resources/generator/client/vue/eslint.config.js.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import globals from 'globals';
import typescript from 'typescript-eslint';
import js from '@eslint/js';
import vue from 'eslint-plugin-vue';

export default typescript.config(
{
languageOptions: {
globals: {
...globals.node,
},
},
},
{
ignores: ['{{projectBuildDirectory}}/'],
},
js.configs.recommended,
...typescript.configs.recommended.map(config => (config.name === 'typescript-eslint/base' ? config : { ...config, files: ['**/*.ts'] })),
...vue.configs['flat/recommended'],
{
files: ['**/*.vue'],
languageOptions: {
parserOptions: { parser: '@typescript-eslint/parser' },
globals: { ...globals.browser },
},
},
{
files: ['src/*/webapp/**/*.vue', 'src/*/webapp/**/*.ts'],
languageOptions: {
globals: { ...globals.browser },
},
rules: {
quotes: ['error', 'single', { avoidEscape: true }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'vue/html-self-closing': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
},
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare module '*.vue' {
import { DefineComponent } from 'vue';
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>;
export default component;
}
11 changes: 6 additions & 5 deletions src/main/resources/generator/dependencies/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
"@tsconfig/recommended": "1.0.7",
"@types/jest": "29.5.12",
"@types/node": "20.16.2",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"@typescript-eslint/eslint-plugin": "8.1.0",
"@typescript-eslint/parser": "8.1.0",
"@vitest/coverage-istanbul": "2.0.5",
"autoprefixer": "10.4.20",
"browser-sync": "3.0.2",
"cssnano": "7.0.5",
"cypress": "13.14.1",
"eslint": "8.57.0",
"eslint": "9.9.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "3.6.3",
"eslint-plugin-cypress": "3.5.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-import-x": "4.1.0",
"globals": "15.9.0",
"husky": "9.1.5",
"jasmine-core": "5.2.0",
"jest": "29.7.0",
Expand All @@ -49,6 +49,7 @@
"tailwindcss": "3.4.10",
"ts-jest": "29.2.5",
"typescript": "5.5.4",
"typescript-eslint": "8.1.0",
"vite": "5.4.2",
"vite-tsconfig-paths": "5.0.1",
"vitest": "2.0.5",
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/generator/dependencies/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@pinia/testing": "0.1.5",
"@types/sinon": "17.0.3",
"@vitejs/plugin-vue": "5.1.3",
"@vue/eslint-config-typescript": "13.0.0",
"@vue/test-utils": "2.4.6",
"@vue/tsconfig": "0.5.1",
"eslint-plugin-vue": "9.27.0",
Expand Down
64 changes: 0 additions & 64 deletions src/main/resources/generator/typescript/.eslintrc.cjs

This file was deleted.

63 changes: 63 additions & 0 deletions src/main/resources/generator/typescript/eslint.config.js.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import js from '@eslint/js';
import imports from 'eslint-plugin-import-x';
import globals from 'globals';
import typescript from 'typescript-eslint';

export default typescript.config(
{
languageOptions: {
globals: {
...globals.node,
},
},
},
{
ignores: [
'{{projectBuildDirectory}}/'
],
},
js.configs.recommended,
...typescript.configs.recommended.map(config => (config.name === 'typescript-eslint/base' ? config : { ...config, files: ['**/*.ts'] })),
{
extends: [imports.flatConfigs.recommended, imports.flatConfigs.typescript],
languageOptions: {
// import plugin does not use ecmaVersion and sourceType from languageOptions object
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
},
rules: {
'import-x/no-unresolved': 'off',
'import-x/order': [
'error',
{
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
'newlines-between': 'always',
},
],
},
},
{
files: ['src/*/webapp/**/*.ts'],
languageOptions: {
globals: { ...globals.browser },
},
rules: {
quotes: ['error', 'single', { avoidEscape: true }],
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
},
],
},
},
);
Loading

0 comments on commit 6f77e5a

Please sign in to comment.