From b168f08999cac78d71d5f25a075282eb22b92aa4 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Sun, 14 Jul 2024 07:57:24 +0800 Subject: [PATCH] Re-enable `eslint-plugin-promise` (#656) Co-authored-by: Federico Brigante Co-authored-by: Sindre Sorhus --- config/plugins.cjs | 26 ++++++++++++-------------- package.json | 1 + test/lint-files.js | 2 +- test/lint-text.js | 4 ++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/config/plugins.cjs b/config/plugins.cjs index 8ba83414..4b428320 100644 --- a/config/plugins.cjs +++ b/config/plugins.cjs @@ -14,8 +14,7 @@ module.exports = { 'no-use-extend-native', 'ava', 'unicorn', - // Disabled as the plugin doesn't support ESLint 8 yet. - // 'promise', + 'promise', 'import', 'n', // eslint-plugin-node's successor 'eslint-comments', @@ -184,18 +183,17 @@ module.exports = { // TODO: Temporarily disabled as the rule is buggy. 'function-call-argument-newline': 'off', - // Disabled as the plugin doesn't support ESLint 8 yet. - // 'promise/param-names': 'error', - // 'promise/no-return-wrap': [ - // 'error', - // { - // allowReject: true, - // }, - // ], - // 'promise/no-new-statics': 'error', - // 'promise/no-return-in-finally': 'error', - // 'promise/valid-params': 'error', - // 'promise/prefer-await-to-then': 'error', + 'promise/param-names': 'error', + 'promise/no-return-wrap': [ + 'error', + { + allowReject: true, + }, + ], + 'promise/no-new-statics': 'error', + 'promise/no-return-in-finally': 'error', + 'promise/valid-params': 'error', + 'promise/prefer-await-to-then': 'error', 'import/default': 'error', 'import/export': 'error', diff --git a/package.json b/package.json index b301a745..5c561a98 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "eslint-plugin-n": "^16.6.2", "eslint-plugin-no-use-extend-native": "^0.5.0", "eslint-plugin-prettier": "^5.1.3", + "eslint-plugin-promise": "^6.4.0", "eslint-plugin-unicorn": "^51.0.1", "esm-utils": "^4.2.1", "find-cache-dir": "^5.0.0", diff --git a/test/lint-files.js b/test/lint-files.js index affdea9f..df3087d9 100644 --- a/test/lint-files.js +++ b/test/lint-files.js @@ -121,7 +121,7 @@ test('multiple negative patterns should act as positive patterns', async t => { t.deepEqual(paths, ['!!unicorn.js', '!unicorn.js']); }); -test.failing('enable rules based on nodeVersion', async t => { +test('enable rules based on nodeVersion', async t => { const {results, rulesMeta} = await xo.lintFiles('**/*', {cwd: 'fixtures/engines-overrides'}); // The transpiled file (as specified in `overrides`) should use `await` diff --git a/test/lint-text.js b/test/lint-text.js index ca4daa3c..a6de9421 100644 --- a/test/lint-text.js +++ b/test/lint-text.js @@ -209,7 +209,7 @@ test('lint eslintignored files if filename is not given', async t => { t.true(results[0].errorCount > 0); }); -test.failing('enable rules based on nodeVersion', async t => { +test('enable rules based on nodeVersion', async t => { const cwd = path.join(__dirname, 'fixtures', 'engines-overrides'); const filePath = path.join(cwd, 'promise-then.js'); const text = await fs.readFile(filePath, 'utf8'); @@ -221,7 +221,7 @@ test.failing('enable rules based on nodeVersion', async t => { t.false(hasRule(results, 'promise/prefer-await-to-then', rulesMeta)); }); -test.failing('enable rules based on nodeVersion in override', async t => { +test('enable rules based on nodeVersion in override', async t => { const cwd = path.join(__dirname, 'fixtures', 'engines-overrides'); const filePath = path.join(cwd, 'promise-then.js'); const text = await fs.readFile(filePath, 'utf8');