chore: fix linting errors
This commit is contained in:
parent
f2aa0dc231
commit
5d99fd5252
|
@ -5,7 +5,6 @@
|
|||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "_" }],
|
||||
"@typescript-eslint/no-inferrable-types": ["off"],
|
||||
"@typescript-eslint/ban-ts-comment": ["warn"]
|
||||
"@typescript-eslint/no-inferrable-types": ["off"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Context, Recogniser } from '.';
|
||||
|
||||
const match = require('../match').default;
|
||||
import match, { Match } from '../match'
|
||||
|
||||
/**
|
||||
* This is a superclass for the individual detectors for
|
||||
|
@ -15,7 +14,7 @@ class ISO_2022 implements Recogniser {
|
|||
return 'ISO_2022';
|
||||
}
|
||||
|
||||
match(det: Context) {
|
||||
match(det: Context): Match | null {
|
||||
/**
|
||||
* Matching function shared among the 2022 detectors JP, CN and KR
|
||||
* Counts up the number of legal an unrecognized escape sequences in
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Context, Recogniser } from '.';
|
||||
const match = require('../match').default;
|
||||
import match, { Match } from '../match'
|
||||
|
||||
/**
|
||||
* Binary search implementation (recursive)
|
||||
|
@ -97,7 +97,7 @@ class mbcs implements Recogniser {
|
|||
* bits 0-7: the match confidence, ranging from 0-100
|
||||
* bits 8-15: The match reason, an enum-like value.
|
||||
*/
|
||||
match(det: Context) {
|
||||
match(det: Context): Match | null {
|
||||
let singleByteCharCount = 0, //TODO Do we really need this?
|
||||
doubleByteCharCount = 0,
|
||||
commonCharCount = 0,
|
||||
|
@ -159,7 +159,7 @@ class mbcs implements Recogniser {
|
|||
}
|
||||
|
||||
if (this.commonChars == null) {
|
||||
// We have no statistics on frequently occuring characters.
|
||||
// We have no statistics on frequently occurring characters.
|
||||
// Assess confidence purely on having a reasonable number of
|
||||
// multi-byte characters (the more the better
|
||||
confidence = 30 + doubleByteCharCount - 20 * badCharCount;
|
||||
|
@ -167,11 +167,8 @@ class mbcs implements Recogniser {
|
|||
confidence = 100;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Frequency of occurrence statistics exist.
|
||||
//
|
||||
// @ts-ignore
|
||||
const maxVal = Math.log(parseFloat(doubleByteCharCount) / 4);
|
||||
const maxVal = Math.log(doubleByteCharCount / 4);
|
||||
const scaleFactor = 90.0 / maxVal;
|
||||
confidence = Math.floor(
|
||||
Math.log(commonCharCount + 1) * scaleFactor + 10
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Context, Recogniser } from '../encoding/index';
|
||||
|
||||
const match = require('../match').default;
|
||||
import match, { Match } from '../match';
|
||||
|
||||
/**
|
||||
* This class recognizes single-byte encodings. Because the encoding scheme is so
|
||||
|
@ -119,12 +118,11 @@ class sbcs implements Recogniser {
|
|||
return [];
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
name(input: Context): string {
|
||||
return 'sbcs';
|
||||
}
|
||||
|
||||
match(det: Context) {
|
||||
match(det: Context): Match | null {
|
||||
const ngrams = this.ngrams();
|
||||
|
||||
if (isFlatNgrams(ngrams)) {
|
||||
|
@ -134,7 +132,7 @@ class sbcs implements Recogniser {
|
|||
}
|
||||
|
||||
let bestConfidenceSoFar = -1;
|
||||
let lang = null;
|
||||
let lang;
|
||||
|
||||
for (let i = ngrams.length - 1; i >= 0; i--) {
|
||||
const ngl = ngrams[i];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Context, Recogniser } from '.';
|
||||
const match = require('../match').default;
|
||||
import match, { Match } from '../match';
|
||||
|
||||
/**
|
||||
* This class matches UTF-16 and UTF-32, both big- and little-endian. The
|
||||
|
@ -10,7 +10,7 @@ export class UTF_16BE implements Recogniser {
|
|||
return 'UTF-16BE';
|
||||
}
|
||||
|
||||
match(det: Context) {
|
||||
match(det: Context): Match | null {
|
||||
const input = det.fRawInput;
|
||||
|
||||
if (
|
||||
|
@ -30,7 +30,7 @@ export class UTF_16LE implements Recogniser {
|
|||
name() {
|
||||
return 'UTF-16LE';
|
||||
}
|
||||
match(det: Context) {
|
||||
match(det: Context): Match | null {
|
||||
const input = det.fRawInput;
|
||||
|
||||
if (
|
||||
|
@ -64,7 +64,7 @@ class UTF_32 implements Recogniser, WithGetChar {
|
|||
return -1;
|
||||
}
|
||||
|
||||
match(det: Context) {
|
||||
match(det: Context): Match | null {
|
||||
let numValid = 0,
|
||||
numInvalid = 0,
|
||||
hasBOM = false,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { Context, Recogniser } from '.';
|
||||
const match = require('../match').default;
|
||||
import match, { Match } from '../match';
|
||||
|
||||
export default class Utf8 implements Recogniser {
|
||||
name() {
|
||||
return 'UTF-8';
|
||||
}
|
||||
|
||||
match(det: Context) {
|
||||
match(det: Context): Match | null {
|
||||
let hasBOM = false,
|
||||
numValid = 0,
|
||||
numInvalid = 0,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { Context, Recogniser } from "./encoding";
|
||||
|
||||
export interface Match {
|
||||
confidence: number;
|
||||
name: string;
|
||||
lang: string;
|
||||
lang?: string;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export default (det, rec, confidence, name, lang): Match => ({
|
||||
export default (det: Context, rec: Recogniser, confidence: number, name?: string, lang?: string): Match => ({
|
||||
confidence,
|
||||
name: name || rec.name(det),
|
||||
lang,
|
||||
|
|
Loading…
Reference in New Issue