Skip to content

Commit

Permalink
feat: 忽略动态 import lint 校验
Browse files Browse the repository at this point in the history
  • Loading branch information
hotoo committed Nov 20, 2023
1 parent dc4b768 commit cd46352
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/segment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// import nodejieba from "nodejieba";
// import { load, cut /*, tag */ } from "@node-rs/jieba";
// @ts-ignore
// import { Segment, useDefault } from "segmentit";
import type { IPinyinSegment } from "./declare";

let nodeRsJiebaLoaded = false; // @node-rs/jieba 加载词典。
Expand All @@ -15,6 +11,7 @@ let hansIntlSegmenter: any; // Intl.Segmenter
export function segment(hans: string, segment?: IPinyinSegment): string[] {
// @node-rs/jieba (Rust)
if (segment === "@node-rs/jieba") {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { load, cut /*, tag */ } = require("@node-rs/jieba");
if (!nodeRsJiebaLoaded) {
nodeRsJiebaLoaded = true;
Expand All @@ -26,6 +23,7 @@ export function segment(hans: string, segment?: IPinyinSegment): string[] {

// segmentit (Node.js)
if (segment === "segmentit") {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { Segment, useDefault } = require("segmentit");
if (!segmentit) {
segmentit = useDefault(new Segment());
Expand All @@ -47,6 +45,7 @@ export function segment(hans: string, segment?: IPinyinSegment): string[] {
}
}

// eslint-disable-next-line @typescript-eslint/no-var-requires
const nodejieba = require("nodejieba");
// 默认使用 nodejieba (C++)
// return nodejieba.tag(hans);
Expand Down

0 comments on commit cd46352

Please sign in to comment.