From b299836a1b8f36bd118b76201ad106cf755d153b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 1 Jun 2024 11:36:31 +0200 Subject: [PATCH] chore: remove useless "use strict" from TS code --- .eslintrc.yml | 2 -- builder/.eslintrc.yml | 2 ++ builder/createStatesJs.js | 1 - src/formats.ts | 2 -- src/generated/__tests__/states.test.ts | 2 -- src/generated/states.ts | 1 - src/index.ts | 2 -- src/parse/__tests__/errors.test.ts | 2 -- src/parse/__tests__/frenchDrivingLicense.test.ts | 2 -- src/parse/__tests__/frenchNationalId.test.ts | 2 -- src/parse/__tests__/swissDrivingLicense.test.ts | 2 -- src/parse/__tests__/td1.test.ts | 2 -- src/parse/__tests__/td2.test.ts | 2 -- src/parse/__tests__/td3.test.ts | 2 -- src/parse/autoCorrection.ts | 2 -- src/parse/checkLines.ts | 2 -- src/parse/createFieldParser.ts | 2 -- src/parse/fieldTemplates.ts | 2 -- src/parse/frenchDrivingLicence.ts | 2 -- src/parse/frenchDrivingLicenceFields.ts | 2 -- src/parse/frenchNationalId.ts | 2 -- src/parse/frenchNationalIdFields.ts | 2 -- src/parse/getResult.ts | 2 -- src/parse/parse.ts | 5 +++-- src/parse/parsers.ts | 2 -- src/parse/swissDrivingLicense.ts | 2 -- src/parse/swissDrivingLicenseFields.ts | 2 -- src/parse/td1.ts | 2 -- src/parse/td1Fields.ts | 2 -- src/parse/td2.ts | 2 -- src/parse/td2Fields.ts | 2 -- src/parse/td3.ts | 2 -- src/parse/td3Fields.ts | 2 -- src/parsers/__tests__/check.test.ts | 2 -- src/parsers/check.ts | 2 -- src/parsers/cleanText.ts | 2 -- src/parsers/frenchDrivingLicence/parseDocumentCode.ts | 2 -- src/parsers/parseAlpha.ts | 2 -- src/parsers/parseCompositeCheckDigit.ts | 2 -- src/parsers/parseDate.ts | 2 -- src/parsers/parseDateCheckDigit.ts | 2 -- src/parsers/parseDocumentCodeId.ts | 2 -- src/parsers/parseDocumentCodePassport.ts | 2 -- src/parsers/parseDocumentNumber.ts | 2 -- src/parsers/parseDocumentNumberCheckDigit.ts | 2 -- src/parsers/parseDocumentNumberOptional.ts | 2 -- src/parsers/parseFirstName.ts | 2 -- src/parsers/parseLastName.ts | 2 -- src/parsers/parseNumber.ts | 2 -- src/parsers/parseOptional.ts | 2 -- src/parsers/parsePersonalNumber.ts | 2 -- src/parsers/parsePersonalNumberCheckDigit.ts | 2 -- src/parsers/parseSex.ts | 2 -- src/parsers/parseState.ts | 2 -- src/parsers/parseText.ts | 2 -- src/parsers/swissDrivingLicense/checkSeparator.ts | 2 -- src/parsers/swissDrivingLicense/parseDocumentCode.ts | 2 -- src/parsers/swissDrivingLicense/parseDocumentNumber.ts | 2 -- src/parsers/swissDrivingLicense/parseIssuingState.ts | 2 -- src/parsers/swissDrivingLicense/parseLanguageCode.ts | 2 -- src/types.ts | 2 -- tsconfig.json | 1 - 62 files changed, 5 insertions(+), 119 deletions(-) create mode 100644 builder/.eslintrc.yml diff --git a/.eslintrc.yml b/.eslintrc.yml index 9e0bb1b..7fa2f92 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,5 +1,3 @@ extends: cheminfo-typescript env: node: true -parserOptions: - sourceType: script diff --git a/builder/.eslintrc.yml b/builder/.eslintrc.yml new file mode 100644 index 0000000..639250e --- /dev/null +++ b/builder/.eslintrc.yml @@ -0,0 +1,2 @@ +parserOptions: + sourceType: script \ No newline at end of file diff --git a/builder/createStatesJs.js b/builder/createStatesJs.js index 5c9ba2a..a09b2f3 100644 --- a/builder/createStatesJs.js +++ b/builder/createStatesJs.js @@ -43,7 +43,6 @@ const statesObject = { }; const result = []; -result.push("'use strict';"); result.push(`const states = ${JSON.stringify(statesObject, null, 2)};`); result.push('Object.freeze(states);'); result.push('export default states;'); diff --git a/src/formats.ts b/src/formats.ts index f0fcc73..760dc09 100644 --- a/src/formats.ts +++ b/src/formats.ts @@ -1,5 +1,3 @@ -'use strict'; - export type FormatType = keyof typeof formats; export const formats = { diff --git a/src/generated/__tests__/states.test.ts b/src/generated/__tests__/states.test.ts index b57327b..86b8872 100644 --- a/src/generated/__tests__/states.test.ts +++ b/src/generated/__tests__/states.test.ts @@ -1,5 +1,3 @@ -'use strict'; - import states from '../states'; describe('check countries', function () { diff --git a/src/generated/states.ts b/src/generated/states.ts index 0f046ff..e108271 100644 --- a/src/generated/states.ts +++ b/src/generated/states.ts @@ -1,4 +1,3 @@ -'use strict'; const states = { "AFG": "Afghanistan", "ALB": "Albania", diff --git a/src/index.ts b/src/index.ts index b054f6d..a5afc2b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,3 @@ -'use strict'; - import { formats } from './formats'; import states from './generated/states'; import parse from './parse/parse'; diff --git a/src/parse/__tests__/errors.test.ts b/src/parse/__tests__/errors.test.ts index 6af58c1..05366c3 100644 --- a/src/parse/__tests__/errors.test.ts +++ b/src/parse/__tests__/errors.test.ts @@ -1,5 +1,3 @@ -'use strict'; - import parse from '../parse'; describe('Bad MRZ', () => { diff --git a/src/parse/__tests__/frenchDrivingLicense.test.ts b/src/parse/__tests__/frenchDrivingLicense.test.ts index 9e311f8..66a4f9a 100644 --- a/src/parse/__tests__/frenchDrivingLicense.test.ts +++ b/src/parse/__tests__/frenchDrivingLicense.test.ts @@ -1,5 +1,3 @@ -'use strict'; - import parse from '../parse'; describe('parse French Driving License', () => { diff --git a/src/parse/__tests__/frenchNationalId.test.ts b/src/parse/__tests__/frenchNationalId.test.ts index a3f04e4..d56464e 100644 --- a/src/parse/__tests__/frenchNationalId.test.ts +++ b/src/parse/__tests__/frenchNationalId.test.ts @@ -1,5 +1,3 @@ -'use strict'; - import parse from '../parse'; describe('parse French National Id', () => { diff --git a/src/parse/__tests__/swissDrivingLicense.test.ts b/src/parse/__tests__/swissDrivingLicense.test.ts index e0ffbd8..cd70e5d 100644 --- a/src/parse/__tests__/swissDrivingLicense.test.ts +++ b/src/parse/__tests__/swissDrivingLicense.test.ts @@ -1,5 +1,3 @@ -'use strict'; - import parse from '../parse'; describe('parse Swiss Driving License', () => { diff --git a/src/parse/__tests__/td1.test.ts b/src/parse/__tests__/td1.test.ts index 0495164..5117aab 100644 --- a/src/parse/__tests__/td1.test.ts +++ b/src/parse/__tests__/td1.test.ts @@ -1,5 +1,3 @@ -'use strict'; - import parse from '../parse'; describe('parse TD1', () => { diff --git a/src/parse/__tests__/td2.test.ts b/src/parse/__tests__/td2.test.ts index 23c35bf..e7fc787 100644 --- a/src/parse/__tests__/td2.test.ts +++ b/src/parse/__tests__/td2.test.ts @@ -1,5 +1,3 @@ -'use strict'; - import parse from '../parse'; describe('parse TD2', () => { diff --git a/src/parse/__tests__/td3.test.ts b/src/parse/__tests__/td3.test.ts index c27dbac..7fbee79 100644 --- a/src/parse/__tests__/td3.test.ts +++ b/src/parse/__tests__/td3.test.ts @@ -1,5 +1,3 @@ -'use strict'; - import parse from '../parse'; describe('parse TD3', () => { diff --git a/src/parse/autoCorrection.ts b/src/parse/autoCorrection.ts index 094c24f..9f877bf 100644 --- a/src/parse/autoCorrection.ts +++ b/src/parse/autoCorrection.ts @@ -1,5 +1,3 @@ -'use strict'; - import { Autocorrect } from '../types'; import { FieldOptions, fieldTypes } from './createFieldParser'; diff --git a/src/parse/checkLines.ts b/src/parse/checkLines.ts index e2a176a..3776689 100644 --- a/src/parse/checkLines.ts +++ b/src/parse/checkLines.ts @@ -1,5 +1,3 @@ -'use strict'; - export function checkLines(lines: string | string[]) { if (typeof lines === 'string') { lines = lines.split(/[\r\n]+/); diff --git a/src/parse/createFieldParser.ts b/src/parse/createFieldParser.ts index 1c4b9ed..bf8a591 100644 --- a/src/parse/createFieldParser.ts +++ b/src/parse/createFieldParser.ts @@ -1,5 +1,3 @@ -'use strict'; - import { ParseTextError } from '../parsers/parseText'; import { Autocorrect, Details, FieldName, Range } from '../types'; diff --git a/src/parse/fieldTemplates.ts b/src/parse/fieldTemplates.ts index 7df5d6f..786bdce 100644 --- a/src/parse/fieldTemplates.ts +++ b/src/parse/fieldTemplates.ts @@ -1,5 +1,3 @@ -'use strict'; - import parseCompositeCheckDigit from '../parsers/parseCompositeCheckDigit'; import parseDate from '../parsers/parseDate'; import parseDateCheckDigit from '../parsers/parseDateCheckDigit'; diff --git a/src/parse/frenchDrivingLicence.ts b/src/parse/frenchDrivingLicence.ts index 8f6e358..0d00b1d 100644 --- a/src/parse/frenchDrivingLicence.ts +++ b/src/parse/frenchDrivingLicence.ts @@ -1,5 +1,3 @@ -'use strict'; - import { formats } from '../formats'; import frenchDrivingLicenceFields from './frenchDrivingLicenceFields'; diff --git a/src/parse/frenchDrivingLicenceFields.ts b/src/parse/frenchDrivingLicenceFields.ts index 864faa4..4b239b9 100644 --- a/src/parse/frenchDrivingLicenceFields.ts +++ b/src/parse/frenchDrivingLicenceFields.ts @@ -1,5 +1,3 @@ -'use strict'; - import parseDocumentCode from '../parsers/frenchDrivingLicence/parseDocumentCode'; import { parseAlpha } from '../parsers/parseAlpha'; diff --git a/src/parse/frenchNationalId.ts b/src/parse/frenchNationalId.ts index bacd26c..052cb2a 100644 --- a/src/parse/frenchNationalId.ts +++ b/src/parse/frenchNationalId.ts @@ -1,5 +1,3 @@ -'use strict'; - import { formats } from '../formats'; import frenchNationalIdFields from './frenchNationalIdFields'; diff --git a/src/parse/frenchNationalIdFields.ts b/src/parse/frenchNationalIdFields.ts index f53665f..8115929 100644 --- a/src/parse/frenchNationalIdFields.ts +++ b/src/parse/frenchNationalIdFields.ts @@ -1,5 +1,3 @@ -'use strict'; - import { parseAlpha } from '../parsers/parseAlpha'; import parseDocumentCode from '../parsers/parseDocumentCodeId'; import { parseOptional } from '../parsers/parseOptional'; diff --git a/src/parse/getResult.ts b/src/parse/getResult.ts index 8a8a375..35e4150 100644 --- a/src/parse/getResult.ts +++ b/src/parse/getResult.ts @@ -1,5 +1,3 @@ -'use strict'; - import { FormatType } from '../formats'; import { Autocorrect, Details, FieldRecords, ParseResult } from '../types'; diff --git a/src/parse/parse.ts b/src/parse/parse.ts index d06e419..818ff60 100644 --- a/src/parse/parse.ts +++ b/src/parse/parse.ts @@ -1,4 +1,4 @@ -'use strict'; +import { ParseResult } from '../types'; import { checkLines } from './checkLines'; import { parsers } from './parsers'; @@ -6,10 +6,11 @@ import { parsers } from './parsers'; export interface ParseMRZOptions { autocorrect?: boolean; } + function parseMRZ( inputLines: string | string[], options: ParseMRZOptions = {}, -) { +): ParseResult { const lines = checkLines(inputLines); switch (lines.length) { case 1: { diff --git a/src/parse/parsers.ts b/src/parse/parsers.ts index d3113e9..2baf592 100644 --- a/src/parse/parsers.ts +++ b/src/parse/parsers.ts @@ -1,5 +1,3 @@ -'use strict'; - import parseFrenchDrivingLicense from './frenchDrivingLicence'; import parseFrenchNationalId from './frenchNationalId'; import parseSwissDrivingLicense from './swissDrivingLicense'; diff --git a/src/parse/swissDrivingLicense.ts b/src/parse/swissDrivingLicense.ts index 5f81f1e..59ed66f 100644 --- a/src/parse/swissDrivingLicense.ts +++ b/src/parse/swissDrivingLicense.ts @@ -1,5 +1,3 @@ -'use strict'; - import { formats } from '../formats'; import { getResult } from './getResult'; diff --git a/src/parse/swissDrivingLicenseFields.ts b/src/parse/swissDrivingLicenseFields.ts index 3b15f96..fc308e8 100644 --- a/src/parse/swissDrivingLicenseFields.ts +++ b/src/parse/swissDrivingLicenseFields.ts @@ -1,5 +1,3 @@ -'use strict'; - import { parseNumber } from '../parsers/parseNumber'; import { checkSeparator } from '../parsers/swissDrivingLicense/checkSeparator'; import parseDocumentCode from '../parsers/swissDrivingLicense/parseDocumentCode'; diff --git a/src/parse/td1.ts b/src/parse/td1.ts index 4c5c85d..30645a9 100644 --- a/src/parse/td1.ts +++ b/src/parse/td1.ts @@ -1,5 +1,3 @@ -'use strict'; - import { formats } from '../formats'; import { getResult } from './getResult'; diff --git a/src/parse/td1Fields.ts b/src/parse/td1Fields.ts index e9db398..998a632 100644 --- a/src/parse/td1Fields.ts +++ b/src/parse/td1Fields.ts @@ -1,5 +1,3 @@ -'use strict'; - import parseDocumentCode from '../parsers/parseDocumentCodeId'; import { parseDocumentNumberOptional } from '../parsers/parseDocumentNumberOptional'; import { parseOptional } from '../parsers/parseOptional'; diff --git a/src/parse/td2.ts b/src/parse/td2.ts index 032286b..ee81646 100644 --- a/src/parse/td2.ts +++ b/src/parse/td2.ts @@ -1,5 +1,3 @@ -'use strict'; - import { formats } from '../formats'; import { getResult } from './getResult'; diff --git a/src/parse/td2Fields.ts b/src/parse/td2Fields.ts index ded3f19..3258a9e 100644 --- a/src/parse/td2Fields.ts +++ b/src/parse/td2Fields.ts @@ -1,5 +1,3 @@ -'use strict'; - import parseDocumentCode from '../parsers/parseDocumentCodeId'; import { parseOptional } from '../parsers/parseOptional'; diff --git a/src/parse/td3.ts b/src/parse/td3.ts index 3d07a5d..472fed1 100644 --- a/src/parse/td3.ts +++ b/src/parse/td3.ts @@ -1,5 +1,3 @@ -'use strict'; - import { formats } from '../formats'; import { getResult } from './getResult'; diff --git a/src/parse/td3Fields.ts b/src/parse/td3Fields.ts index faf7334..7d89c74 100644 --- a/src/parse/td3Fields.ts +++ b/src/parse/td3Fields.ts @@ -1,5 +1,3 @@ -'use strict'; - import parseDocumentCode from '../parsers/parseDocumentCodePassport'; import { parsePersonalNumber } from '../parsers/parsePersonalNumber'; import { parsePersonalNumberCheckDigit } from '../parsers/parsePersonalNumberCheckDigit'; diff --git a/src/parsers/__tests__/check.test.ts b/src/parsers/__tests__/check.test.ts index 0bf9662..c9e48fd 100644 --- a/src/parsers/__tests__/check.test.ts +++ b/src/parsers/__tests__/check.test.ts @@ -1,5 +1,3 @@ -'use strict'; - import { check } from '../check'; test('check digits', () => { diff --git a/src/parsers/check.ts b/src/parsers/check.ts index 4fe653c..344778b 100644 --- a/src/parsers/check.ts +++ b/src/parsers/check.ts @@ -1,5 +1,3 @@ -'use strict'; - export function check(string: string, value: string | number) { let code = 0; const factors = [7, 3, 1]; diff --git a/src/parsers/cleanText.ts b/src/parsers/cleanText.ts index acbebdc..1e7c00a 100644 --- a/src/parsers/cleanText.ts +++ b/src/parsers/cleanText.ts @@ -1,5 +1,3 @@ -'use strict'; - export function cleanText(string: string) { return string.replace(/<+$/g, '').replace(/