Skip to content

Commit

Permalink
chore: configure eqeqeq lint rule (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Mar 7, 2022
1 parent 4f7447c commit 5cd3dae
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 183 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Expand Up @@ -28,6 +28,7 @@ module.exports = defineConfig({
rules: {
// We may want to use this in the future
'no-useless-escape': 'off',
eqeqeq: ['error', 'always', { null: 'ignore' }],

'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/consistent-type-imports': 'error',
Expand Down
316 changes: 158 additions & 158 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/datatype.ts
Expand Up @@ -182,7 +182,7 @@ export class Datatype {
const RFC4122_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
const replacePlaceholders = (placeholder) => {
const random = this.faker.datatype.number({ min: 0, max: 15 });
const value = placeholder == 'x' ? random : (random & 0x3) | 0x8;
const value = placeholder === 'x' ? random : (random & 0x3) | 0x8;
return value.toString(16);
};
return RFC4122_TEMPLATE.replace(/[xy]/g, replacePlaceholders);
Expand Down
2 changes: 1 addition & 1 deletion src/date.ts
Expand Up @@ -112,7 +112,7 @@ export class _Date {
* // [ 2023-05-02T16:00:00.000Z, 2026-09-01T08:00:00.000Z ]
*/
betweens(from: string, to: string, num?: number): Date[] {
if (typeof num == 'undefined') {
if (typeof num === 'undefined') {
num = 3;
}
const newDates: Date[] = [];
Expand Down
6 changes: 3 additions & 3 deletions src/finance.ts
Expand Up @@ -91,7 +91,7 @@ export class Finance {
mask(length?: number, parens?: boolean, ellipsis?: boolean): string {
// set defaults
length =
length == 0 || !length || typeof length == 'undefined' ? 4 : length;
length === 0 || !length || typeof length === 'undefined' ? 4 : length;
parens = parens == null ? true : parens;
ellipsis = ellipsis == null ? true : ellipsis;

Expand Down Expand Up @@ -352,9 +352,9 @@ export class Finance {
let c = bban.count;
count += bban.count;
while (c > 0) {
if (bban.type == 'a') {
if (bban.type === 'a') {
s += this.faker.random.arrayElement(this.ibanLib.alpha);
} else if (bban.type == 'c') {
} else if (bban.type === 'c') {
if (this.faker.datatype.number(100) < 80) {
s += this.faker.datatype.number(9);
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/helpers.ts
Expand Up @@ -178,9 +178,9 @@ export class Helpers {
replaceSymbolWithNumber(string: string = '', symbol: string = '#'): string {
let str = '';
for (let i = 0; i < string.length; i++) {
if (string.charAt(i) == symbol) {
if (string.charAt(i) === symbol) {
str += this.faker.datatype.number(9);
} else if (string.charAt(i) == '!') {
} else if (string.charAt(i) === '!') {
str += this.faker.datatype.number({ min: 2, max: 9 });
} else {
str += string.charAt(i);
Expand Down Expand Up @@ -237,11 +237,11 @@ export class Helpers {
let str = '';

for (let i = 0; i < string.length; i++) {
if (string.charAt(i) == '#') {
if (string.charAt(i) === '#') {
str += this.faker.datatype.number(9);
} else if (string.charAt(i) == '?') {
} else if (string.charAt(i) === '?') {
str += this.faker.random.arrayElement(alpha);
} else if (string.charAt(i) == '*') {
} else if (string.charAt(i) === '*') {
str += this.faker.datatype.boolean()
? this.faker.random.arrayElement(alpha)
: this.faker.datatype.number(9);
Expand Down
2 changes: 1 addition & 1 deletion src/internet.ts
Expand Up @@ -336,7 +336,7 @@ export class Internet {

for (i = 0; i < 12; i++) {
mac += this.faker.datatype.number(15).toString(16);
if (i % 2 == 1 && i != 11) {
if (i % 2 === 1 && i !== 11) {
mac += validSep;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lorem.ts
Expand Up @@ -50,7 +50,7 @@ export class Lorem {
* faker.lorem.words(10) // 'debitis consectetur voluptatem non doloremque ipsum autem totam eum ratione'
*/
words(num?: number): string {
if (typeof num == 'undefined') {
if (typeof num === 'undefined') {
num = 3;
}
const words: string[] = [];
Expand All @@ -72,7 +72,7 @@ export class Lorem {
*/
// TODO @Shinigami92 2022-01-11: `range` is not in use
sentence(wordCount?: number, range?: number): string {
if (typeof wordCount == 'undefined') {
if (typeof wordCount === 'undefined') {
wordCount = this.faker.datatype.number({ min: 3, max: 10 });
}
// if (typeof range == 'undefined') { range = 7; }
Expand Down
4 changes: 2 additions & 2 deletions src/mersenne.ts
Expand Up @@ -46,7 +46,7 @@ export class Mersenne {
* @throws If the seed is not a `number`.
*/
seed(S: number): void {
if (typeof S != 'number') {
if (typeof S !== 'number') {
throw new Error('seed(S) must take numeric argument; is ' + typeof S);
}

Expand All @@ -60,7 +60,7 @@ export class Mersenne {
* @throws If the seed is not a `number[]`.
*/
seed_array(A: number[]): void {
if (typeof A != 'object') {
if (typeof A !== 'object') {
throw new Error(
'seed_array(A) must take array of numbers; is ' + typeof A
);
Expand Down
2 changes: 1 addition & 1 deletion src/vendor/mersenne.ts
Expand Up @@ -237,7 +237,7 @@ export default class MersenneTwister19937 {
//c//int kk;
let kk: number;

if (this.mti == this.N + 1) {
if (this.mti === this.N + 1) {
/* if init_genrand() has not been called, */
//c//init_genrand(5489); /* a default initial seed is used */
this.initGenrand(5489);
Expand Down
14 changes: 7 additions & 7 deletions src/word.ts
Expand Up @@ -24,7 +24,7 @@ export class Word {
let wordList = this.faker.definitions.word.adjective;
if (length) {
wordList = this.faker.definitions.word.adjective.filter(
(word) => word.length == length
(word) => word.length === length
);
}

Expand All @@ -46,7 +46,7 @@ export class Word {
let wordList = this.faker.definitions.word.adverb;
if (length) {
wordList = this.faker.definitions.word.adverb.filter(
(word: string) => word.length == length
(word: string) => word.length === length
);
}

Expand All @@ -68,7 +68,7 @@ export class Word {
let wordList = this.faker.definitions.word.conjunction;
if (length) {
wordList = this.faker.definitions.word.conjunction.filter(
(word: string) => word.length == length
(word: string) => word.length === length
);
}

Expand All @@ -90,7 +90,7 @@ export class Word {
let wordList = this.faker.definitions.word.interjection;
if (length) {
wordList = this.faker.definitions.word.interjection.filter(
(word: string) => word.length == length
(word: string) => word.length === length
);
}

Expand All @@ -112,7 +112,7 @@ export class Word {
let wordList = this.faker.definitions.word.noun;
if (length) {
wordList = this.faker.definitions.word.noun.filter(
(word: string) => word.length == length
(word: string) => word.length === length
);
}

Expand All @@ -134,7 +134,7 @@ export class Word {
let wordList = this.faker.definitions.word.preposition;
if (length) {
wordList = this.faker.definitions.word.preposition.filter(
(word: string) => word.length == length
(word: string) => word.length === length
);
}

Expand All @@ -156,7 +156,7 @@ export class Word {
let wordList = this.faker.definitions.word.verb;
if (length) {
wordList = this.faker.definitions.word.verb.filter(
(word: string) => word.length == length
(word: string) => word.length === length
);
}

Expand Down
2 changes: 1 addition & 1 deletion test/address.spec.ts
Expand Up @@ -571,7 +571,7 @@ describe('address', () => {
latFloat1 = parseFloat(faker.address.latitude());
lonFloat1 = parseFloat(faker.address.longitude());
const radius = Math.random() * 99 + 1; // range of [1, 100)
isMetric = Math.round(Math.random()) == 1;
isMetric = Math.round(Math.random()) === 1;

const coordinate = faker.address.nearbyGPSCoordinate(
[latFloat1, lonFloat1],
Expand Down
2 changes: 1 addition & 1 deletion test/finance.spec.ts
Expand Up @@ -187,7 +187,7 @@ describe('finance', () => {
let expected = faker.datatype.number(20);

expected =
expected === 0 || !expected || typeof expected == 'undefined'
expected === 0 || !expected || typeof expected === 'undefined'
? 4
: expected;

Expand Down

0 comments on commit 5cd3dae

Please sign in to comment.