From ba75e46a0644f6746f2bcba48019ae825d2db5d2 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Mon, 28 Aug 2023 22:09:45 +0200 Subject: [PATCH] Various review feedback for ESLint configuration (#204) Co-authored-by: Frederik Prijck --- .eslintrc.json | 29 +++++++------ .prettierrc | 5 +-- jest.config.ts | 5 +-- package-lock.json | 108 ++++++++++++++++++++++++++++++++++++++++++---- package.json | 5 ++- 5 files changed, 122 insertions(+), 30 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 09c8e5e..dd2992c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,24 +1,27 @@ { - "env": { - "node": true, - "commonjs": true, - "es2017": true, - "mocha": true - }, - "ignorePatterns": ["**/*.mjs", "**/*.js"], + "ignorePatterns": ["build", "coverage"], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended-type-checked", "plugin:@typescript-eslint/stylistic-type-checked", + "plugin:import/recommended", + "plugin:import/typescript", "plugin:prettier/recommended" ], - "plugins": ["@typescript-eslint", "import"], + "overrides": [ + { + "files": ["lib/**", "test/**"], + "rules": { + "import/no-default-export": "error" + } + } + ], + "settings": { + "import/resolver": { + "typescript": true + } + }, "parserOptions": { - "ecmaVersion": 9, "project": true - }, - "rules": { - "import/no-default-export": "error", - "import/extensions": ["error", "always"] } } diff --git a/.prettierrc b/.prettierrc index d31e49f..de753c5 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,3 @@ { - "printWidth": 100, - "singleQuote": false - } \ No newline at end of file + "printWidth": 100 +} diff --git a/jest.config.ts b/jest.config.ts index 081468e..9337912 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -8,10 +8,7 @@ const jestConfig: JestConfigWithTsJest = { testMatch: ["**/test/**/*.test.ts", "**/test/tests.ts"], coverageProvider: "v8", coveragePathIgnorePatterns: ["/node_modules/", "./test"], - reporters: [ - "default", - ["jest-junit", { outputDirectory: "test-results/jest" }], - ], + reporters: ["default", ["jest-junit", { outputDirectory: "test-results/jest" }]], coverageReporters: ["lcov", "text", "text-summary"], }; diff --git a/package-lock.json b/package-lock.json index d876ae6..1115b4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,8 +13,9 @@ "@typescript-eslint/parser": "^6.4.1", "browser-sync": "^2.29.3", "concurrently": "^8.2.0", - "eslint": "^8.47.0", + "eslint": "^8.48.0", "eslint-config-prettier": "^9.0.0", + "eslint-import-resolver-typescript": "^3.6.0", "eslint-plugin-import": "^2.28.1", "eslint-plugin-prettier": "^5.0.0", "husky": "^8.0.3", @@ -879,9 +880,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.47.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.47.0.tgz", - "integrity": "sha512-P6omY1zv5MItm93kLM8s2vr1HICJH8v0dvddDhysbIuZ+vcjOHg5Zbkf1mTkcmi2JA9oBG2anOkRnW8WJTS8Og==", + "version": "8.48.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.48.0.tgz", + "integrity": "sha512-ZSjtmelB7IJfWD2Fvb7+Z+ChTIKWq6kjda95fLcQKNS5aheVHn4IkfgRQE3sIIzTcSLwLcLZUD9UBt+V7+h+Pw==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3624,6 +3625,19 @@ } } }, + "node_modules/enhanced-resolve": { + "version": "5.15.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz", + "integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", @@ -3784,15 +3798,15 @@ } }, "node_modules/eslint": { - "version": "8.47.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.47.0.tgz", - "integrity": "sha512-spUQWrdPt+pRVP1TTJLmfRNJJHHZryFmptzcafwSvHsceV81djHOdnEeDmkdotZyLNjDhrOasNK8nikkoG1O8Q==", + "version": "8.48.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.48.0.tgz", + "integrity": "sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "^8.47.0", + "@eslint/js": "8.48.0", "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -3875,6 +3889,54 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/eslint-import-resolver-typescript": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.0.tgz", + "integrity": "sha512-QTHR9ddNnn35RTxlaEnx2gCxqFlF2SEN0SE2d17SqwyM7YOSI2GHWRYp5BiRkObTUNYPupC/3Fq2a0PpT+EKpg==", + "dev": true, + "dependencies": { + "debug": "^4.3.4", + "enhanced-resolve": "^5.12.0", + "eslint-module-utils": "^2.7.4", + "fast-glob": "^3.3.1", + "get-tsconfig": "^4.5.0", + "is-core-module": "^2.11.0", + "is-glob": "^4.0.3" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts/projects/eslint-import-resolver-ts" + }, + "peerDependencies": { + "eslint": "*", + "eslint-plugin-import": "*" + } + }, + "node_modules/eslint-import-resolver-typescript/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/eslint-import-resolver-typescript/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "node_modules/eslint-module-utils": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz", @@ -4657,6 +4719,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-tsconfig": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.0.tgz", + "integrity": "sha512-pmjiZ7xtB8URYm74PlGJozDNyhvsVLUcpBa8DZBG3bWHwaHa9bPiRpiSfovw+fjhwONSCWKRyk+JQHEGZmMrzw==", + "dev": true, + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -7640,6 +7714,15 @@ "node": ">=8" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/resolve.exports": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", @@ -8485,6 +8568,15 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", diff --git a/package.json b/package.json index ea8c919..469f95d 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "prebuild": "rimraf build", "build": "tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json && echo '{\"type\": \"commonjs\"}'> build/cjs/package.json", "build:watch": "tsc -b --watch ./tsconfig.cjs.json ./tsconfig.esm.json && echo '{\"type\": \"commonjs\"}'> build/cjs/package.json", - "lint": "eslint ./lib ./test --ext ts", + "lint": "eslint .", "lint:package": "publint", "test": "npm run test:node && npm run test:browser", "test:node": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --coverage", @@ -51,8 +51,9 @@ "@typescript-eslint/parser": "^6.4.1", "browser-sync": "^2.29.3", "concurrently": "^8.2.0", - "eslint": "^8.47.0", + "eslint": "^8.48.0", "eslint-config-prettier": "^9.0.0", + "eslint-import-resolver-typescript": "^3.6.0", "eslint-plugin-import": "^2.28.1", "eslint-plugin-prettier": "^5.0.0", "husky": "^8.0.3",