Skip to content

Commit 1c388fb

Browse files
chore: switch nyc to c8 (#16263)
* chore: switch nyc to c8 * chore: istanbul ignore => c8 ignore * Update lib/linter/code-path-analysis/code-path-segment.js Co-authored-by: Ari Perkkiö <ari.perkkio@gmail.com> * chore: c8 ignore if/else => c8 ignore start/end refs: #16263 (comment) * fix: c8 ignore end => stop * fix: rm an unused c8 ignore it does not have an `else`, so seems no longer needed. * fix: c8 disallows additional text Co-authored-by: Ari Perkkiö <ari.perkkio@gmail.com>
1 parent 67db10c commit 1c388fb

26 files changed

Lines changed: 49 additions & 47 deletions
File renamed without changes.

Makefile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,12 +601,12 @@ target.mocha = () => {
601601

602602
echo("Running unit tests");
603603

604-
lastReturn = exec(`${getBinFile("nyc")} -- ${MOCHA} --forbid-only -R progress -t ${MOCHA_TIMEOUT} -c ${TEST_FILES}`);
604+
lastReturn = exec(`${getBinFile("c8")} -- ${MOCHA} --forbid-only -R progress -t ${MOCHA_TIMEOUT} -c ${TEST_FILES}`);
605605
if (lastReturn.code !== 0) {
606606
errors++;
607607
}
608608

609-
lastReturn = exec(`${getBinFile("nyc")} check-coverage --statement 98 --branch 97 --function 98 --lines 98`);
609+
lastReturn = exec(`${getBinFile("c8")} check-coverage --statement 98 --branch 97 --function 98 --lines 98`);
610610
if (lastReturn.code !== 0) {
611611
errors++;
612612
}

lib/cli-engine/file-enumerator.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ function statSafeSync(filePath) {
122122
try {
123123
return fs.statSync(filePath);
124124
} catch (error) {
125-
/* istanbul ignore next */
125+
126+
/* c8 ignore next */
126127
if (error.code !== "ENOENT") {
127128
throw error;
128129
}
@@ -141,7 +142,8 @@ function readdirSafeSync(directoryPath) {
141142
try {
142143
return fs.readdirSync(directoryPath, { withFileTypes: true });
143144
} catch (error) {
144-
/* istanbul ignore next */
145+
146+
/* c8 ignore next */
145147
if (error.code !== "ENOENT") {
146148
throw error;
147149
}

lib/linter/code-path-analysis/code-path-segment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ class CodePathSegment {
8888
}
8989
});
9090

91-
/* istanbul ignore if */
91+
/* c8 ignore start */
9292
if (debug.enabled) {
9393
this.internal.nodes = [];
94-
}
94+
}/* c8 ignore stop */
9595
}
9696

9797
/**

lib/linter/code-path-analysis/code-path-state.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function getContinueContext(state, label) {
5959
context = context.upper;
6060
}
6161

62-
/* istanbul ignore next: foolproof (syntax error) */
62+
/* c8 ignore next */
6363
return null;
6464
}
6565

@@ -79,7 +79,7 @@ function getBreakContext(state, label) {
7979
context = context.upper;
8080
}
8181

82-
/* istanbul ignore next: foolproof (syntax error) */
82+
/* c8 ignore next */
8383
return null;
8484
}
8585

@@ -433,7 +433,7 @@ class CodePathState {
433433
*/
434434
return context;
435435

436-
/* istanbul ignore next */
436+
/* c8 ignore next */
437437
default:
438438
throw new Error("unreachable");
439439
}
@@ -1030,7 +1030,7 @@ class CodePathState {
10301030
};
10311031
break;
10321032

1033-
/* istanbul ignore next */
1033+
/* c8 ignore next */
10341034
default:
10351035
throw new Error(`unknown type: "${type}"`);
10361036
}
@@ -1095,7 +1095,7 @@ class CodePathState {
10951095
);
10961096
break;
10971097

1098-
/* istanbul ignore next */
1098+
/* c8 ignore next */
10991099
default:
11001100
throw new Error("unreachable");
11011101
}
@@ -1392,11 +1392,12 @@ class CodePathState {
13921392

13931393
const context = getBreakContext(this, label);
13941394

1395-
/* istanbul ignore else: foolproof (syntax error) */
1395+
13961396
if (context) {
13971397
context.brokenForkContext.add(forkContext.head);
13981398
}
13991399

1400+
/* c8 ignore next */
14001401
forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
14011402
}
14021403

@@ -1417,7 +1418,6 @@ class CodePathState {
14171418

14181419
const context = getContinueContext(this, label);
14191420

1420-
/* istanbul ignore else: foolproof (syntax error) */
14211421
if (context) {
14221422
if (context.continueDestSegments) {
14231423
makeLooped(this, forkContext.head, context.continueDestSegments);

lib/linter/code-path-analysis/debug-helpers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const debug = require("debug")("eslint:code-path");
2020
* @param {CodePathSegment} segment A segment to get.
2121
* @returns {string} Id of the segment.
2222
*/
23-
/* istanbul ignore next */
23+
/* c8 ignore next */
2424
function getId(segment) { // eslint-disable-line jsdoc/require-jsdoc -- Ignoring
2525
return segment.id + (segment.reachable ? "" : "!");
2626
}
@@ -67,7 +67,7 @@ module.exports = {
6767
* @param {boolean} leaving A flag whether or not it's leaving
6868
* @returns {void}
6969
*/
70-
dumpState: !debug.enabled ? debug : /* istanbul ignore next */ function(node, state, leaving) {
70+
dumpState: !debug.enabled ? debug : /* c8 ignore next */ function(node, state, leaving) {
7171
for (let i = 0; i < state.currentSegments.length; ++i) {
7272
const segInternal = state.currentSegments[i].internal;
7373

@@ -98,7 +98,7 @@ module.exports = {
9898
* @see http://www.graphviz.org
9999
* @see http://www.webgraphviz.com
100100
*/
101-
dumpDot: !debug.enabled ? debug : /* istanbul ignore next */ function(codePath) {
101+
dumpDot: !debug.enabled ? debug : /* c8 ignore next */ function(codePath) {
102102
let text =
103103
"\n" +
104104
"digraph {\n" +

lib/linter/code-path-analysis/id-generator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class IdGenerator {
3333
next() {
3434
this.n = 1 + this.n | 0;
3535

36-
/* istanbul ignore if */
36+
/* c8 ignore start */
3737
if (this.n < 0) {
3838
this.n = 1;
39-
}
39+
}/* c8 ignore stop */
4040

4141
return this.prefix + this.n;
4242
}

lib/linter/timing.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Helpers
1010
//------------------------------------------------------------------------------
1111

12-
/* istanbul ignore next */
12+
/* c8 ignore next */
1313
/**
1414
* Align the string to left
1515
* @param {string} str string to evaluate
@@ -22,7 +22,7 @@ function alignLeft(str, len, ch) {
2222
return str + new Array(len - str.length + 1).join(ch || " ");
2323
}
2424

25-
/* istanbul ignore next */
25+
/* c8 ignore next */
2626
/**
2727
* Align the string to right
2828
* @param {string} str string to evaluate
@@ -64,7 +64,7 @@ function getListSize() {
6464
return TIMING_ENV_VAR_AS_INTEGER > 10 ? TIMING_ENV_VAR_AS_INTEGER : MINIMUM_SIZE;
6565
}
6666

67-
/* istanbul ignore next */
67+
/* c8 ignore next */
6868
/**
6969
* display the data
7070
* @param {Object} data Data object to be displayed
@@ -119,7 +119,7 @@ function display(data) {
119119
console.log(table.join("\n")); // eslint-disable-line no-console -- Debugging function
120120
}
121121

122-
/* istanbul ignore next */
122+
/* c8 ignore next */
123123
module.exports = (function() {
124124

125125
const data = Object.create(null);

lib/rules/array-callback-return.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function getArrayMethodName(node) {
125125
}
126126
}
127127

128-
/* istanbul ignore next: unreachable */
128+
/* c8 ignore next */
129129
return null;
130130
}
131131

lib/rules/global-require.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ function findReference(scope, node) {
2828
const references = scope.references.filter(reference => reference.identifier.range[0] === node.range[0] &&
2929
reference.identifier.range[1] === node.range[1]);
3030

31-
/* istanbul ignore else: correctly returns null */
3231
if (references.length === 1) {
3332
return references[0];
3433
}
34+
35+
/* c8 ignore next */
3536
return null;
3637

3738
}

0 commit comments

Comments
 (0)