• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ota-meshi / eslint-plugin-jsonc / 11734106188

08 Nov 2024 01:03AM CUT coverage: 73.004%. Remained the same
11734106188

Pull #317

github

web-flow
Merge dc6db512b into af28a2390
Pull Request #317: chore(deps): update dependency @types/eslint-visitor-keys to v3

860 of 1378 branches covered (62.41%)

Branch coverage included in aggregate %.

1801 of 2267 relevant lines covered (79.44%)

171.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.0
/lib/utils/eslint-string-utils.ts
1
// Most source code was copied from ESLint v8.
2
// MIT License. Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
3
/**
4
 * @fileoverview Utilities to operate on strings.
5
 * @author Stephen Wade
6
 */
7

8
import Graphemer from "graphemer";
1✔
9
// eslint-disable-next-line no-control-regex -- intentionally including control characters
10
const ASCII_REGEX = /^[\u0000-\u007f]*$/u;
1✔
11
let segmenter: Intl.Segmenter | undefined;
12
let splitter: Graphemer | undefined;
13

14
/**
15
 * Counts graphemes in a given string.
16
 * @param value A string to count graphemes.
17
 * @returns The number of graphemes in `value`.
18
 */
19
export function getGraphemeCount(value: string): number {
1✔
20
  if (ASCII_REGEX.test(value)) return value.length;
×
21

22
  try {
×
23
    if (!segmenter) segmenter = new Intl.Segmenter();
×
24

25
    return [...segmenter.segment(value)].length;
×
26
  } catch {
27
    // ignore
28
  }
29
  if (!splitter)
×
30
    // @ts-expect-error CJS interop
31
    splitter = new (Graphemer.default || Graphemer)();
×
32
  return splitter!.countGraphemes(value);
×
33
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc