Skip to content

Commit

Permalink
Merge pull request #2259 from vishal423/upgrade-eslint-9x
Browse files Browse the repository at this point in the history
chore: Upgrade EsLint dependencies
  • Loading branch information
vishal423 authored Sep 16, 2024
2 parents 62495b3 + 8422e4c commit 599c476
Show file tree
Hide file tree
Showing 24 changed files with 3,251 additions and 1,855 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install lint-staged
3 changes: 0 additions & 3 deletions cli/jsvelte.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ const { version } = require('../package.json');
const packagePath = dirname(__dirname);

(async () => {
/* eslint-disable import/no-unresolved */
const { runJHipster, done, logger } = await import('generator-jhipster/cli');
/* eslint-disable import/extensions */
const { getLogo } = await import('./logo.js');
const blueprint = 'jsvelte';
runJHipster({
Expand All @@ -21,7 +19,6 @@ const packagePath = dirname(__dirname);
},
printBlueprintLogo: () => {},
printLogo: () => {
/* eslint-disable no-console */
console.log(getLogo());
},
lookups: [{ packagePaths: [packagePath], lookups: ['generators'] }],
Expand Down
2 changes: 0 additions & 2 deletions cli/logo.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import chalk from 'chalk';
/* eslint-disable import/extensions */
import { getPackageJson } from '../generators/util.js';

/* eslint-disable import/prefer-default-export */
export const getLogo = () => `
${chalk.cyan(' .d88888b. .d88888b.')}
${chalk.cyan(' d888888888888b. .d888888888888d')}
Expand Down
47 changes: 47 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ['**/coverage', 'generators/**/templates', '**/node_modules', '**/travis', '**/docs'],
},
...compat.extends('plugin:prettier/recommended'),
{
languageOptions: {
globals: {
...globals.node,
},

ecmaVersion: 'latest',
sourceType: 'module',
},

rules: {
'prettier/prettier': 'error',
'no-use-before-define': [2, 'nofunc'],

'no-unused-vars': [
2,
{
vars: 'local',
args: 'none',
},
],

'no-underscore-dangle': 'off',
'prefer-destructuring': 'off',
'no-multi-assign': 'off',
},
},
];
5 changes: 2 additions & 3 deletions generators/client/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ const svelteFiles = {
base: [
{
templates: [
'.eslintignore',
'.eslintrc.json',
'.npmrc',
'cypress.config.cjs',
'.gitignore.jhi.svelte',
'.prettierignore.jhi.svelte',
'cypress.config.cjs',
'eslint.config.js',
'README.md.jhi.svelte',
{
file: 'package-template.json',
Expand Down
11 changes: 4 additions & 7 deletions generators/client/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable no-param-reassign */
/* eslint-disable import/extensions */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-shadow */
import { lt } from 'semver';

import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';
Expand Down Expand Up @@ -211,6 +206,10 @@ export default class extends ClientGenerator {
);
}
}
if (oldSvelteBlueprintVersion && lt(oldSvelteBlueprintVersion, '1.2.0')) {
this.removeFile(`.eslintrc.json`);
this.removeFile(`.eslintignore`);
}
},
async writingTemplateTask({ application }) {
await this.writeFiles({
Expand Down Expand Up @@ -254,8 +253,6 @@ export default class extends ClientGenerator {
},
async writeEntityFiles({ application, entities }) {
for (const entity of entities.filter(entity => !entity.skipClient && !entity.builtIn)) {
/* eslint-disable no-await-in-loop */
/* eslint-disable no-undef */
await this.writeFiles({
sections: entitySvelteFiles,
context: { ...application, ...entity, swaggerUi: this.swaggerUi, jest: this.jest },
Expand Down
10 changes: 0 additions & 10 deletions generators/client/templates/.eslintignore.ejs

This file was deleted.

35 changes: 0 additions & 35 deletions generators/client/templates/.eslintrc.json.ejs

This file was deleted.

61 changes: 61 additions & 0 deletions generators/client/templates/eslint.config.js.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import svelte from "eslint-plugin-svelte";
import cypress from "eslint-plugin-cypress";
import jestDom from "eslint-plugin-jest-dom";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: [
"**/node_modules/",
"src/main/docker/",
"**/target/",
"**/build/",
"**/node/",
"**/pnpm-lock.yaml",
"**/package-lock.json",
"**/yarn.lock",
],
}, ...compat.extends(
"eslint:recommended",
"plugin:svelte/recommended",
"plugin:cypress/recommended",
"plugin:jest-dom/recommended",
), {
plugins: {
svelte,
cypress,
"jest-dom": jestDom,
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
...cypress.environments.globals.globals,
<%_ if (this.blueprintConfig.jest) { _%>
"jest": true,
<%_ } else { _%>
vi: true,
<%_ } _%>
},

ecmaVersion: 2020,
sourceType: "module",
},

rules: {
"no-unused-vars": "off",
},
}];

13 changes: 7 additions & 6 deletions generators/client/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"@fortawesome/free-solid-svg-icons": "6.6.0"
},
"devDependencies": {
"@eslint/js": "9.10.0",
"@sveltejs/adapter-static": "3.0.4",
"@sveltejs/kit": "2.5.27",
"@testing-library/jest-dom": "6.5.0",
Expand All @@ -12,18 +13,18 @@
"autoprefixer": "10.4.20",
"cypress": "13.5.1",
"esbuild": "0.23.1",
"eslint": "8.57.0",
"eslint-plugin-cypress": "3.2.0",
"eslint": "9.10.0",
"eslint-plugin-cypress": "3.5.0",
"eslint-plugin-jest-dom": "5.4.0",
"eslint-plugin-svelte": "2.39.0",
"eslint-plugin-testing-library": "6.2.2",
"husky": "9.0.11",
"eslint-plugin-svelte": "2.44.0",
"globals": "15.9.0",
"husky": "9.1.5",
"jhipster-svelte-library": "0.12.1",
"postcss": "8.4.45",
"prettier": "3.2.5",
"prettier-plugin-svelte": "3.2.3",
"prettier-plugin-organize-imports": "3.2.4",
"lint-staged": "15.2.9",
"lint-staged": "15.2.10",
"rimraf": "6.0.1",
"svelte": "4.2.19",
"tailwindcss": "3.4.11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
}
function handleFetch(event) {
// eslint-disable-next-line no-extra-semi
;({ page, pageSize, sortPredicate, sortOrder } = event.detail)
fetchUsers()
}
Expand Down
20 changes: 1 addition & 19 deletions generators/common/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,8 @@ const commonFiles = {
templates: ['.editorconfig', '.gitignore', 'README.md', 'sonar-project.properties'],
},
],
// serverFiles: [
// {
// condition: generator => !generator.skipServer,
// templates: ['src/main/resources/banner.txt'],
// },
// ],
commitHooks: [
{
condition: generator => !generator.skipCommitHook,
templates: [
'.lintstagedrc.json',
{
file: 'pre-commit',
renameTo: () => '.husky/pre-commit',
method: 'copy',
},
],
},
],
};

const sharedFiles = {
global: [
{
Expand Down
1 change: 0 additions & 1 deletion generators/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable import/no-unresolved */
import CommonGenerator from 'generator-jhipster/generators/common';
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';

Expand Down
1 change: 1 addition & 0 deletions generators/common/templates/.husky/pre-commit.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install lint-staged
2 changes: 2 additions & 0 deletions generators/common/templates/pre-commit.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npx --no-install lint-staged

1 change: 0 additions & 1 deletion generators/cypress/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-unresolved */
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';

export default class extends BaseApplicationGenerator {
Expand Down
1 change: 0 additions & 1 deletion generators/docker/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-unresolved */
import DockerGenerator from 'generator-jhipster/generators/docker';
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';

Expand Down
1 change: 0 additions & 1 deletion generators/languages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-unresolved */
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';
import LanguagesGenerator from 'generator-jhipster/generators/languages';

Expand Down
1 change: 0 additions & 1 deletion generators/server/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-unresolved */
import ServerGenerator from 'generator-jhipster/generators/server';
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';

Expand Down
1 change: 0 additions & 1 deletion generators/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/prefer-default-export */
import { readFileSync } from 'fs';
import { join } from 'path';
import { fileURLToPath } from 'url';
Expand Down
Loading

0 comments on commit 599c476

Please sign in to comment.