From 24526166105778bb1eb5ac9148f69aae1d247c02 Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Fri, 21 Jul 2023 14:51:04 +0200 Subject: [PATCH] Add explanations to some ESLint ignore comments (#704) --- cli.js | 2 +- index.js | 2 +- lib/options-manager.js | 4 ++-- test/lint-files.js | 12 ++++++------ test/lint-text.js | 2 +- test/open-report.js | 9 ++++----- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/cli.js b/cli.js index 2d481d57..dca59e12 100755 --- a/cli.js +++ b/cli.js @@ -1,5 +1,5 @@ #!/usr/bin/env node -/* eslint-disable unicorn/prefer-top-level-await */ +/* eslint-disable unicorn/prefer-top-level-await -- TODO: Use top-level await */ import process from 'node:process'; import getStdin from 'get-stdin'; import meow from 'meow'; diff --git a/index.js b/index.js index afc541ed..acd0c6dd 100644 --- a/index.js +++ b/index.js @@ -89,7 +89,7 @@ const lintFiles = async (patterns, options) => { const {cwd, baseConfig: {ignorePatterns}} = eslintOptions; if ( micromatch.isMatch(path.relative(cwd, filePath), ignorePatterns) - // eslint-disable-next-line no-await-in-loop + // eslint-disable-next-line no-await-in-loop -- Not worth refactoring || await eslint.isPathIgnored(filePath) ) { continue; diff --git a/lib/options-manager.js b/lib/options-manager.js index 52e5e4ff..6feb6ec7 100644 --- a/lib/options-manager.js +++ b/lib/options-manager.js @@ -522,11 +522,11 @@ const findApplicableOverrides = (path, overrides) => { const applicable = []; for (const override of overrides) { - hash <<= 1; // eslint-disable-line no-bitwise + hash <<= 1; // eslint-disable-line no-bitwise -- Intentional bitwise usage if (micromatch.isMatch(path, override.files)) { applicable.push(override); - hash |= 1; // eslint-disable-line no-bitwise + hash |= 1; // eslint-disable-line no-bitwise -- Intentional bitwise usage } } diff --git a/test/lint-files.js b/test/lint-files.js index 9fbadaf7..d9f4ca4b 100644 --- a/test/lint-files.js +++ b/test/lint-files.js @@ -228,19 +228,19 @@ test.serial('typescript files', async t => { test.serial('typescript 2 space option', async t => { const {errorCount, results} = await xo.lintFiles('two-spaces.tsx', {cwd: 'fixtures/typescript', space: 2}); - // eslint-disable-next-line ava/assertion-arguments + // eslint-disable-next-line ava/assertion-arguments -- Type issue t.is(errorCount, 0, JSON.stringify(results[0].messages)); }); test.serial('typescript 4 space option', async t => { const {errorCount, results} = await xo.lintFiles('child/sub-child/four-spaces.ts', {cwd: 'fixtures/typescript', space: 4}); - // eslint-disable-next-line ava/assertion-arguments + // eslint-disable-next-line ava/assertion-arguments -- Type issue t.is(errorCount, 0, JSON.stringify(results[0].messages)); }); test.serial('typescript no semicolon option', async t => { const {errorCount, results} = await xo.lintFiles('child/no-semicolon.ts', {cwd: 'fixtures/typescript', semicolon: false}); - // eslint-disable-next-line ava/assertion-arguments + // eslint-disable-next-line ava/assertion-arguments -- Type issue t.is(errorCount, 0, JSON.stringify(results[0].messages)); }); @@ -253,7 +253,7 @@ test('webpack import resolver is used if webpack.config.js is found', async t => }, }); - // eslint-disable-next-line ava/assertion-arguments + // eslint-disable-next-line ava/assertion-arguments -- Type issue t.is(results[0].errorCount, 1, JSON.stringify(results[0].messages)); const errorMessage = results[0].messages[0].message; @@ -279,7 +279,7 @@ test('webpack import resolver config can be passed through webpack option', asyn }, }); - // eslint-disable-next-line ava/assertion-arguments + // eslint-disable-next-line ava/assertion-arguments -- Type issue t.is(results[0].errorCount, 1, JSON.stringify(results[0].messages)); }); @@ -295,7 +295,7 @@ test('webpack import resolver is used if {webpack: true}', async t => { }, }); - // eslint-disable-next-line ava/assertion-arguments + // eslint-disable-next-line ava/assertion-arguments -- Type issue t.is(results[0].errorCount, 0, JSON.stringify(results[0])); }); diff --git a/test/lint-text.js b/test/lint-text.js index 8355ff88..ca4daa3c 100644 --- a/test/lint-text.js +++ b/test/lint-text.js @@ -346,7 +346,7 @@ test('typescript files: four space pass', async t => { filePath: fourSpacesFilePath, space: 4, }); - // eslint-disable-next-line ava/assertion-arguments + // eslint-disable-next-line ava/assertion-arguments -- Type issue t.is(results[0].errorCount, 0, JSON.stringify(results[0].messages)); }); diff --git a/test/open-report.js b/test/open-report.js index e9e5435f..2c7bc0e2 100644 --- a/test/open-report.js +++ b/test/open-report.js @@ -1,4 +1,3 @@ -/* eslint-disable ava/no-skip-test */ import process from 'node:process'; import path from 'node:path'; import test from 'ava'; @@ -9,7 +8,7 @@ import xo from '../index.js'; const {__dirname} = createEsmUtils(import.meta); process.chdir(__dirname); -test.skip('opens nothing when there are no errors nor warnings', async t => { +test.failing('opens nothing when there are no errors nor warnings', async t => { const glob = path.join(__dirname, 'fixtures/open-report/successes/*'); const results = await xo.lintFiles(glob); @@ -25,7 +24,7 @@ test.skip('opens nothing when there are no errors nor warnings', async t => { t.pass(); }); -test.skip('only opens errors if there are errors and warnings', async t => { +test.failing('only opens errors if there are errors and warnings', async t => { const glob = path.join(__dirname, 'fixtures/open-report/**'); const results = await xo.lintFiles(glob); @@ -55,7 +54,7 @@ test.skip('only opens errors if there are errors and warnings', async t => { openReport(results); }); -test.skip('if a file has errors and warnings, it opens the first error', async t => { +test.failing('if a file has errors and warnings, it opens the first error', async t => { const glob = path.join(__dirname, 'fixtures/open-report/errors/two-with-warnings.js'); const results = await xo.lintFiles(glob); @@ -73,7 +72,7 @@ test.skip('if a file has errors and warnings, it opens the first error', async t openReport(results); }); -test.skip('only opens warnings if there are no errors', async t => { +test.failing('only opens warnings if there are no errors', async t => { const glob = path.join(__dirname, 'fixtures/open-report/warnings/*'); const results = await xo.lintFiles(glob);