Skip to content

Commit 5cd3dae

Browse files
authored
chore: configure eqeqeq lint rule (#595)
1 parent 4f7447c commit 5cd3dae

13 files changed

+184
-183
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = defineConfig({
2828
rules: {
2929
// We may want to use this in the future
3030
'no-useless-escape': 'off',
31+
eqeqeq: ['error', 'always', { null: 'ignore' }],
3132

3233
'@typescript-eslint/ban-ts-comment': 'warn',
3334
'@typescript-eslint/consistent-type-imports': 'error',

pnpm-lock.yaml

Lines changed: 158 additions & 158 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datatype.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export class Datatype {
182182
const RFC4122_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
183183
const replacePlaceholders = (placeholder) => {
184184
const random = this.faker.datatype.number({ min: 0, max: 15 });
185-
const value = placeholder == 'x' ? random : (random & 0x3) | 0x8;
185+
const value = placeholder === 'x' ? random : (random & 0x3) | 0x8;
186186
return value.toString(16);
187187
};
188188
return RFC4122_TEMPLATE.replace(/[xy]/g, replacePlaceholders);

src/date.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class _Date {
112112
* // [ 2023-05-02T16:00:00.000Z, 2026-09-01T08:00:00.000Z ]
113113
*/
114114
betweens(from: string, to: string, num?: number): Date[] {
115-
if (typeof num == 'undefined') {
115+
if (typeof num === 'undefined') {
116116
num = 3;
117117
}
118118
const newDates: Date[] = [];

src/finance.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class Finance {
9191
mask(length?: number, parens?: boolean, ellipsis?: boolean): string {
9292
// set defaults
9393
length =
94-
length == 0 || !length || typeof length == 'undefined' ? 4 : length;
94+
length === 0 || !length || typeof length === 'undefined' ? 4 : length;
9595
parens = parens == null ? true : parens;
9696
ellipsis = ellipsis == null ? true : ellipsis;
9797

@@ -352,9 +352,9 @@ export class Finance {
352352
let c = bban.count;
353353
count += bban.count;
354354
while (c > 0) {
355-
if (bban.type == 'a') {
355+
if (bban.type === 'a') {
356356
s += this.faker.random.arrayElement(this.ibanLib.alpha);
357-
} else if (bban.type == 'c') {
357+
} else if (bban.type === 'c') {
358358
if (this.faker.datatype.number(100) < 80) {
359359
s += this.faker.datatype.number(9);
360360
} else {

src/helpers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ export class Helpers {
178178
replaceSymbolWithNumber(string: string = '', symbol: string = '#'): string {
179179
let str = '';
180180
for (let i = 0; i < string.length; i++) {
181-
if (string.charAt(i) == symbol) {
181+
if (string.charAt(i) === symbol) {
182182
str += this.faker.datatype.number(9);
183-
} else if (string.charAt(i) == '!') {
183+
} else if (string.charAt(i) === '!') {
184184
str += this.faker.datatype.number({ min: 2, max: 9 });
185185
} else {
186186
str += string.charAt(i);
@@ -237,11 +237,11 @@ export class Helpers {
237237
let str = '';
238238

239239
for (let i = 0; i < string.length; i++) {
240-
if (string.charAt(i) == '#') {
240+
if (string.charAt(i) === '#') {
241241
str += this.faker.datatype.number(9);
242-
} else if (string.charAt(i) == '?') {
242+
} else if (string.charAt(i) === '?') {
243243
str += this.faker.random.arrayElement(alpha);
244-
} else if (string.charAt(i) == '*') {
244+
} else if (string.charAt(i) === '*') {
245245
str += this.faker.datatype.boolean()
246246
? this.faker.random.arrayElement(alpha)
247247
: this.faker.datatype.number(9);

src/internet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export class Internet {
336336

337337
for (i = 0; i < 12; i++) {
338338
mac += this.faker.datatype.number(15).toString(16);
339-
if (i % 2 == 1 && i != 11) {
339+
if (i % 2 === 1 && i !== 11) {
340340
mac += validSep;
341341
}
342342
}

src/lorem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class Lorem {
5050
* faker.lorem.words(10) // 'debitis consectetur voluptatem non doloremque ipsum autem totam eum ratione'
5151
*/
5252
words(num?: number): string {
53-
if (typeof num == 'undefined') {
53+
if (typeof num === 'undefined') {
5454
num = 3;
5555
}
5656
const words: string[] = [];
@@ -72,7 +72,7 @@ export class Lorem {
7272
*/
7373
// TODO @Shinigami92 2022-01-11: `range` is not in use
7474
sentence(wordCount?: number, range?: number): string {
75-
if (typeof wordCount == 'undefined') {
75+
if (typeof wordCount === 'undefined') {
7676
wordCount = this.faker.datatype.number({ min: 3, max: 10 });
7777
}
7878
// if (typeof range == 'undefined') { range = 7; }

src/mersenne.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class Mersenne {
4646
* @throws If the seed is not a `number`.
4747
*/
4848
seed(S: number): void {
49-
if (typeof S != 'number') {
49+
if (typeof S !== 'number') {
5050
throw new Error('seed(S) must take numeric argument; is ' + typeof S);
5151
}
5252

@@ -60,7 +60,7 @@ export class Mersenne {
6060
* @throws If the seed is not a `number[]`.
6161
*/
6262
seed_array(A: number[]): void {
63-
if (typeof A != 'object') {
63+
if (typeof A !== 'object') {
6464
throw new Error(
6565
'seed_array(A) must take array of numbers; is ' + typeof A
6666
);

src/vendor/mersenne.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export default class MersenneTwister19937 {
237237
//c//int kk;
238238
let kk: number;
239239

240-
if (this.mti == this.N + 1) {
240+
if (this.mti === this.N + 1) {
241241
/* if init_genrand() has not been called, */
242242
//c//init_genrand(5489); /* a default initial seed is used */
243243
this.initGenrand(5489);

src/word.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class Word {
2424
let wordList = this.faker.definitions.word.adjective;
2525
if (length) {
2626
wordList = this.faker.definitions.word.adjective.filter(
27-
(word) => word.length == length
27+
(word) => word.length === length
2828
);
2929
}
3030

@@ -46,7 +46,7 @@ export class Word {
4646
let wordList = this.faker.definitions.word.adverb;
4747
if (length) {
4848
wordList = this.faker.definitions.word.adverb.filter(
49-
(word: string) => word.length == length
49+
(word: string) => word.length === length
5050
);
5151
}
5252

@@ -68,7 +68,7 @@ export class Word {
6868
let wordList = this.faker.definitions.word.conjunction;
6969
if (length) {
7070
wordList = this.faker.definitions.word.conjunction.filter(
71-
(word: string) => word.length == length
71+
(word: string) => word.length === length
7272
);
7373
}
7474

@@ -90,7 +90,7 @@ export class Word {
9090
let wordList = this.faker.definitions.word.interjection;
9191
if (length) {
9292
wordList = this.faker.definitions.word.interjection.filter(
93-
(word: string) => word.length == length
93+
(word: string) => word.length === length
9494
);
9595
}
9696

@@ -112,7 +112,7 @@ export class Word {
112112
let wordList = this.faker.definitions.word.noun;
113113
if (length) {
114114
wordList = this.faker.definitions.word.noun.filter(
115-
(word: string) => word.length == length
115+
(word: string) => word.length === length
116116
);
117117
}
118118

@@ -134,7 +134,7 @@ export class Word {
134134
let wordList = this.faker.definitions.word.preposition;
135135
if (length) {
136136
wordList = this.faker.definitions.word.preposition.filter(
137-
(word: string) => word.length == length
137+
(word: string) => word.length === length
138138
);
139139
}
140140

@@ -156,7 +156,7 @@ export class Word {
156156
let wordList = this.faker.definitions.word.verb;
157157
if (length) {
158158
wordList = this.faker.definitions.word.verb.filter(
159-
(word: string) => word.length == length
159+
(word: string) => word.length === length
160160
);
161161
}
162162

test/address.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ describe('address', () => {
571571
latFloat1 = parseFloat(faker.address.latitude());
572572
lonFloat1 = parseFloat(faker.address.longitude());
573573
const radius = Math.random() * 99 + 1; // range of [1, 100)
574-
isMetric = Math.round(Math.random()) == 1;
574+
isMetric = Math.round(Math.random()) === 1;
575575

576576
const coordinate = faker.address.nearbyGPSCoordinate(
577577
[latFloat1, lonFloat1],

test/finance.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ describe('finance', () => {
187187
let expected = faker.datatype.number(20);
188188

189189
expected =
190-
expected === 0 || !expected || typeof expected == 'undefined'
190+
expected === 0 || !expected || typeof expected === 'undefined'
191191
? 4
192192
: expected;
193193

0 commit comments

Comments
 (0)