From 7d1d73ee167dbef479a2ca63cc4da321d118b02a Mon Sep 17 00:00:00 2001 From: Ihor Diachenko Date: Tue, 4 Jun 2024 02:57:16 +0300 Subject: [PATCH] FIxed recommended config for legacy `eslintrc` config format (#36) * Added v8 compatibility test * Added a legacy config * Clean up scripts * updated readme * Keep things the same for eslintrc * Imporved the naming --- README.md | 2 +- eslint.config.js | 2 +- lib/index.js | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1da66c9..3aeb5d8 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ ESLint 9 flat config format: const pluginChaiFriendly = require("eslint-plugin-chai-friendly"); module.exports = [ - pluginChaiFriendly.configs.recommended, + pluginChaiFriendly.configs.recommendedFlat, // other configurations ] ``` diff --git a/eslint.config.js b/eslint.config.js index 38b5133..8a5dac4 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,7 +3,7 @@ const pluginChaiFriendly = require("./lib"); module.exports = [ - pluginChaiFriendly.configs.recommended, + pluginChaiFriendly.configs.recommendedFlat, { ignores: ["node_modules", "!.eslintrc.js", "examples"], } diff --git a/lib/index.js b/lib/index.js index ce484da..23a103e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -19,7 +19,8 @@ const plugin = { // assign configs here so we can reference `plugin` Object.assign(plugin.configs, { - recommended: { + // Compatible with ESLint v9 flat configs + recommendedFlat: { plugins: { 'chai-friendly': plugin }, @@ -27,6 +28,17 @@ Object.assign(plugin.configs, { 'chai-friendly/no-unused-expressions': 'error', 'no-unused-expressions': 'off' } + }, + + // Compatible with ESLint <9 eslintrc configs + recommended: { + plugins: [ + 'chai-friendly' + ], + rules: { + 'no-unused-expressions': 0, // disable original rule + 'chai-friendly/no-unused-expressions': 2 + } } },)