From 890019a759e23ab8c51f80c7b4ffa45803cfe42b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giancarlo=20Calder=C3=B3n=20C=C3=A1rdenas?= Date: Mon, 21 Oct 2024 08:14:48 -0500 Subject: [PATCH] chore(deps): upgrade ESLint to v9 (#200) Co-authored-by: Timothy Jones --- .eslintrc | 49 ---------------------------------- eslint.config.mjs | 67 +++++++++++++++++++++++++++++++++++++++++++++++ index.js | 1 + package.json | 14 +++++----- 4 files changed, 76 insertions(+), 55 deletions(-) delete mode 100644 .eslintrc create mode 100644 eslint.config.mjs diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index e520a06f2..000000000 --- a/.eslintrc +++ /dev/null @@ -1,49 +0,0 @@ -{ - "extends": [ - "prettier", - "eslint:recommended" - ], - "env": { - "node": true, - "es6": true - }, - "overrides": [ - { - "env": { - "node": true, - "es6": true, - "jest/globals": true - }, - "files": [ - "test/**" - ], - "plugins": [ - "jest" - ], - "extends": [ - "prettier", - "eslint:recommended", - "plugin:jest/recommended" - ], - "rules": { - "jest/prefer-expect-assertions": "off", - "jest/expect-expect": "off" - } - } - ], - "parserOptions": { - "ecmaVersion": 2023 - }, - "plugins": [ - "jest" - ], - "rules": { - "no-var": "error", - "no-unused-vars": [ - "error", - { - "argsIgnorePattern": "_.*" - } - ] - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..98c4b7da0 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,67 @@ +import globals from "globals"; +import js from "@eslint/js"; +import jest from "eslint-plugin-jest"; +import eslintConfigPrettier from "eslint-config-prettier"; + +/** + * @type {import("eslint").Linter.Config} + */ +export default [ + { + "ignores": [".git/", ".github/", ".husky/", ".scannerwork/", ".vscode/", "coverage/", "node_modules/"], + "name": "Files to ignore" + }, + { + ...eslintConfigPrettier, + "name": "Prettier" + }, + { + ...js.configs.recommended, + "files": ["**/*.{js,cjs,mjs}"], + "languageOptions": { + "ecmaVersion": 2023 + }, + "name": "JavaScript files", + "rules": { + ...js.configs.recommended.rules, + "no-var": "error", + "no-unused-vars": [ + "error", + { + "argsIgnorePattern": "_.*" + } + ] + } + }, + { + "files": ["**/*.mjs"], + "languageOptions": { + "sourceType": "module" + }, + "name": "JavaScript modules" + }, + { + "files": ["**/*.{js,cjs,mjs}"], + "languageOptions": { + "globals": { + ...globals.node + } + }, + "name": "Node.js files" + }, + { + ...jest.configs["flat/recommended"], + "files": ["test/**/*{spec,test}.{js,cjs,mjs}", "test/mocks/jest-mocks.js"], + "languageOptions": { + "globals": { + ...globals.jest + } + }, + "name": "Test files", + "rules": { + ...jest.configs["flat/recommended"].rules, + "jest/prefer-expect-assertions": "off", + "jest/expect-expect": "off" + } + } +]; diff --git a/index.js b/index.js index ecb193458..c05ff8d61 100755 --- a/index.js +++ b/index.js @@ -69,6 +69,7 @@ module.exports = async function standardVersion(argv) { : false, }; break; + // eslint-disable-next-line no-unused-vars } catch (err) { /* This probably shouldn't be empty? */ } diff --git a/package.json b/package.json index a24a634b6..4f7a56c3e 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,9 @@ "description": "replacement for `npm version` with automatic CHANGELOG generation", "bin": "bin/cli.js", "scripts": { - "fix": "eslint . --fix", - "posttest": "eslint . && npm run format:check", + "eslint": "eslint .", + "eslint:fix": "npm run eslint -- --fix", + "posttest": "npm run eslint && npm run format:check", "format:base": "prettier \"./**/*.{ts,js}\"", "format:fix": "npm run format:base -- --write", "format:check": "npm run format:base -- --check", @@ -56,12 +57,13 @@ "yargs": "^17.7.2" }, "devDependencies": { - "eslint": "^8.57.1", + "@eslint/js": "^9.13.0", + "eslint": "^9.13.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.31.0", - "eslint-plugin-jest": "^27.9.0", - "eslint-plugin-n": "^15.7.0", - "eslint-plugin-promise": "^6.6.0", + "eslint-plugin-jest": "^28.8.3", + "eslint-plugin-n": "^17.11.1", + "eslint-plugin-promise": "^7.1.0", "jest": "^29.7.0", "jest-serial-runner": "^1.2.1", "prettier": "^3.3.3",