Skip to content

Commit

Permalink
feat: target ESLint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
Marsup committed Jul 29, 2024
1 parent 945503a commit 06b1326
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/linter/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = {
extends: 'plugin:@hapi/module'
};
const HapiPlugin = require('@hapi/eslint-plugin');

module.exports = [...HapiPlugin.configs.module];
26 changes: 18 additions & 8 deletions lib/linter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ exports.lint = async function () {

const options = process.argv[2] ? JSON.parse(process.argv[2]) : undefined;

if (!Fs.existsSync('.eslintrc.js') &&
!Fs.existsSync('.eslintrc.cjs') && // Needed for projects with "type": "module"
!Fs.existsSync('.eslintrc.yaml') &&
!Fs.existsSync('.eslintrc.yml') &&
!Fs.existsSync('.eslintrc.json') &&
!Fs.existsSync('.eslintrc')) {
if (!Fs.existsSync('eslint.config.js') &&
!Fs.existsSync('eslint.config.cjs') && // Needed for projects with "type": "module"
!Fs.existsSync('eslint.config.mjs')) {
configuration.overrideConfigFile = Path.join(__dirname, '.eslintrc.js');
}

Expand All @@ -32,17 +29,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);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 06b1326

Please sign in to comment.