Skip to content

Commit d977ab3

Browse files
committed
fix: linter fix
1 parent 30e1124 commit d977ab3

File tree

7 files changed

+29
-28
lines changed

7 files changed

+29
-28
lines changed

src/cli/cli.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export async function initializeCli() {
2222

2323
const myArgs = process.argv.slice(2);
2424
if (
25-
myArgs.length == 0 ||
26-
myArgs[0] == commands.help1 ||
27-
myArgs[0] == commands.help2
25+
myArgs.length === 0 ||
26+
myArgs[0] === commands.help1 ||
27+
myArgs[0] === commands.help2
2828
) {
2929
help();
3030
return;
@@ -40,21 +40,21 @@ export async function help() {
4040
async function translate() {
4141
const myArgs = process.argv.slice(2);
4242

43-
if (myArgs[1] && typeof myArgs[1] == 'string') {
43+
if (myArgs[1] && typeof myArgs[1] === 'string') {
4444
const file_path = myArgs[1];
4545
await readProxyFile(file_path);
4646
}
4747

4848
// no path condition
4949
let objectPath = myArgs[0];
50-
if (objectPath == undefined || objectPath == '') {
50+
if (objectPath === undefined || objectPath === '') {
5151
error(messages.file.no_path + ' ' + messages.cli.usage);
5252
return;
5353
}
5454

5555
// no file in the path condition
5656
let { json_obj } = await getFileFromPath(objectPath);
57-
if (json_obj == undefined) {
57+
if (json_obj === undefined) {
5858
error(messages.file.no_file_in_path);
5959
return;
6060
}
@@ -108,7 +108,7 @@ async function translate() {
108108
to = answers.to;
109109
});
110110

111-
if (to.length == 0 || to == undefined) {
111+
if (to.length === 0 || to === undefined) {
112112
warn(messages.cli.no_selected_language);
113113
return;
114114
}
@@ -151,7 +151,7 @@ function getLanguageChoices(): {
151151
to_choices: LanguageCodes;
152152
} {
153153
let from_choices = getFromChoices();
154-
let to_choices = from_choices.filter(language => language != `Automatic`);
154+
let to_choices = from_choices.filter(language => language !== `Automatic`);
155155

156156
return { from_choices, to_choices };
157157
}

src/core/core.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ export async function plaintranslate(
1717

1818
let translatedWord = '';
1919

20-
if (global.source == Sources.LibreTranslate) {
20+
if (global.source === Sources.LibreTranslate) {
2121
translatedWord = await translateWithLibre(ignored_word, from, to);
22-
} else if (global.source == Sources.ArgosTranslate) {
22+
} else if (global.source === Sources.ArgosTranslate) {
2323
translatedWord = await translateWithArgos(ignored_word, from, to);
24-
} else if (global.source == Sources.BingTranslate) {
24+
} else if (global.source === Sources.BingTranslate) {
2525
translatedWord = await translateWithBing(ignored_word, from, to);
2626
} else {
2727
if (
2828
global.proxyList &&
2929
global.proxyList.length > 0 &&
30-
global.proxyIndex != -1
30+
global.proxyIndex !== -1
3131
) {
3232
let proxy = global.proxyList[global.proxyIndex];
3333

@@ -133,7 +133,7 @@ async function translateWithGoogle(
133133
to: to,
134134
},
135135
{
136-
agent: options != undefined ? options.agent : undefined,
136+
agent: options !== undefined ? options.agent : undefined,
137137
}
138138
);
139139

@@ -163,7 +163,7 @@ export function getRootFolder(path: string) {
163163

164164
let root = arr.join('/');
165165

166-
if (root == undefined || root == '') {
166+
if (root === undefined || root === '') {
167167
root = './';
168168
}
169169

@@ -184,7 +184,7 @@ export async function saveFilePublic(path: string, data: any) {
184184
export function safeValueTransition(value: string) {
185185
const value_safety: ValueSafety = valueIsSafe(value);
186186

187-
if (value_safety.is_safe == true) {
187+
if (value_safety.is_safe === true) {
188188
return value;
189189
}
190190

@@ -208,14 +208,14 @@ function valueIsSafe(value: string): ValueSafety {
208208
type: undefined,
209209
};
210210

211-
if (value == undefined) {
211+
if (value === undefined) {
212212
result.is_safe = false;
213213
result['type'] = nonSafeTypes.undefined;
214214

215215
return result;
216216
}
217217

218-
if (value == null) {
218+
if (value === null) {
219219
result.is_safe = false;
220220
result['type'] = nonSafeTypes.null;
221221

@@ -229,7 +229,7 @@ function valueIsSafe(value: string): ValueSafety {
229229
return result;
230230
}
231231

232-
if (value == '') {
232+
if (value === '') {
233233
result.is_safe = false;
234234
result['type'] = nonSafeTypes.empty;
235235

src/core/json_file.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function fileTranslator(
1414
let { json_obj } = file_from_path;
1515
objectPath = file_from_path.objectPath;
1616

17-
if (json_obj == undefined) {
17+
if (json_obj === undefined) {
1818
error(messages.file.no_file_in_path);
1919
return;
2020
}
@@ -23,15 +23,15 @@ export async function fileTranslator(
2323

2424
let new_json_obj = await objectTranslator(json_obj, from, to);
2525

26-
if (new_json_obj == undefined) {
26+
if (new_json_obj === undefined) {
2727
error(messages.file.cannot_translate);
2828
return;
2929
}
3030

3131
let latest_path = objectPath.replace(/\\/g, '/');
3232
let root_folder = getRootFolder(latest_path);
3333

34-
if (Array.isArray(new_json_obj) == true && Array.isArray(to) == true) {
34+
if (Array.isArray(new_json_obj) === true && Array.isArray(to) === true) {
3535
// multiple file saving
3636
(new_json_obj as Array<translatedObject>).forEach(
3737
async (element, index) => {
@@ -62,7 +62,7 @@ export async function getFileFromPath(
6262
): Promise<{ json_obj: any; objectPath: string }> {
6363
let json_obj: any = await getFile(objectPath);
6464

65-
if (json_obj == undefined) {
65+
if (json_obj === undefined) {
6666
objectPath = __dirname + '\\' + objectPath;
6767

6868
json_obj = await getFile(objectPath);

src/core/json_object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function objectTranslator(
1313
): Promise<translatedObject | translatedObject[]> {
1414
if (object && from && to) {
1515
// need to translate to more than 1 languages
16-
if (typeof to == 'object') {
16+
if (typeof to === 'object') {
1717
let general_object: translatedObject[] | null[] = [];
1818

1919
await Promise.all(

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ export type LanguageCode = string;
4949
export type LanguageCodes = LanguageCode[];
5050

5151
export function getLanguages() {
52-
if (global.source == Sources.LibreTranslate) {
52+
if (global.source === Sources.LibreTranslate) {
5353
return LibreTranslateLanguages;
54-
} else if (global.source == Sources.ArgosTranslate) {
54+
} else if (global.source === Sources.ArgosTranslate) {
5555
return ArgosTranslateLanguages;
56-
} else if (global.source == Sources.BingTranslate) {
56+
} else if (global.source === Sources.BingTranslate) {
5757
return BingTranslateLanguages;
5858
}
5959

src/utils/console.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export const commands = {
3030

3131
export const language_choices: { [key: string]: string } = {
3232
GoogleTranslate: `Google Translate (104 languages)`,
33-
BingTranslate: 'Bing Microsoft Translate (110 languages) \x1b[33m**NEW**\x1b[0m',
33+
BingTranslate:
34+
'Bing Microsoft Translate (110 languages) \x1b[33m**NEW**\x1b[0m',
3435
LibreTranslate: `Libre Translate (29 languages)`,
3536
ArgosTranslate: `Argos Translate (17 languages)`,
3637
};

src/utils/micro.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function getEnumKeyByEnumValue(
1414
myEnum: any,
1515
enumValue: number | string
1616
): string {
17-
let keys = Object.keys(myEnum).filter(x => myEnum[x] == enumValue);
17+
let keys = Object.keys(myEnum).filter(x => myEnum[x] === enumValue);
1818
return keys.length > 0 ? keys[0] : '';
1919
}
2020

0 commit comments

Comments
 (0)