From 9b9ae5adf7bbbb6cb3c4846bff3617a1e7545672 Mon Sep 17 00:00:00 2001 From: Merlin Beutlberger Date: Fri, 27 Sep 2024 09:09:23 +0200 Subject: [PATCH] refactor(config): Minor cleanups in config files (#322) --- .editorconfig | 2 +- ava.config.js | 15 +- eslint.config.js | 7 +- npm-shrinkwrap.json | 226 +++++++++++++++++- package.json | 2 +- .../amdTranspiler/parseModuleDeclaration.ts | 1 + test/lib/utils/configManager.ts | 6 +- 7 files changed, 240 insertions(+), 19 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9f0c5fdce..28e01952c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,7 +12,7 @@ end_of_line = lf indent_size = 4 insert_final_newline = true -[*.{css,html,js,cjs,mjs,jsx,ts,tsx,less,txt,json,yml,md}] +[*.{css,html,js,cjs,mjs,jsx,ts,cts,mts,tsx,less,txt,json,yml,md}] trim_trailing_whitespace = true end_of_line = lf indent_size = 4 diff --git a/ava.config.js b/ava.config.js index e864378d9..4e4059f8c 100644 --- a/ava.config.js +++ b/ava.config.js @@ -1,15 +1,8 @@ -import {satisfies} from "semver"; -import process from "node:process"; - // Calculate nodeArguments based on the Node version -const nodeArguments = []; -if (satisfies(process.versions.node, "< 18.19.0")) { - nodeArguments.push("--loader=tsx/esm"); - nodeArguments.push("--loader=esmock"); -} else { - nodeArguments.push("--import=tsx/esm"); -} -nodeArguments.push("--no-warnings=ExperimentalWarning"); +const nodeArguments = [ + "--import=tsx/esm", + "--no-warnings=ExperimentalWarning", +]; export default { extensions: { diff --git a/eslint.config.js b/eslint.config.js index e9d2f04a8..e19a3e8c4 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,6 +1,7 @@ import eslint from "@eslint/js"; import tseslint from "typescript-eslint"; import stylistic from "@stylistic/eslint-plugin"; +import ava from "eslint-plugin-ava"; export default tseslint.config( { @@ -33,7 +34,8 @@ export default tseslint.config( arrowParens: true, braceStyle: "1tbs", blockSpacing: false, - }), { + }), + ava.configs["flat/recommended"], { // Lint all JS files using the eslint parser files: ["**/*.js"], languageOptions: { @@ -117,10 +119,11 @@ export default tseslint.config( }, ], "no-implicit-coercion": [ - 2, + "error", {allow: ["!!"]}, ], "no-console": "error", + "no-eval": "error", }, } ); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 0e89c0f41..0c1108bb6 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -47,12 +47,12 @@ "ava": "^6.1.3", "depcheck": "^1.4.7", "eslint": "^9.11.1", + "eslint-plugin-ava": "^15.0.1", "esmock": "^2.6.7", "husky": "^9.1.6", "licensee": "^11.1.0", "nyc": "^17.1.0", "rimraf": "^6.0.1", - "semver": "^7.6.3", "sinon": "^19.0.2", "tsx": "^4.19.1", "typescript-eslint": "^8.7.0", @@ -5666,6 +5666,19 @@ "iconv-lite": "^0.6.2" } }, + "node_modules/enhance-visitors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/enhance-visitors/-/enhance-visitors-1.0.0.tgz", + "integrity": "sha512-+29eJLiUixTEDRaZ35Vu8jP3gPLNcQQkQkOQjLp2X+6cZGGPDD/uasbFzvLsJKnGZnvmyZ0srxudwOtskHeIDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash": "^4.13.1" + }, + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", @@ -5858,6 +5871,161 @@ } } }, + "node_modules/eslint-plugin-ava": { + "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, + "license": "MIT", + "dependencies": { + "enhance-visitors": "^1.0.0", + "eslint-utils": "^3.0.0", + "espree": "^9.0.0", + "espurify": "^2.1.1", + "import-modules": "^2.1.0", + "micro-spelling-correcter": "^1.1.1", + "pkg-dir": "^5.0.0", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": "^18.18 || >=20" + }, + "peerDependencies": { + "eslint": ">=9" + } + }, + "node_modules/eslint-plugin-ava/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-plugin-ava/node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-plugin-ava/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-ava/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-ava/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-ava/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-ava/node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint-plugin-ava/node_modules/pkg-dir": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-5.0.0.tgz", + "integrity": "sha512-NPE8TDbzl/3YQYY7CSS228s3g2ollTFnc+Qi3tqmqJp9Vg2ovUpixcJEo2HJScN2Ez+kEaal6y70c0ehqJBJeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^5.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint-plugin-ava/node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/eslint-scope": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.2.tgz", @@ -5874,6 +6042,35 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^2.0.0" + }, + "engines": { + "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=5" + } + }, + "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=10" + } + }, "node_modules/eslint-visitor-keys": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", @@ -6133,6 +6330,13 @@ "node": ">=4" } }, + "node_modules/espurify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/espurify/-/espurify-2.1.1.tgz", + "integrity": "sha512-zttWvnkhcDyGOhSH4vO2qCBILpdCMv/MX8lp4cqgRkQoDRGK2oZxi2GfWhlP2dIXmk7BaKeOTuzbHhyC68o8XQ==", + "dev": true, + "license": "MIT" + }, "node_modules/esquery": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", @@ -7103,6 +7307,19 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/import-modules": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/import-modules/-/import-modules-2.1.0.tgz", + "integrity": "sha512-8HEWcnkbGpovH9yInoisxaSoIg9Brbul+Ju3Kqe2UsYDUBJD/iQjSgEj0zPcTDPKfPp2fs5xlv1i+JSye/m1/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -8149,6 +8366,13 @@ "node": ">= 8" } }, + "node_modules/micro-spelling-correcter": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/micro-spelling-correcter/-/micro-spelling-correcter-1.1.1.tgz", + "integrity": "sha512-lkJ3Rj/mtjlRcHk6YyCbvZhyWTOzdBvTHsxMmZSk5jxN1YyVSQ+JETAom55mdzfcyDrY/49Z7UCW760BK30crg==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", diff --git a/package.json b/package.json index 881e64457..d67d41d3e 100644 --- a/package.json +++ b/package.json @@ -93,12 +93,12 @@ "ava": "^6.1.3", "depcheck": "^1.4.7", "eslint": "^9.11.1", + "eslint-plugin-ava": "^15.0.1", "esmock": "^2.6.7", "husky": "^9.1.6", "licensee": "^11.1.0", "nyc": "^17.1.0", "rimraf": "^6.0.1", - "semver": "^7.6.3", "sinon": "^19.0.2", "tsx": "^4.19.1", "typescript-eslint": "^8.7.0", diff --git a/test/lib/linter/amdTranspiler/parseModuleDeclaration.ts b/test/lib/linter/amdTranspiler/parseModuleDeclaration.ts index a53b24908..0ebf685ef 100644 --- a/test/lib/linter/amdTranspiler/parseModuleDeclaration.ts +++ b/test/lib/linter/amdTranspiler/parseModuleDeclaration.ts @@ -206,6 +206,7 @@ test("All combinations", (t) => { permutations.forEach(({args, expected}) => { // Omit any parameters with "kind" set to null const res = _matchArgumentsToParameters(args.filter((_) => _?.kind)); + // eslint-disable-next-line ava/assertion-arguments -- https://github.com/avajs/eslint-plugin-ava/issues/332 t.deepEqual( resolveSyntaxKind(res), resolveSyntaxKind(expected), diff --git a/test/lib/utils/configManager.ts b/test/lib/utils/configManager.ts index 2c15fa174..2ecc0e6ed 100644 --- a/test/lib/utils/configManager.ts +++ b/test/lib/utils/configManager.ts @@ -16,8 +16,8 @@ test("Check config file", async (t) => { t.deepEqual(config, { ignores: [ - "!test/sap/m/visual/Magician.spec.js", - "test/**/*", + "webapp/test/**/*", + "!webapp/test/integration/opaTests.qunit.js", ], }, "The configuration is derived from the provided custom config file"); }); @@ -51,7 +51,7 @@ test("Resolves to an empty config if default module is not found", async (t) => t.deepEqual(config, {}, "An empty configuration gets returned"); }); -test.only("Check config file with absolute path", async (t) => { +test("Check config file with absolute path", async (t) => { const confManager = new ConfigManager( path.join(fixturesProjectsPath, "com.ui5.troublesome.app"), "ui5lint-custom.config.cjs");