From 19f6b992dd0d2eb47a0648aab54eb6839828393f Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Mon, 3 Feb 2025 21:11:47 +0000 Subject: [PATCH] chore: move to eslint flat config Moves to using an ESLint flat config. --- .eslintignore | 1 - .eslintrc.json | 16 ----------- eslint.config.js | 30 +++++++++++++++++++++ package-lock.json | 66 +++++++++++++++++++++++++++++++++++++-------- package.json | 2 ++ test/.eslintrc.json | 7 ----- 6 files changed, 87 insertions(+), 35 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.json create mode 100644 eslint.config.js delete mode 100644 test/.eslintrc.json diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 404abb2..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -coverage/ diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 7852733..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "root": true, - "extends": [ - "eslint:recommended" - ], - "env": { - "node": true, - "es2022": true - }, - "parserOptions": { - "ecmaVersion": "2022", - "sourceType": "module" - }, - "rules": { - } -} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..e88d131 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,30 @@ +import eslintjs from "@eslint/js"; +import globals from 'globals'; + +const {configs: eslintConfigs} = eslintjs; + +export default [ + { + ignores: [ + 'coverage/' + ], + }, + eslintConfigs["recommended"], + { + files: ['test/**/*.js'], + languageOptions: { + globals: { + ...globals.browser, + } + } + }, + { + files: ['test/**/*.js'], + languageOptions: { + globals: { + ...globals.mocha, + ...globals.node, + } + } + } +]; diff --git a/package-lock.json b/package-lock.json index 85bd2e2..cf21e23 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,9 +12,11 @@ "check-error": "^2.0.0" }, "devDependencies": { + "@eslint/js": "^9.19.0", "c8": "^10.0.0", "chai": "^5.1.0", "eslint": "^8.57.0", + "globals": "^15.14.0", "mocha": "^10.4.0", "prettier": "^3.2.5" }, @@ -85,6 +87,22 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@eslint/eslintrc/node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -98,12 +116,13 @@ } }, "node_modules/@eslint/js": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", - "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "version": "9.19.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.19.0.tgz", + "integrity": "sha512-rbq9/g38qjfqFLOVPvwjIvFFdNziEC5S65jmjPw5r6A//QH+W91akh9irMwjDN8zKUTak6W9EsAv4m/7Wnw0UQ==", "dev": true, + "license": "MIT", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@humanwhocodes/config-array": { @@ -838,12 +857,38 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint/node_modules/@eslint/js": { + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/eslint/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/eslint/node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/eslint/node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -1169,15 +1214,13 @@ } }, "node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "version": "15.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.14.0.tgz", + "integrity": "sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==", "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, + "license": "MIT", "engines": { - "node": ">=8" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -2210,6 +2253,7 @@ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, + "license": "(MIT OR CC0-1.0)", "engines": { "node": ">=10" }, diff --git a/package.json b/package.json index 5c6be79..a1108f4 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,11 @@ "chai": ">= 2.1.2 < 6" }, "devDependencies": { + "@eslint/js": "^9.19.0", "c8": "^10.0.0", "chai": "^5.1.0", "eslint": "^8.57.0", + "globals": "^15.14.0", "mocha": "^10.4.0", "prettier": "^3.2.5" } diff --git a/test/.eslintrc.json b/test/.eslintrc.json deleted file mode 100644 index 26aaba6..0000000 --- a/test/.eslintrc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../.eslintrc.json", - "env": { - "mocha": true, - "node": true - } -}