From 4faa44984f5461eb58733f9d6d5da6ba2fc02a71 Mon Sep 17 00:00:00 2001 From: Max Reichmann Date: Mon, 5 Aug 2024 17:48:52 +0200 Subject: [PATCH] [INTERNAL] Add common + specific ESLint configs + Update deps to newer version --- .eslintignore | 16 ------- .eslintrc.cjs | 86 ----------------------------------- eslint.common.config.js | 99 +++++++++++++++++++++++++++++++++++++++++ eslint.config.js | 12 +++++ package-lock.json | 34 +++++++++----- package.json | 4 +- 6 files changed, 138 insertions(+), 113 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.cjs create mode 100644 eslint.common.config.js create mode 100644 eslint.config.js diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 1b110a17..00000000 --- a/.eslintignore +++ /dev/null @@ -1,16 +0,0 @@ -# /node_modules/* and /bower_components/* ignored by default - -# Ignore test runner static resources -lib/middleware/testRunner/ - -# Exclude coverage folder -coverage/ - -# Exclude test files -test/tmp/ -test/expected/ -test/fixtures/ - -# Exlucde JSDoc output -docs/ -jsdocs/ diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index ff7ac6fa..00000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,86 +0,0 @@ -module.exports = { - "parserOptions": { - "sourceType": "module", - }, - "env": { - "node": true, - "es2023": true - }, - "extends": ["eslint:recommended", "plugin:ava/recommended", "google"], - "plugins": [ - "jsdoc", - "ava" - ], - "rules": { - "indent": [ - "error", - "tab" - ], - "linebreak-style": [ - "error", - "unix" - ], - "quotes": [ - "error", - "double", - {"allowTemplateLiterals": true} - ], - "semi": [ - "error", - "always" - ], - "no-negated-condition": "off", - "require-jsdoc": "off", - "no-mixed-requires": "off", - "max-len": [ - "error", - { - "code": 120, - "ignoreUrls": true, - "ignoreRegExpLiterals": true - } - ], - "no-implicit-coercion": [ - 2, - {"allow": ["!!"]} - ], - "comma-dangle": "off", - "no-tabs": "off", - "valid-jsdoc": 0, - // jsdoc/check-examples is temporarily set to "warn" as the rule causes issues in our CI - // See: https://github.com/gajus/eslint-plugin-jsdoc/issues/508 - // Starting with ESLint v8, it needs to be disabled as it currently can't be supported - // See: https://github.com/eslint/eslint/issues/14745 - "jsdoc/check-examples": 0, - "jsdoc/check-param-names": 2, - "jsdoc/check-tag-names": 2, - "jsdoc/check-types": 2, - "jsdoc/no-undefined-types": 0, - "jsdoc/require-description": 0, - "jsdoc/require-description-complete-sentence": 0, - "jsdoc/require-example": 0, - "jsdoc/require-hyphen-before-param-description": 0, - "jsdoc/require-param": 2, - "jsdoc/require-param-description": 0, - "jsdoc/require-param-name": 2, - "jsdoc/require-param-type": 2, - "jsdoc/require-returns": 0, - "jsdoc/require-returns-description": 0, - "jsdoc/require-returns-type": 2, - "jsdoc/tag-lines": [2, "any", {"startLines": 1}], - "jsdoc/valid-types": 0, - // ava/assertion-arguments reports concatenated strings in a assertion message as an issue - // See: https://github.com/avajs/eslint-plugin-ava/issues/332 - "ava/assertion-arguments": 0 - }, - "settings": { - "jsdoc": { - "mode": "jsdoc", - "tagNamePreference": { - "return": "returns", - "augments": "extends" - } - } - }, - "root": true -}; diff --git a/eslint.common.config.js b/eslint.common.config.js new file mode 100644 index 00000000..07876d52 --- /dev/null +++ b/eslint.common.config.js @@ -0,0 +1,99 @@ +import jsdoc from "eslint-plugin-jsdoc"; +import ava from "eslint-plugin-ava"; +import globals from "globals"; +import js from "@eslint/js"; +import google from "eslint-config-google"; + +export default [{ + ignores: [ // Common ignore patterns across all tooling repos + "**/coverage/", + "test/tmp/", + "test/expected/", + "test/fixtures/", + "**/docs/", + "**/jsdocs/", + ], +}, js.configs.recommended, google, ava.configs["flat/recommended"], { + name: "Common ESLint config used for all tooling repos", + + plugins: { + jsdoc, + }, + + languageOptions: { + globals: { + ...globals.node, + }, + + ecmaVersion: 2023, + sourceType: "module", + }, + + settings: { + jsdoc: { + mode: "jsdoc", + + tagNamePreference: { + return: "returns", + augments: "extends", + }, + }, + }, + + rules: { + "indent": ["error", "tab"], + "linebreak-style": ["error", "unix"], + + "quotes": ["error", "double", { + allowTemplateLiterals: true, + }], + + "semi": ["error", "always"], + "no-negated-condition": "off", + "require-jsdoc": "off", + "no-mixed-requires": "off", + + "max-len": ["error", { + code: 120, + ignoreUrls: true, + ignoreRegExpLiterals: true, + }], + + "no-implicit-coercion": [2, { + allow: ["!!"], + }], + + "comma-dangle": "off", + "no-tabs": "off", + "no-console": 2, // Disallow console.log() + "no-eval": 2, + // The following rule must be disabled as of ESLint 9. + // It's removed and causes issues when present + // https://eslint.org/docs/latest/rules/valid-jsdoc + "valid-jsdoc": 0, + "jsdoc/check-examples": 0, + "jsdoc/check-param-names": 2, + "jsdoc/check-tag-names": 2, + "jsdoc/check-types": 2, + "jsdoc/no-undefined-types": 0, + "jsdoc/require-description": 0, + "jsdoc/require-description-complete-sentence": 0, + "jsdoc/require-example": 0, + "jsdoc/require-hyphen-before-param-description": 0, + "jsdoc/require-param": 2, + "jsdoc/require-param-description": 0, + "jsdoc/require-param-name": 2, + "jsdoc/require-param-type": 2, + "jsdoc/require-returns": 0, + "jsdoc/require-returns-description": 0, + "jsdoc/require-returns-type": 2, + + "jsdoc/tag-lines": [2, "any", { + startLines: 1, + }], + + "jsdoc/valid-types": 0, + "ava/assertion-arguments": 0, + }, +} +]; diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..a277a372 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,12 @@ +import eslintCommonConfig from "./eslint.common.config.js"; + +export default [ + ...eslintCommonConfig, // Load common ESLint config + { + // Add project-specific ESLint config rules here + // in order to override common config + ignores: [ + "lib/middleware/testRunner/", + ] + } +]; diff --git a/package-lock.json b/package-lock.json index 33e4bad4..2f6af18b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "yesno": "^0.4.0" }, "devDependencies": { + "@eslint/js": "^9.8.0", "@istanbuljs/esm-loader-hook": "^0.2.0", "@ui5/project": "^4.0.2", "ava": "^6.1.3", @@ -39,9 +40,10 @@ "docdash": "^2.0.2", "eslint": "^9.8.0", "eslint-config-google": "^0.14.0", - "eslint-plugin-ava": "^14.0.0", + "eslint-plugin-ava": "^15.0.1", "eslint-plugin-jsdoc": "^48.11.0", "esmock": "^2.6.7", + "globals": "^15.9.0", "jsdoc": "^4.0.3", "nyc": "^17.0.0", "open-cli": "^8.0.0", @@ -308,6 +310,15 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/types": { "version": "7.25.2", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.2.tgz", @@ -3932,9 +3943,9 @@ } }, "node_modules/eslint-plugin-ava": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-ava/-/eslint-plugin-ava-14.0.0.tgz", - "integrity": "sha512-XmKT6hppaipwwnLVwwvQliSU6AF1QMHiNoLD5JQfzhUhf0jY7CO0O624fQrE+Y/fTb9vbW8r77nKf7M/oHulxw==", + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-ava/-/eslint-plugin-ava-15.0.1.tgz", + "integrity": "sha512-eRX7mLFPvalGDWztJ4zm+anez2X6J/88r9CqLFfPAIMvFlGyJ+dUoFppoohgUQZLV09mIBNz5guP07zFJOLF8g==", "dev": true, "dependencies": { "enhance-visitors": "^1.0.0", @@ -3947,10 +3958,10 @@ "resolve-from": "^5.0.0" }, "engines": { - "node": ">=14.17 <15 || >=16.4" + "node": "^18.18 || >=20" }, "peerDependencies": { - "eslint": ">=8.26.0" + "eslint": ">=9" } }, "node_modules/eslint-plugin-ava/node_modules/espree": { @@ -5093,12 +5104,15 @@ } }, "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "version": "15.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.9.0.tgz", + "integrity": "sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==", "dev": true, "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globby": { diff --git a/package.json b/package.json index 7c1a01d5..fb7ea896 100644 --- a/package.json +++ b/package.json @@ -138,6 +138,7 @@ "yesno": "^0.4.0" }, "devDependencies": { + "@eslint/js": "^9.8.0", "@istanbuljs/esm-loader-hook": "^0.2.0", "@ui5/project": "^4.0.2", "ava": "^6.1.3", @@ -147,9 +148,10 @@ "docdash": "^2.0.2", "eslint": "^9.8.0", "eslint-config-google": "^0.14.0", - "eslint-plugin-ava": "^14.0.0", + "eslint-plugin-ava": "^15.0.1", "eslint-plugin-jsdoc": "^48.11.0", "esmock": "^2.6.7", + "globals": "^15.9.0", "jsdoc": "^4.0.3", "nyc": "^17.0.0", "open-cli": "^8.0.0",