mirror of
https://github.com/hanzoai/eslint.git
synced 2026-10-30 19:38:10 +00:00
* refactor: deduplicate isAnySegmentReachable across rules * test: add unit tests for isAnySegmentReachable * refactor: move isAnySegmentReachable to code-path-utils
23 lines
482 B
JavaScript
23 lines
482 B
JavaScript
/**
|
|
* @fileoverview Code path related utilities.
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Checks all segments in a set and returns true if any are reachable.
|
|
* @param {Set<CodePathSegment>} segments The segments to check.
|
|
* @returns {boolean} `true` if any segment is reachable; `false` otherwise.
|
|
*/
|
|
function isAnySegmentReachable(segments) {
|
|
for (const segment of segments) {
|
|
if (segment.reachable) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
module.exports = { isAnySegmentReachable };
|