aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinigami <[email protected]>2022-01-30 19:37:21 +0100
committerGitHub <[email protected]>2022-01-30 19:37:21 +0100
commit6c5b9706eb16f8841d3f3b2109b8a21fb65fa04a (patch)
tree7b043e25d6fe971c3223851b2ccac8338e51d8a8
parentd4125e2a7d69042c37ccecea89f1525c4424a45b (diff)
downloadfaker-6c5b9706eb16f8841d3f3b2109b8a21fb65fa04a.tar.xz
faker-6c5b9706eb16f8841d3f3b2109b8a21fb65fa04a.zip
chore: use recommended restrict-plus-operands (#369)
-rw-r--r--.eslintrc.js1
-rw-r--r--scripts/apidoc.ts2
-rw-r--r--src/commerce.ts2
-rw-r--r--src/finance.ts15
-rw-r--r--src/image.ts25
-rw-r--r--src/image_providers/lorempicsum.ts6
-rw-r--r--src/image_providers/lorempixel.ts4
-rw-r--r--src/image_providers/unsplash.ts2
-rw-r--r--src/internet.ts19
-rw-r--r--src/lorem.ts2
-rw-r--r--src/vehicle.ts35
-rw-r--r--src/vendor/mersenne.ts5
-rw-r--r--src/vendor/unique.ts4
-rw-r--r--src/vendor/user-agent.ts95
-rw-r--r--test/database.spec.ts14
-rw-r--r--test/finance.spec.ts52
-rw-r--r--test/finance_iban.spec.ts16
17 files changed, 114 insertions, 185 deletions
diff --git a/.eslintrc.js b/.eslintrc.js
index ab862365..33042eeb 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -41,7 +41,6 @@ module.exports = defineConfig({
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'warn',
- '@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/restrict-template-expressions': [
'error',
{
diff --git a/scripts/apidoc.ts b/scripts/apidoc.ts
index 3d972c95..f07e5e06 100644
--- a/scripts/apidoc.ts
+++ b/scripts/apidoc.ts
@@ -232,7 +232,7 @@ async function build(): Promise<void> {
.map((tag) => tag.text.trimEnd()) || [];
if (examples.length !== 0) {
- console.log('Example-Length: ' + examples);
+ console.log('Example-Length:', examples);
content += examples.join('\n') + '\n';
}
diff --git a/src/commerce.ts b/src/commerce.ts
index 61a5f5a1..1d6ac91d 100644
--- a/src/commerce.ts
+++ b/src/commerce.ts
@@ -64,7 +64,7 @@ export class Commerce {
symbol: string = ''
): string {
if (min < 0 || max < 0) {
- return symbol + 0.0;
+ return `${symbol}${0.0}`;
}
const randValue = this.faker.datatype.number({ max: max, min: min });
diff --git a/src/finance.ts b/src/finance.ts
index 2d00570a..719d1198 100644
--- a/src/finance.ts
+++ b/src/finance.ts
@@ -64,7 +64,7 @@ export class Finance {
sum += Number(routingNumber[i + 2]) || 0;
}
- return routingNumber + (Math.ceil(sum / 10) * 10 - sum);
+ return `${routingNumber}${Math.ceil(sum / 10) * 10 - sum}`;
}
/**
@@ -293,7 +293,12 @@ export class Finance {
* @method faker.finance.iban
*/
iban(formatted: boolean = false, countryCode: string): string {
- let ibanFormat;
+ let ibanFormat: {
+ bban: Array<{ type: string; count: number }>;
+ country: string;
+ total?: number;
+ format?: string;
+ };
if (countryCode) {
const findFormat = (currentFormat) =>
currentFormat.country === countryCode;
@@ -341,12 +346,12 @@ export class Finance {
let checksum: string | number =
98 -
this.ibanLib.mod97(
- this.ibanLib.toDigitString(s + ibanFormat.country + '00')
+ this.ibanLib.toDigitString(`${s}${ibanFormat.country}00`)
);
if (checksum < 10) {
- checksum = '0' + checksum;
+ checksum = `0${checksum}`;
}
- const iban = ibanFormat.country + checksum + s;
+ const iban = `${ibanFormat.country}${checksum}${s}`;
return formatted ? iban.match(/.{1,4}/g).join(' ') : iban;
}
diff --git a/src/image.ts b/src/image.ts
index 00e94114..1a74f26e 100644
--- a/src/image.ts
+++ b/src/image.ts
@@ -87,13 +87,13 @@ export class Image {
if (typeof https !== 'undefined' && https === true) {
protocol = 'https://';
}
- let url = protocol + 'placeimg.com/' + width + '/' + height;
+ let url = `${protocol}placeimg.com/${width}/${height}`;
if (typeof category !== 'undefined') {
url += '/' + category;
}
if (randomize) {
- url += '?' + this.faker.datatype.number();
+ url += `?${this.faker.datatype.number()}`;
}
return url;
@@ -264,22 +264,11 @@ export class Image {
* @param color
*/
dataUri(width?: number, height?: number, color: string = 'grey'): string {
- const svgString =
- '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full" width="' +
- width +
- '" height="' +
- height +
- '"><rect width="100%" height="100%" fill="' +
- color +
- '"/><text x="' +
- width / 2 +
- '" y="' +
- height / 2 +
- '" font-size="20" alignment-baseline="middle" text-anchor="middle" fill="white">' +
- width +
- 'x' +
- height +
- '</text></svg>';
+ const svgString = `<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full" width="${width}" height="${height}"><rect width="100%" height="100%" fill="${color}"/><text x="${
+ width / 2
+ }" y="${
+ height / 2
+ }" font-size="20" alignment-baseline="middle" text-anchor="middle" fill="white">${width}x${height}</text></svg>`;
const rawPrefix = 'data:image/svg+xml;charset=UTF-8,';
return rawPrefix + encodeURIComponent(svgString);
}
diff --git a/src/image_providers/lorempicsum.ts b/src/image_providers/lorempicsum.ts
index 32c52867..635ab9e6 100644
--- a/src/image_providers/lorempicsum.ts
+++ b/src/image_providers/lorempicsum.ts
@@ -108,10 +108,10 @@ export class LoremPicsum {
url += '/seed/' + seed;
}
- url += '/' + width + '/' + height;
+ url += `/${width}/${height}`;
if (grayscale && blur) {
- return url + '?grayscale' + '&blur=' + blur;
+ return `${url}?grayscale&blur=${blur}`;
}
if (grayscale) {
@@ -119,7 +119,7 @@ export class LoremPicsum {
}
if (blur) {
- return url + '?blur=' + blur;
+ return `${url}?blur=${blur}`;
}
return url;
diff --git a/src/image_providers/lorempixel.ts b/src/image_providers/lorempixel.ts
index d152cd6e..045da3f2 100644
--- a/src/image_providers/lorempixel.ts
+++ b/src/image_providers/lorempixel.ts
@@ -61,13 +61,13 @@ export class Lorempixel {
width ||= 640;
height ||= 480;
- let url = 'https://lorempixel.com/' + width + '/' + height;
+ let url = `https://lorempixel.com/${width}/${height}`;
if (typeof category !== 'undefined') {
url += '/' + category;
}
if (randomize) {
- url += '?' + this.faker.datatype.number();
+ url += `?${this.faker.datatype.number()}`;
}
return url;
diff --git a/src/image_providers/unsplash.ts b/src/image_providers/unsplash.ts
index 1d358345..580a3d96 100644
--- a/src/image_providers/unsplash.ts
+++ b/src/image_providers/unsplash.ts
@@ -58,7 +58,7 @@ export class Unsplash {
url += '/category/' + category;
}
- url += '/' + width + 'x' + height;
+ url += `/${width}x${height}`;
if (typeof keyword !== 'undefined') {
const keywordFormat = new RegExp(
diff --git a/src/internet.ts b/src/internet.ts
index b26654d1..2c663d58 100644
--- a/src/internet.ts
+++ b/src/internet.ts
@@ -185,11 +185,9 @@ export class Internet {
* @method faker.internet.avatar
*/
avatar(): string {
- return (
- 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/' +
- this.faker.datatype.number(1249) +
- '.jpg'
- );
+ return `https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/${this.faker.datatype.number(
+ 1249
+ )}.jpg`;
}
/**
@@ -240,18 +238,17 @@ export class Internet {
lastName ||= this.faker.name.lastName();
switch (this.faker.datatype.number(2)) {
case 0:
- result = firstName + this.faker.datatype.number(99);
+ result = `${firstName}${this.faker.datatype.number(99)}`;
break;
case 1:
result =
firstName + this.faker.random.arrayElement(['.', '_']) + lastName;
break;
case 2:
- result =
- firstName +
- this.faker.random.arrayElement(['.', '_']) +
- lastName +
- this.faker.datatype.number(99);
+ result = `${firstName}${this.faker.random.arrayElement([
+ '.',
+ '_',
+ ])}${lastName}${this.faker.datatype.number(99)}`;
break;
}
result = result.toString().replace(/'/g, '');
diff --git a/src/lorem.ts b/src/lorem.ts
index 5583b510..9368ec01 100644
--- a/src/lorem.ts
+++ b/src/lorem.ts
@@ -149,7 +149,7 @@ export class Lorem {
'lorem.lines',
];
const randomLoremMethod = this.faker.random.arrayElement(loremMethods);
- return this.faker.fake('{{' + randomLoremMethod + '}}');
+ return this.faker.fake(`{{${randomLoremMethod}}}`);
}
/**
diff --git a/src/vehicle.ts b/src/vehicle.ts
index b4171cc6..78661738 100644
--- a/src/vehicle.ts
+++ b/src/vehicle.ts
@@ -76,16 +76,15 @@ export class Vehicle {
*/
vin(): string {
const bannedChars = ['o', 'i', 'q'];
- return (
- this.faker.random.alphaNumeric(10, { bannedChars: bannedChars }) +
- this.faker.random.alpha({
- count: 1,
- upcase: true,
- bannedChars: bannedChars,
- }) +
- this.faker.random.alphaNumeric(1, { bannedChars: bannedChars }) +
- this.faker.datatype.number({ min: 10000, max: 100000 })
- ) // return five digit #
+ return `${this.faker.random.alphaNumeric(10, {
+ bannedChars,
+ })}${this.faker.random.alpha({
+ count: 1,
+ upcase: true,
+ bannedChars,
+ })}${this.faker.random.alphaNumeric(1, {
+ bannedChars,
+ })}${this.faker.datatype.number({ min: 10000, max: 100000 })}` // return five digit #
.toUpperCase();
}
@@ -106,12 +105,16 @@ export class Vehicle {
* faker.vehicle.vrm() // 'MF56UPA'
*/
vrm(): string {
- return (
- this.faker.random.alpha({ count: 2, upcase: true }) +
- this.faker.datatype.number({ min: 0, max: 9 }) +
- this.faker.datatype.number({ min: 0, max: 9 }) +
- this.faker.random.alpha({ count: 3, upcase: true })
- ).toUpperCase();
+ return `${this.faker.random.alpha({
+ count: 2,
+ upcase: true,
+ })}${this.faker.datatype.number({
+ min: 0,
+ max: 9,
+ })}${this.faker.datatype.number({
+ min: 0,
+ max: 9,
+ })}${this.faker.random.alpha({ count: 3, upcase: true })}`.toUpperCase();
}
/**
diff --git a/src/vendor/mersenne.ts b/src/vendor/mersenne.ts
index 6a94522b..a908d8d8 100644
--- a/src/vendor/mersenne.ts
+++ b/src/vendor/mersenne.ts
@@ -193,7 +193,7 @@ function MersenneTwister19937(): void {
/* generates a random number on [0,0xffffffff]-interval */
//c//unsigned long genrand_int32(void)
- this.genrand_int32 = function () {
+ this.genrand_int32 = function (): number {
//c//unsigned long y;
//c//static unsigned long mag01[2]={0x0UL, MATRIX_A};
let y: number;
@@ -271,7 +271,8 @@ function MersenneTwister19937(): void {
//c//double genrand_real3(void)
this.genrand_real3 = function (): number {
//c//return ((genrand_int32()) + 0.5)*(1.0/4294967296.0);
- return (this.genrand_int32() + 0.5) * (1.0 / 4294967296.0);
+ // TODO @Shinigami92 2022-01-30: Rewrite this file to a class
+ return ((this.genrand_int32() as number) + 0.5) * (1.0 / 4294967296.0);
/* divided by 2^32 */
};
diff --git a/src/vendor/unique.ts b/src/vendor/unique.ts
index dbe82480..31056b03 100644
--- a/src/vendor/unique.ts
+++ b/src/vendor/unique.ts
@@ -87,7 +87,7 @@ export function exec<Method extends (args: Args) => string, Args extends any[]>(
if (now - startTime >= opts.maxTime) {
return errorMessage(
now,
- 'Exceeded maxTime:' + opts.maxTime,
+ `Exceeded maxTime: ${opts.maxTime}`,
// @ts-expect-error: we know that opts.startTime is defined
opts
);
@@ -96,7 +96,7 @@ export function exec<Method extends (args: Args) => string, Args extends any[]>(
if (opts.currentIterations >= opts.maxRetries) {
return errorMessage(
now,
- 'Exceeded maxRetries:' + opts.maxRetries,
+ `Exceeded maxRetries: ${opts.maxRetries}`,
// @ts-expect-error: we know that opts.startTime is defined
opts
);
diff --git a/src/vendor/user-agent.ts b/src/vendor/user-agent.ts
index 81cbeb3e..9218c6e5 100644
--- a/src/vendor/user-agent.ts
+++ b/src/vendor/user-agent.ts
@@ -73,7 +73,8 @@ export function generate(faker: Faker): string {
}
throw new TypeError(
- 'Invalid arguments passed to rnd. (' + (b ? a + ', ' + b : a) + ')'
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ `Invalid arguments passed to rnd. (${b ? `${a}, ${b}` : a})`
);
}
@@ -211,7 +212,7 @@ export function generate(faker: Faker): string {
//generate a random revision
//dots = 2 returns .x.y where x & y are between 0 and 9
for (let x = 0; x < dots; x++) {
- return_val += '.' + rnd(0, 9);
+ return_val += `.${rnd(0, 9)}`;
}
return return_val;
}
@@ -221,13 +222,13 @@ export function generate(faker: Faker): string {
return [rnd(1, 4), rnd(0, 9), rnd(10000, 99999), rnd(0, 9)].join('.');
},
nt() {
- return rnd(5, 6) + '.' + rnd(0, 3);
+ return `${rnd(5, 6)}.${rnd(0, 3)}`;
},
ie() {
return rnd(7, 11);
},
trident() {
- return rnd(3, 7) + '.' + rnd(0, 1);
+ return `${rnd(3, 7)}.${rnd(0, 1)}`;
},
osx(delim?: string) {
return [10, rnd(5, 10), rnd(0, 9)].join(delim || '.');
@@ -236,28 +237,28 @@ export function generate(faker: Faker): string {
return [rnd(13, 39), 0, rnd(800, 899), 0].join('.');
},
presto() {
- return '2.9.' + rnd(160, 190);
+ return `2.9.${rnd(160, 190)}`;
},
presto2() {
- return rnd(10, 12) + '.00';
+ return `${rnd(10, 12)}.00`;
},
safari() {
- return rnd(531, 538) + '.' + rnd(0, 2) + '.' + rnd(0, 2);
+ return `${rnd(531, 538)}.${rnd(0, 2)}.${rnd(0, 2)}`;
},
};
const browser = {
firefox(arch: Arch): string {
//https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference
- const firefox_ver = rnd(5, 15) + randomRevision(2),
+ const firefox_ver = `${rnd(5, 15)}${randomRevision(2)}`,
gecko_ver = 'Gecko/20100101 Firefox/' + firefox_ver,
proc = randomProc(arch),
os_ver =
arch === 'win'
- ? '(Windows NT ' + version_string.nt() + (proc ? '; ' + proc : '')
+ ? '(Windows NT ' + version_string.nt() + (proc ? `; ${proc}` : '')
: arch === 'mac'
- ? '(Macintosh; ' + proc + ' Mac OS X ' + version_string.osx()
- : '(X11; Linux ' + proc;
+ ? `(Macintosh; ${proc} Mac OS X ${version_string.osx()}`
+ : `(X11; Linux ${proc}`;
return (
'Mozilla/5.0 ' +
@@ -274,26 +275,16 @@ export function generate(faker: Faker): string {
if (ver >= 11) {
//http://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
- return (
- 'Mozilla/5.0 (Windows NT 6.' +
- rnd(1, 3) +
- '; Trident/7.0; ' +
- rnd(['Touch; ', '']) +
- 'rv:11.0) like Gecko'
- );
+ return `Mozilla/5.0 (Windows NT 6.${rnd(1, 3)}; Trident/7.0; ${rnd([
+ 'Touch; ',
+ '',
+ ])}rv:11.0) like Gecko`;
}
//http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx
- return (
- 'Mozilla/5.0 (compatible; MSIE ' +
- ver +
- '.0; Windows NT ' +
- version_string.nt() +
- '; Trident/' +
- version_string.trident() +
- (rnd(0, 1) === 1 ? '; .NET CLR ' + version_string.net() : '') +
- ')'
- );
+ return `Mozilla/5.0 (compatible; MSIE ${ver}.0; Windows NT ${version_string.nt()}; Trident/${version_string.trident()}${
+ rnd(0, 1) === 1 ? '; .NET CLR ' + version_string.net() : ''
+ })`;
},
opera(arch: Arch): string {
@@ -306,44 +297,22 @@ export function generate(faker: Faker): string {
')',
os_ver =
arch === 'win'
- ? '(Windows NT ' +
- version_string.nt() +
- '; U; ' +
- randomLang() +
- presto_ver
+ ? `(Windows NT ${version_string.nt()}; U; ${randomLang()}${presto_ver}`
: arch === 'lin'
- ? '(X11; Linux ' +
- randomProc(arch) +
- '; U; ' +
- randomLang() +
- presto_ver
- : '(Macintosh; Intel Mac OS X ' +
- version_string.osx() +
- ' U; ' +
- randomLang() +
- ' Presto/' +
- version_string.presto() +
- ' Version/' +
- version_string.presto2() +
- ')';
+ ? `(X11; Linux ${randomProc(arch)}; U; ${randomLang()}${presto_ver}`
+ : `(Macintosh; Intel Mac OS X ${version_string.osx()} U; ${randomLang()} Presto/${version_string.presto()} Version/${version_string.presto2()})`;
- return 'Opera/' + rnd(9, 14) + '.' + rnd(0, 99) + ' ' + os_ver;
+ return `Opera/${rnd(9, 14)}.${rnd(0, 99)} ${os_ver}`;
},
safari(arch: Arch): string {
const safari = version_string.safari(),
- ver = rnd(4, 7) + '.' + rnd(0, 1) + '.' + rnd(0, 10),
+ ver = `${rnd(4, 7)}.${rnd(0, 1)}.${rnd(0, 10)}`,
os_ver =
arch === 'mac'
- ? '(Macintosh; ' +
- randomProc('mac') +
- ' Mac OS X ' +
- version_string.osx('_') +
- ' rv:' +
- rnd(2, 6) +
- '.0; ' +
- randomLang() +
- ') '
+ ? `(Macintosh; ${randomProc('mac')} Mac OS X ${version_string.osx(
+ '_'
+ )} rv:${rnd(2, 6)}.0; ${randomLang()}) `
: '(Windows; U; Windows NT ' + version_string.nt() + ')';
return (
@@ -362,14 +331,12 @@ export function generate(faker: Faker): string {
const safari = version_string.safari(),
os_ver =
arch === 'mac'
- ? '(Macintosh; ' +
- randomProc('mac') +
- ' Mac OS X ' +
- version_string.osx('_') +
- ') '
+ ? `(Macintosh; ${randomProc('mac')} Mac OS X ${version_string.osx(
+ '_'
+ )}) `
: arch === 'win'
? '(Windows; U; Windows NT ' + version_string.nt() + ')'
- : '(X11; Linux ' + randomProc(arch);
+ : `(X11; Linux ${randomProc(arch)}`;
return (
'Mozilla/5.0 ' +
diff --git a/test/database.spec.ts b/test/database.spec.ts
index 7117e97b..3b4177e4 100644
--- a/test/database.spec.ts
+++ b/test/database.spec.ts
@@ -13,10 +13,7 @@ describe('database', () => {
expect(
column,
- 'The column name should be equals ' +
- expected +
- '. Current is ' +
- column
+ `The column name should be equals ${expected}. Current is ${column}`
).toBe(expected);
spy_database_column.mockRestore();
@@ -34,10 +31,7 @@ describe('database', () => {
expect(
collation,
- 'The collation should be equals ' +
- expected +
- '. Current is ' +
- collation
+ `The collation should be equals ${expected}. Current is ${collation}`
).toBe(expected);
spy_database_collation.mockRestore();
@@ -55,7 +49,7 @@ describe('database', () => {
expect(
engine,
- 'The db engine should be equals ' + expected + '. Current is ' + engine
+ `The db engine should be equals ${expected}. Current is ${engine}`
).toBe(expected);
spy_database_engine.mockRestore();
@@ -73,7 +67,7 @@ describe('database', () => {
expect(
type,
- 'The column type should be equals ' + expected + '. Current is ' + type
+ `The column type should be equals ${expected}. Current is ${type}`
).toBe(expected);
spy_database_type.mockRestore();
diff --git a/test/finance.spec.ts b/test/finance.spec.ts
index 724c225e..f49e90e3 100644
--- a/test/finance.spec.ts
+++ b/test/finance.spec.ts
@@ -15,10 +15,7 @@ describe('finance', () => {
expect(
actual,
- 'The expected default account length is ' +
- expected +
- ' but it was ' +
- actual
+ `The expected default account length is ${expected} but it was ${actual}`
).toBe(expected);
});
@@ -31,10 +28,7 @@ describe('finance', () => {
expect(
actual,
- 'The expected default account length is ' +
- expected +
- ' but it was ' +
- actual
+ `The expected default account length is ${expected} but it was ${actual}`
).toBe(expected);
});
@@ -47,10 +41,7 @@ describe('finance', () => {
expect(
actual,
- 'The expected default account length is ' +
- expected +
- ' but it was ' +
- actual
+ `The expected default account length is ${expected} but it was ${actual}`
).toBe(expected);
});
});
@@ -81,10 +72,7 @@ describe('finance', () => {
expect(
actual,
- 'The expected default mask length is ' +
- expected +
- ' but it was ' +
- actual
+ `The expected default mask length is ${expected} but it was ${actual}`
).toBe(expected);
});
@@ -102,10 +90,7 @@ describe('finance', () => {
expect(
actual,
- 'The expected default mask length is ' +
- expected +
- ' but it was ' +
- actual
+ `The expected default mask length is ${expected} but it was ${actual}`
).toBe(expected);
});
@@ -118,10 +103,7 @@ describe('finance', () => {
expect(
actual,
- 'The expected default mask length is ' +
- expected +
- ' but it was ' +
- actual
+ `The expected default mask length is ${expected} but it was ${actual}`
).toBe(expected);
});
@@ -135,10 +117,7 @@ describe('finance', () => {
expect(
actual,
- 'The expected match for parentheses is ' +
- expected +
- ' but it was ' +
- actual
+ `The expected match for parentheses is ${expected} but it was ${actual}`
).toBe(expected);
});
@@ -152,10 +131,7 @@ describe('finance', () => {
expect(
actual,
- 'The expected match for parentheses is ' +
- expected +
- ' but it was ' +
- actual
+ `The expected match for parentheses is ${expected} but it was ${actual}`
).toBe(expected);
});
@@ -387,9 +363,7 @@ describe('finance', () => {
const ibanLib = require('../dist/cjs/iban');
it('returns a random yet formally correct IBAN number', () => {
- const iban =
- // @ts-expect-error
- faker.finance.iban();
+ const iban: string = faker.finance.iban();
const bban = iban.substring(4) + iban.substring(0, 4);
expect(
@@ -398,7 +372,7 @@ describe('finance', () => {
).toStrictEqual(1);
});
it('returns a specific and formally correct IBAN number', () => {
- const iban = faker.finance.iban(false, 'DE');
+ const iban: string = faker.finance.iban(false, 'DE');
const bban = iban.substring(4) + iban.substring(0, 4);
const countryCode = iban.substring(0, 2);
@@ -421,9 +395,9 @@ describe('finance', () => {
it('returns a random yet formally correct BIC number', () => {
const bic = faker.finance.bic();
const expr = new RegExp(
- '^[A-Z]{4}(' +
- ibanLib.iso3166.join('|') +
- ')[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3})?$',
+ `^[A-Z]{4}(${ibanLib.iso3166.join(
+ '|'
+ )})[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3})?\$`,
'i'
);
diff --git a/test/finance_iban.spec.ts b/test/finance_iban.spec.ts
index 801ade34..d11a9568 100644
--- a/test/finance_iban.spec.ts
+++ b/test/finance_iban.spec.ts
@@ -5,7 +5,7 @@ import ibanLib from '../dist/cjs/iban';
console.log(ibanLib);
-function getAnIbanByCountry(countryCode) {
+function getAnIbanByCountry(countryCode: string): string {
let iban =
// @ts-expect-error
faker.finance.iban();
@@ -23,9 +23,9 @@ function getAnIbanByCountry(countryCode) {
console.log('Not found with 10000 seed, vraiment pas de bol');
} else if (countTry < maxTry) {
console.log(
- 'you can optimize this helper by add faker.seed(' +
- (100000 - 1 - countTry) +
- ') before the call of getAnIbanByCountry()'
+ `you can optimize this helper by add faker.seed(${
+ 100000 - 1 - countTry
+ }) before the call of getAnIbanByCountry()`
);
}
// console.log(iban);
@@ -53,7 +53,7 @@ describe('finance_iban.js', () => {
expect(
22,
- 'GE IBAN would be 22 chars length, given is ' + iban.length
+ `GE IBAN would be 22 chars length, given is ${iban.length}`
).toBe(iban.length);
expect(
@@ -112,7 +112,7 @@ describe('finance_iban.js', () => {
expect(
24,
- 'PK IBAN would be 24 chars length, given is ' + iban.length
+ `PK IBAN would be 24 chars length, given is ${iban.length}`
).toBe(iban.length);
expect(
@@ -178,7 +178,7 @@ describe('finance_iban.js', () => {
expect(
26,
- 'PK IBAN would be 26 chars length, given is ' + iban.length
+ `PK IBAN would be 26 chars length, given is ${iban.length}`
).toBe(iban.length);
expect(
@@ -251,7 +251,7 @@ describe('finance_iban.js', () => {
expect(
28,
- 'AZ IBAN would be 28 chars length, given is ' + iban.length
+ `AZ IBAN would be 28 chars length, given is ${iban.length}`
).toBe(iban.length);
expect(