Skip to content

Commit 27a34ca

Browse files
authored
Merge pull request #32 from sillsdev/eslint
fix: eslint (#32)
2 parents f650259 + 56cbb16 commit 27a34ca

18 files changed

Lines changed: 2888 additions & 1739 deletions

File tree

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"macrolanguage",
1717
"Subtag",
1818
"subtags",
19+
"tseslint",
1920
"typecheck"
2021
]
2122
}

components/language-chooser/common/find-language/.eslintrc.cjs

Lines changed: 0 additions & 18 deletions
This file was deleted.

components/language-chooser/common/find-language/findLanguageInterfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ export interface ILanguage {
2020
alternativeTags: string[];
2121
isForMacrolanguageDisambiguation?: boolean;
2222
isMacrolanguage?: boolean;
23+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2324
[key: string]: any; // allow indexing by string
2425
}

components/language-chooser/common/find-language/langtagProcessing.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
// This file has lots of anys in order to parse and process langtags.json
13
import { iso15924 } from "iso-15924";
24
import langTagsJson from "./language-data/langtags.json" assert { type: "json" };
35
import fs from "fs";
@@ -92,7 +94,7 @@ function getAllPossibleNames(entry: any) {
9294
function autonymOrFallback(entry: any, fallback: string | undefined) {
9395
// We are currently ignoring the "localname" field because it appears to be more specific than what we want,
9496
// e.g. the "es-Latn-ES" entry of langtags.json has "localname": "español de España" and "localnames": [ "castellano", "español" ]
95-
return entry.localnames ? entry.localnames[0] : undefined ?? fallback;
97+
return entry.localnames ? entry.localnames[0] : fallback;
9698
}
9799

98100
// We want to have one entry for every ISO 639-3 code, whereas langtags.json sometimes has multiple entries per code
@@ -245,7 +247,7 @@ function parseLangTagsTxt() {
245247
const langTagsTxtRaw = fs.readFileSync("language-data/langtags.txt", "utf8");
246248
const langTagsTxt = langTagsTxtRaw.replaceAll("*", "");
247249
const lines = langTagsTxt.split("\n");
248-
const tagLookups = [];
250+
const tagLookups: any[] = [];
249251
for (const line of lines) {
250252
if (line.length === 0) {
251253
continue;

components/language-chooser/common/find-language/matchingSubstringDemarcation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function deepStripDemarcation<T>(demarcated: T): T {
6060
return demarcated.map((element) => deepStripDemarcation(element)) as T;
6161
}
6262
if (typeof demarcated === "object") {
63-
const newObject = {} as any;
63+
const newObject: any = {};
6464
for (const key of Object.keys(demarcated)) {
6565
newObject[key] = deepStripDemarcation((demarcated as any)[key]);
6666
}
@@ -76,7 +76,7 @@ export function deepStripDemarcation<T>(demarcated: T): T {
7676
export function demarcateExactMatches(searchString: string, result: ILanguage) {
7777
for (const field of fieldsToSearch) {
7878
if (Array.isArray(result[field])) {
79-
result[field] = result[field].map((value: any) =>
79+
result[field] = result[field].map((value: string) =>
8080
demarcateExactMatchString(searchString, value)
8181
);
8282
} else if (typeof result[field] === "string") {

components/language-chooser/common/find-language/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
"main": "./index.js",
88
"types": "./index.d.ts",
99
"scripts": {
10-
"langtag-processing": "ts-node-esm ./langtagProcessing.ts",
10+
"langtag-processing": "tsx ./langtagProcessing.ts",
1111
"build": "nx vite:build",
1212
"typecheck": "tsc",
13-
"test": "nx vite:test --config vitest.config.ts"
13+
"test": "nx vite:test --config vitest.config.ts",
14+
"lint": "eslint ."
1415
},
1516
"dependencies": {
1617
"fuse.js": "^7.0.0",
@@ -20,11 +21,11 @@
2021
"devDependencies": {
2122
"@nx/vite": "^19.1.2",
2223
"@types/node": "^20.16.11",
23-
"ts-node": "^10.9.2",
24+
"tsx": "^4.19.2",
2425
"typescript": "^5.2.2"
2526
},
2627
"// We've tested with 18 and have no reason to believe it won't work with higher versions": "",
2728
"engines": {
28-
"node": ">=18.0.0"
29+
"node": ">=18.18"
2930
}
3031
}

components/language-chooser/common/find-language/testUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ILanguage } from "./findLanguageInterfaces";
1+
import { ILanguage, IScript } from "./findLanguageInterfaces";
22

33
interface ILanguageTestEntry {
44
autonym?: string;
@@ -7,7 +7,7 @@ interface ILanguageTestEntry {
77
languageSubtag?: string;
88
regionNames?: string;
99
names?: string[];
10-
scripts?: any[];
10+
scripts?: IScript[];
1111
variants?: string;
1212
alternativeTags?: string[];
1313
}

components/language-chooser/react/common/language-chooser-react-hook/package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"typecheck": "tsc",
1111
"prebuild": "npm run typecheck",
1212
"build": "nx vite:build",
13-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
13+
"lint": "eslint .",
1414
"test": "nx vite:test --config vitest.config.ts"
1515
},
1616
"dependencies": {
@@ -23,17 +23,12 @@
2323
"@types/lodash": "^4.17.7",
2424
"@types/react": "^17",
2525
"@types/react-dom": "^17",
26-
"@typescript-eslint/eslint-plugin": "^6.14.0",
27-
"@typescript-eslint/parser": "^6.14.0",
2826
"@vitejs/plugin-react": "^4.2.1",
29-
"eslint": "^8.55.0",
30-
"eslint-plugin-react-hooks": "^4.6.0",
31-
"eslint-plugin-react-refresh": "^0.4.5",
3227
"typescript": "^5.2.2",
3328
"vite-plugin-dts": "^4.2.1"
3429
},
35-
"// We've tested with 18 and have no reason to believe it won't work with higher versions": "",
30+
"// We've tested with 18.18 and have no reason to believe it won't work with higher versions": "",
3631
"engines": {
37-
"node": ">=18.0.0"
32+
"node": ">=18.18"
3833
}
3934
}

components/language-chooser/react/common/language-chooser-react-hook/useLanguageChooser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { useMemo, useState } from "react";
1010
import { FuseResult } from "fuse.js";
1111
import {
1212
ICustomizableLanguageDetails,
13-
IOrthography,
1413
isUnlistedLanguage,
1514
parseLangtagFromLangChooser,
1615
UNLISTED_LANGUAGE,
@@ -145,7 +144,7 @@ export const useLanguageChooser = (
145144
setSelectedLanguage(language);
146145
setSelectedScript(
147146
// If there is only one script option for this language, automatically select it
148-
language.scripts.length == 1 ? language.scripts[0] : undefined
147+
language.scripts.length === 1 ? language.scripts[0] : undefined
149148
);
150149
setCustomizableLanguageDetails({
151150
displayName: stripDemarcation(

components/language-chooser/react/language-chooser-react-mui/package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"typecheck": "tsc",
1515
"prebuild": "npm run typecheck",
1616
"build": "nx vite:build",
17-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
17+
"lint": "eslint ."
1818
},
1919
"dependencies": {
2020
"lodash": "^4.17.21",
@@ -32,12 +32,6 @@
3232
"@types/react": "^17",
3333
"@types/react-dom": "^17",
3434
"@types/react-lazyload": "^3.2.3",
35-
"@typescript-eslint/eslint-plugin": "^6.14.0",
36-
"@typescript-eslint/parser": "^6.14.0",
37-
"@vitejs/plugin-react": "^4.2.1",
38-
"eslint": "^8.55.0",
39-
"eslint-plugin-react-hooks": "^4.6.0",
40-
"eslint-plugin-react-refresh": "^0.4.5",
4135
"storybook": "^8.2.8",
4236
"typescript": "^5.2.2",
4337
"vite-plugin-dts": "^4.2.1"
@@ -52,6 +46,6 @@
5246
},
5347
"// We've tested with 18 and have no reason to believe it won't work with higher versions": "",
5448
"engines": {
55-
"node": ">=18.0.0"
49+
"node": ">=18.18"
5650
}
5751
}

0 commit comments

Comments
 (0)