30}
31declare global {
32 // eslint-disable-next-line no-var
33 var crowdinOta: { common: OtaClient; database: OtaClient } | undefined34}
35const { crowdinDistTimestamp, fetchCrowdinDbKey, fetchCrowdinFile } = createCommonFns(crowdinOta)
36
26}
27declare global {
28 // eslint-disable-next-line no-var
29 var crowdinEdgeOta: { common: OtaClient; database: OtaClient } | undefined30}
31
32const { crowdinDistTimestamp, fetchCrowdinDbKey, fetchCrowdinFile } = createCommonFns(crowdinEdgeOta)
17}
18declare global {
19 // eslint-disable-next-line no-var
20 var crowdinApi: Crowdin | undefined21}
22export const {
23 addSingleKey,
13
14declare global {
15 // eslint-disable-next-line no-var -- allow global `var` declarations
16 var prisma: PrismaClient<typeof clientOptions> | undefined17}
18
19const clientOptions = {
17 global.crowdinEdge = crowdinEdge
18}
19declare global {
20 var crowdinEdge: Crowdin | undefined21}
22export const { getStringIdByKey } = createCommonFns(crowdinEdge)
23export { branches, sourceFiles, projectId } from '../constants'
Declare variables at the top of their scope as it improves code readability, performance and also helps in code navigation.
The vars-on-top
rule generates warnings when variable declarations are not used serially at the top of a function scope or the top of a program. By default variable declarations are always moved (“hoisted”) invisibly to the top of their containing scope by the JavaScript interpreter. This rule forces the programmer to represent that behavior by manually moving the variable declaration to the top of its containing scope.
// Variable declarations in a block:
function doSomething() {
var first;
if (true) {
first = true;
}
var second;
}
// Variable declaration in for initializer:
function doSomething() {
for (var i=0; i<10; i++) {}
}
function doSomething() {
var first;
var second; //multiple declarations are allowed at the top
if (true) {
first = true;
}
}
function doSomething() {
var i;
for (i=0; i<10; i++) {}
}