From 418c1e706c254f0d68c2e56741713369c820f450 Mon Sep 17 00:00:00 2001 From: Reggi Date: Wed, 12 Jun 2024 09:35:37 -0400 Subject: [PATCH] fix: add support for eslint 9 --- lib/index.js | 81 ++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/lib/index.js b/lib/index.js index aecccfc..a3e6484 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,44 +1,28 @@ -module.exports = { - extends: [ - 'eslint:recommended', - ], - parserOptions: { +const globals = require("globals") +const js = require("@eslint/js") +const pluginNode = require("eslint-plugin-node") +const pluginImport = require("eslint-plugin-import") +const pluginPromise = require("eslint-plugin-promise") +const { fixupPluginRules } = require("@eslint/compat") + +const npmCliConfig = [{ + languageOptions: { ecmaVersion: 2022, - ecmaFeatures: {}, sourceType: 'script', + globals: { + ...globals.browser, + ...globals.node, + document: 'readonly', + navigator: 'readonly', + window: 'readonly', + } }, - env: { - es6: true, - node: true, - }, - plugins: [ - 'node', - 'import', - 'promise', - ], - globals: { - document: 'readonly', - navigator: 'readonly', - window: 'readonly', + plugins: { + node: fixupPluginRules(pluginNode), + import: pluginImport, + promise: pluginPromise }, - ignorePatterns: ['tap-snapshots/**'], - overrides: [{ - files: ['test/**'], - rules: { - 'no-global-assign': 'off', - 'no-extend-native': 'off', - }, - }, { - files: ['lib/**', 'bin/**'], - rules: { - 'import/no-extraneous-dependencies': ['error', { devDependencies: false }], - }, - }, { - files: ['lib/**'], - rules: { - 'no-console': 'error', - }, - }], + ignores: ['tap-snapshots/**'], rules: { 'accessor-pairs': 'error', 'array-bracket-spacing': ['error', 'never'], @@ -230,4 +214,27 @@ module.exports = { 'promise/catch-or-return': 'error', 'promise/no-new-statics': 'error', }, +}, +{ + files: ['test/**'], + rules: { + 'no-global-assign': 'off', + 'no-extend-native': 'off', + }, +}, { + files: ['lib/**', 'bin/**'], + rules: { + 'import/no-extraneous-dependencies': ['error', { devDependencies: false }], + }, +}, { + files: ['lib/**'], + rules: { + 'no-console': 'error', + }, } +] + +module.exports = [ + js.configs.recommended, + ...npmCliConfig +]