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

ota-meshi / eslint-plugin-jsonc / 8598798574

08 Apr 2024 10:50AM CUT coverage: 72.344%. Remained the same
8598798574

push

github

renovate[bot]
chore(deps): update dependency vite-plugin-eslint4b to ^0.3.0

1003 of 1592 branches covered (63.0%)

Branch coverage included in aggregate %.

1673 of 2107 relevant lines covered (79.4%)

57.63 hits per line

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

16.67
/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