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

ota-meshi / eslint-plugin-jsonc / 7529794917

15 Jan 2024 01:50PM UTC coverage: 71.898%. Remained the same
7529794917

push

github

web-flow
fix(deps): update dependency eslint-compat-utils to ^0.2.0 (#292)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>

985 of 1569 branches covered (0.0%)

Branch coverage included in aggregate %.

1617 of 2050 relevant lines covered (78.88%)

57.1 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