Skip to content

Commit 64fb207

Browse files
committed
Clean imports
1 parent d58fa35 commit 64fb207

File tree

240 files changed

+729
-727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+729
-727
lines changed

jest.config.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import type { Config } from "@jest/types"
1+
import { type Config } from "@jest/types"
22
import tsConfig from './tsconfig.json'
3+
34
const paths = tsConfig.compilerOptions.paths
45

56
const aliasPattern = /^(@.*)\/\*$/
@@ -8,32 +9,32 @@ const sourcePattern = /^(.*)\/\*$/
89
const moduleNameMapper: { [key: string]: string } = {}
910

1011
Object.entries(paths).forEach(([alias, sourceArr]) => {
11-
if (!aliasPattern.test(alias)) {
12-
return
13-
}
14-
if (sourceArr.length !== 1 || !sourcePattern.test(sourceArr[0])) {
15-
return
16-
}
17-
const prefix = alias.match(aliasPattern)[1]
18-
const pattern = `^${prefix}/(.*)$`
19-
const source = sourceArr[0].match(sourcePattern)[1]
20-
const sourcePath = `<rootDir>/${source}/$1`
21-
moduleNameMapper[pattern] = sourcePath
12+
if (!aliasPattern.test(alias)) {
13+
return
14+
}
15+
if (sourceArr.length !== 1 || !sourcePattern.test(sourceArr[0])) {
16+
return
17+
}
18+
const prefix = alias.match(aliasPattern)[1]
19+
const pattern = `^${prefix}/(.*)$`
20+
const source = sourceArr[0].match(sourcePattern)[1]
21+
const sourcePath = `<rootDir>/${source}/$1`
22+
moduleNameMapper[pattern] = sourcePath
2223
})
2324

2425
console.log("The moduleNameMapper parsed from tsconfig.json: ")
2526
console.log(moduleNameMapper)
2627

2728
const config: Config.InitialOptions = {
28-
moduleNameMapper,
29-
roots: [
30-
"<rootDir>/test"
31-
],
32-
testRegex: 'test/(.+)\\.test\\.(jsx?|tsx?)$',
33-
transform: {
34-
"^.+\\.tsx?$": "ts-jest"
35-
},
36-
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
29+
moduleNameMapper,
30+
roots: [
31+
"<rootDir>/test"
32+
],
33+
testRegex: 'test/(.+)\\.test\\.(jsx?|tsx?)$',
34+
transform: {
35+
"^.+\\.tsx?$": "ts-jest"
36+
},
37+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
3738
}
3839

3940
export default config

script/crowdin/client.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import Crowdin, {
2-
Credentials,
3-
Pagination,
4-
PatchRequest,
5-
ResponseList,
6-
SourceFilesModel,
7-
SourceStringsModel,
8-
StringTranslationsModel,
9-
UploadStorageModel,
2+
type Credentials,
3+
type Pagination,
4+
type PatchRequest,
5+
type ResponseList,
6+
type SourceFilesModel,
7+
type SourceStringsModel,
8+
type StringTranslationsModel,
9+
type UploadStorageModel,
1010
} from '@crowdin/crowdin-api-client'
11-
import { ALL_CROWDIN_LANGUAGES, CrowdinLanguage, Dir, ItemSet } from './common'
11+
import { ALL_CROWDIN_LANGUAGES, type CrowdinLanguage, type Dir, type ItemSet } from './common'
1212

1313
const PROJECT_ID = 516822
1414

script/crowdin/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs'
22
import path from 'path'
33
import { exitWith } from '../util/process'
4-
import { CrowdinClient } from './client'
4+
import { type CrowdinClient } from './client'
55

66
export const ALL_DIRS = ['app', 'common', 'popup', 'side', 'cs'] as const
77

script/crowdin/export-translation.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ import { existsSync, readdirSync, readFileSync, rm, writeFile } from "fs"
33
import { join } from "path"
44
import { getClientFromEnv } from "./client"
55
import {
6-
ALL_DIRS, ALL_TRANS_LOCALES, RSC_FILE_SUFFIX,
7-
checkMainBranch, crowdinLangOf, Dir, ItemSet, mergeMessage, transMsg
6+
ALL_DIRS, ALL_TRANS_LOCALES,
7+
checkMainBranch,
8+
crowdinLangOf,
9+
type Dir,
10+
type ItemSet,
11+
mergeMessage,
12+
RSC_FILE_SUFFIX,
13+
transMsg
814
} from "./common"
915

1016
const TEMP_FILE_NAME = join(process.cwd(), ".crowdin-temp.zip")

script/crowdin/sync-source.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { SourceFilesModel, SourceStringsModel } from "@crowdin/crowdin-api-client"
1+
import { type SourceFilesModel, type SourceStringsModel } from "@crowdin/crowdin-api-client"
22
import { groupBy } from "@util/array"
3-
import { CrowdinClient, getClientFromEnv, NameKey } from "./client"
3+
import { type CrowdinClient, getClientFromEnv, type NameKey } from "./client"
44
import {
55
ALL_DIRS,
66
Dir,

script/crowdin/sync-translation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

2-
import { SourceFilesModel } from "@crowdin/crowdin-api-client"
2+
import { type SourceFilesModel } from "@crowdin/crowdin-api-client"
33
import { groupBy } from "@util/array"
44
import { exitWith } from "../util/process"
5-
import { CrowdinClient, getClientFromEnv } from "./client"
5+
import { type CrowdinClient, getClientFromEnv } from "./client"
66
import {
77
ALL_DIRS, ALL_TRANS_LOCALES,
8-
CrowdinLanguage, Dir, ItemSet,
8+
type CrowdinLanguage, type Dir, type ItemSet,
99
checkMainBranch, crowdinLangOf, isIgnored, readAllMessages, transMsg,
1010
} from "./common"
1111

script/psl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Build psl tree
33
*/
44

5-
import { PslTree } from '@util/psl'
5+
import { type PslTree } from '@util/psl'
66
import axios from 'axios'
77
import { writeFileSync } from 'fs'
88
import path from 'path'

script/user-chart/add.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
22
createGist as createGistApi,
33
getJsonFileContent,
4-
Gist,
5-
GistForm,
4+
type Gist,
5+
type GistForm,
66
updateGist as updateGistApi
77
} from "@src/api/gist"
88
import fs from "fs"
@@ -85,7 +85,7 @@ function parseChrome(content: string): UserCount {
8585
if (!dateStr || !numberStr) {
8686
return
8787
}
88-
// Replace '/' to '-', then rjust month and date
88+
// Replace '/' to '-', then rjust month and date
8989
const date = dateStr.split('/').map(str => rjust(str, 2, '0')).join('-')
9090
const number = parseInt(numberStr)
9191
date && number && (result[date] = number)
@@ -106,7 +106,7 @@ function parseEdge(content: string): UserCount {
106106
if (!dateStr || !numberStr) {
107107
return
108108
}
109-
// Replace '/' to '-', then rjust month and date
109+
// Replace '/' to '-', then rjust month and date
110110
const date = dateStr.split('/').map(str => rjust(str, 2, '0')).join('-')
111111
const number = parseInt(numberStr)
112112
date && number && (result[date] = number)

script/user-chart/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { findTarget, Gist } from "@api/gist"
1+
import { findTarget, type Gist } from "@api/gist"
22
import { exitWith } from "../util/process"
33

44
/**

script/user-chart/render.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {
22
createGist,
3-
FileForm,
3+
type FileForm,
44
findTarget,
55
getJsonFileContent,
6-
Gist,
7-
GistForm,
6+
type Gist,
7+
type GistForm,
88
updateGist
99
} from "@api/gist"
10-
import { EChartsType, init } from "echarts"
10+
import { type EChartsType, init } from "echarts"
1111
import { writeFileSync } from "fs"
1212
import { exit } from "process"
1313
import { filenameOf, getExistGist, validateTokenFromEnv } from "./common"

0 commit comments

Comments
 (0)