Skip to content

Commit b7348a4

Browse files
committed
fix: lint
1 parent cae4fc9 commit b7348a4

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.9.0",
2+
"version": "1.10.0",
33
"license": "MIT",
44
"main": "dist/index.js",
55
"description": "Translate your JSON file or object into another languages with Google Translate API",

src/cli/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { listIOS, getLanguages, Sources, TRANSLATE_POSTFIX, translatorsNames } from '..';
1+
import { getLanguages, Sources, TRANSLATE_POSTFIX, translatorsNames } from '..';
22
import { fileTranslator, getFileFromPath } from '../core/json_file';
33
import {
44
error,

src/core/core.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from 'fs/promises';
2-
import * as YAML from "yaml"
2+
import * as YAML from 'yaml';
33
import { matchYamlExt } from '../utils/yaml';
44
import { error, messages } from '../utils/console';
55
import { default_value, translation_value_limit } from '../utils/micro';
@@ -11,9 +11,11 @@ export async function getFile(objectPath: string) {
1111
.readFile(objectPath, 'utf8')
1212
.then(data => {
1313
// This function should return a string with JSON-encoded data.
14-
// To preserve the contract, YAML files should be parsed to object
14+
// To preserve the contract, YAML files should be parsed to object
1515
// and then stringified to JSON string.
16-
json_file = matchYamlExt(objectPath) ? JSON.stringify(YAML.parse(data)) : data;
16+
json_file = matchYamlExt(objectPath)
17+
? JSON.stringify(YAML.parse(data))
18+
: data;
1719
})
1820
.catch(_ => {
1921
json_file = undefined;
@@ -36,7 +38,7 @@ export function getRootFolder(path: string) {
3638
}
3739

3840
export async function saveFilePublic(path: string, data: any) {
39-
// When path extension is for YAML file, then stringify with YAML encoder.
41+
// When path extension is for YAML file, then stringify with YAML encoder.
4042
// Otherwise, default JSON encoder is used.
4143
var json = matchYamlExt(path) ? YAML.stringify(data) : JSON.stringify(data);
4244

src/core/json_file.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { error, messages, success } from '../utils/console';
33
import { getLanguageFromCode } from '../utils/micro';
44
import { getFile, getRootFolder, saveFilePublic } from './core';
55
import { objectTranslator } from './json_object';
6-
import { matchYamlExt } from "../utils/yaml";
6+
import { matchYamlExt } from '../utils/yaml';
77

88
export async function fileTranslator(
99
objectPath: string,
@@ -34,10 +34,10 @@ export async function fileTranslator(
3434
let root_folder = getRootFolder(latest_path);
3535

3636
// Check if source file has YAML extension and return the extension ("yml" or "yaml").
37-
const source_file_match_yaml_ext = matchYamlExt(latest_path)
38-
// When source file has "yml" or "yaml" extension, use the same in output file path.
37+
const source_file_match_yaml_ext = matchYamlExt(latest_path);
38+
// When source file has "yml" or "yaml" extension, use the same in output file path.
3939
// Otherwise, default "json" extension used.
40-
const file_ext = source_file_match_yaml_ext || "json";
40+
const file_ext = source_file_match_yaml_ext || 'json';
4141

4242
if (Array.isArray(new_json_obj) === true && Array.isArray(to) === true) {
4343
// multiple file saving
@@ -59,7 +59,9 @@ export async function fileTranslator(
5959
} else {
6060
new_json_obj = (new_json_obj as translatedObject).data;
6161

62-
let file_name = newFileName ? `/${newFileName}.${to}.${file_ext}` : `/${to}.${file_ext}`;
62+
let file_name = newFileName
63+
? `/${newFileName}.${to}.${file_ext}`
64+
: `/${to}.${file_ext}`;
6365

6466
await saveFilePublic(root_folder + file_name, new_json_obj);
6567

src/utils/yaml.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
2-
*
2+
*
33
* @param objectPath path to file
44
* @returns File extension without leading "." ("yml" or "yaml")
55
*/
6-
export const matchYamlExt = (objectPath: string) => objectPath.match(/\.(ya?ml)$/)?.[1];
6+
export const matchYamlExt = (objectPath: string) =>
7+
objectPath.match(/\.(ya?ml)$/)?.[1];

0 commit comments

Comments
 (0)