From 2aa0309c4640308fa1769ae4b5f605d842820a28 Mon Sep 17 00:00:00 2001 From: Nicolas Morel Date: Sun, 28 Jul 2024 01:42:17 +0200 Subject: [PATCH] feat: target ESLint v9 --- lib/linter/.eslintrc.js | 6 +++--- lib/linter/index.js | 17 +++++++++++++++-- package.json | 3 ++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/linter/.eslintrc.js b/lib/linter/.eslintrc.js index b2d74046..e7b26db8 100755 --- a/lib/linter/.eslintrc.js +++ b/lib/linter/.eslintrc.js @@ -1,5 +1,5 @@ 'use strict'; -module.exports = { - extends: 'plugin:@hapi/module' -}; +const HapiPlugin = require('@hapi/eslint-plugin'); + +module.exports = [...HapiPlugin.configs.module]; diff --git a/lib/linter/index.js b/lib/linter/index.js index 9f25bbe2..a287a3b1 100755 --- a/lib/linter/index.js +++ b/lib/linter/index.js @@ -32,17 +32,30 @@ exports.lint = async function () { } if (!configuration.extensions) { - configuration.extensions = ['.js', '.cjs', '.mjs']; + const extensions = ['js', 'cjs', 'mjs']; if (configuration.typescript) { - configuration.extensions.push('.ts'); + extensions.push('ts'); } + + configuration.baseConfig = configuration.baseConfig || []; + configuration.baseConfig.unshift({ + files: [`**/*.{${extensions.join(',')}}`], + }); } if (configuration.typescript) { delete configuration.typescript; } + if (configuration.ignores) { + configuration.baseConfig = configuration.baseConfig || []; + configuration.baseConfig.unshift({ + ignores: configuration.ignores + }); + delete configuration.ignores; + } + let results; try { const eslint = new Eslint.ESLint(configuration); diff --git a/package.json b/package.json index 6ae808b5..a1386cb3 100755 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@hapi/eslint-plugin": "^6.0.0", "@hapi/hoek": "^11.0.2", "diff": "^5.0.0", - "eslint": "8.x.x", + "eslint": "9.x.x", "find-rc": "4.x.x", "globby": "^11.1.0", "handlebars": "4.x.x", @@ -48,6 +48,7 @@ "devDependencies": { "@hapi/code": "^9.0.0", "@hapi/somever": "^4.0.0", + "@types/eslint": "^9.6.0", "@types/node": "^18.11.17", "@typescript-eslint/parser": "^5.62.0", "cpr": "3.x.x",