From 4941f8307aafe2bf853dfdd4492b612bedd3a050 Mon Sep 17 00:00:00 2001 From: Ricardo Arturo Cabral Mejia Date: Tue, 25 Oct 2022 09:14:55 -0400 Subject: [PATCH] chore: improve linting --- .eslintrc.js | 2 +- src/index.ts | 1 - src/utils/proof-of-work.ts | 1 + src/utils/runes/alternative.ts | 28 +++++++++++++++------------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 32f7926..26f80c7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,7 +4,7 @@ module.exports = { sourceType: 'module', }, plugins: ['@typescript-eslint/eslint-plugin'], - extends: ['plugin:@typescript-eslint/recommended'], + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], root: true, env: { node: true, diff --git a/src/index.ts b/src/index.ts index da44d1a..a770184 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,4 +12,3 @@ export const run = (isPrimary: boolean) => { if (require.main === module) { run(cluster.isPrimary)() } - diff --git a/src/utils/proof-of-work.ts b/src/utils/proof-of-work.ts index f62d59f..4f043db 100644 --- a/src/utils/proof-of-work.ts +++ b/src/utils/proof-of-work.ts @@ -18,6 +18,7 @@ function msb(b: number) { return 8 } + // eslint-disable-next-line no-cond-assign while (b >>= 1) { n++ } diff --git a/src/utils/runes/alternative.ts b/src/utils/runes/alternative.ts index 82add1e..8ffd982 100644 --- a/src/utils/runes/alternative.ts +++ b/src/utils/runes/alternative.ts @@ -1,6 +1,6 @@ import { IAlternative } from '../../@types/runes' -const punctuations = /[!"#\$%&'()*+-.\/:;<=>?@\[\\\]^`{|}~]/ +const punctuations = /[!"#$%&'()*+-./:;<=>?@[\\\]^`{|}~]/ const hasPunctuation = (input) => punctuations.test(input) @@ -54,19 +54,21 @@ export class Alternative implements IAlternative { return why(values[this.field].includes(this.value), this.field, `does not contain ${this.value}`) case '<': case '>': - const actualInt = Number.parseInt(val) - if (Number.isNaN(actualInt)) { - return why(false, this.field, 'not an integer field') - } - const restrictionVal = Number.parseInt(this.value) - if (Number.isNaN(restrictionVal)) { - return why(false, this.field, 'not a valid integer') - } + { + const actualInt = Number.parseInt(val) + if (Number.isNaN(actualInt)) { + return why(false, this.field, 'not an integer field') + } + const restrictionVal = Number.parseInt(this.value) + if (Number.isNaN(restrictionVal)) { + return why(false, this.field, 'not a valid integer') + } - if (this.cond === '<') { - return why(actualInt < restrictionVal, this.field, `>= ${restrictionVal}`) - } else { - return why(actualInt > restrictionVal, this.field, `<= ${restrictionVal}`) + if (this.cond === '<') { + return why(actualInt < restrictionVal, this.field, `>= ${restrictionVal}`) + } else { + return why(actualInt > restrictionVal, this.field, `<= ${restrictionVal}`) + } } case '{': return why(val < this.value, this.field, `is the same or ordered after ${this.value}`)