Skip to content

Commit

Permalink
chore: replace tslint with eslint (#53)
Browse files Browse the repository at this point in the history
* chore: replace tslint with eslint

upgrade typescript to 5

avoid massive code changes by disabling some rules

* use node18 base config
remove missed tslint directives
make compatible with prettier

---------

Co-authored-by: Aaron <[email protected]>
  • Loading branch information
aaronmgdr and aaronmgdr authored Oct 4, 2023
1 parent ec53575 commit 312e06b
Show file tree
Hide file tree
Showing 50 changed files with 608 additions and 327 deletions.
33 changes: 33 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-env node */
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true },
],
'no-restricted-imports': [
'error',
{
name: 'elliptic',
message: 'Only import "elliptic" inline / async',
},
],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
'{}': false,
},
extendDefaults: true,
},
],
},
ignorePatterns: ['**/lib/*', '**/dist/*', '**/*.js'],
root: true,
}
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"eamodio.gitlens",
"ms-vscode.vscode-typescript-tslint-plugin",
"esbenp.prettier-vscode",
"juanblanco.solidity",
"redhat.vscode-yaml",
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,5 @@
"javascript.format.enable": false,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"tslint.jsEnable": true,
"typescript.tsdk": "node_modules/typescript/lib"
}
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preinstall": "git config --global url.\"https://\".insteadOf ssh://",
"lint": "yarn lerna run lint && yarn run --silent lint:do-not-merge",
"lint:do-not-merge": "! git grep -E 'DO[ _]*NOT[ _]*MERGE'",
"prettify": "yarn run prettier --config .prettierrc.js --write '**/*.+(ts|tsx|js|jsx|sol|java)'",
"prettify:diff": "yarn run prettier --config .prettierrc.js --list-different '**/*.+(ts|tsx|js|jsx|sol|java)'",
"prettify": "yarn run prettier --config .prettierrc.js --write '**/*.+(ts|js)'",
"prettify:diff": "yarn run prettier --config .prettierrc.js --list-different '**/*.+(ts|js)'",
"reset": "yarn reset-modules && yarn reset-cache",
"reset-cache": "yarn reset-yarn && yarn reset-rn",
"reset-modules": "rm -rf node_modules/ packages/*/node_modules",
Expand Down Expand Up @@ -37,18 +37,23 @@
]
},
"devDependencies": {
"@celo/typescript": "0.0.2",
"@babel/core": "^7.8.4",
"@babel/runtime": "^7.8.4",
"@changesets/cli": "^2.26.2",
"@tsconfig/node18": "^18.2.2",
"@tsconfig/recommended": "^1.0.3",
"@types/jest": "^29.1.1",
"@types/node": "18.7.16",
"@types/prompt": "1.1.1",
"@types/semver": "7.3.8",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"babel-jest": "^29.1.2",
"codecov": "^3.6.5",
"colors": "1.4.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"husky": "^3.1.0",
"jest": "^29.0.2",
"jest-circus": "^29.0.2",
Expand All @@ -65,9 +70,7 @@
"ts-jest": "^29.0.0",
"ts-node": "^10.9.1",
"tsconfig-paths": "^3.8.0",
"tslint": "^5.20.0",
"typescript": "4.7.4",
"typescript-tslint-plugin": "^0.5.4"
"typescript": "^5.2.2"
},
"resolutions": {
"bip39": "https://github.com/bitcoinjs/bip39#d8ea080a18b40f301d4e2219a2991cd2417e83c2",
Expand Down
2 changes: 1 addition & 1 deletion packages/phone-number-privacy/combiner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"config:set:mainnet": "firebase functions:config:set --project celo-pgpnp-mainnet",
"clean": "tsc -b . --clean",
"build": "tsc -b .",
"lint": "tslint --project .",
"lint": "eslint .",
"test": "jest --runInBand --testPathIgnorePatterns test/end-to-end",
"test:coverage": "yarn test --coverage",
"test:integration": "jest --runInBand test/integration",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
OdisResponse,
PnpQuotaStatus,
send,
// tslint:disable-next-line: ordered-imports
SequentialDelayDomainState,
WarningMessage,
} from '@celo/phone-number-privacy-common'
Expand Down
2 changes: 1 addition & 1 deletion packages/phone-number-privacy/combiner/src/common/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { isAbortError, Signer } from './combine'
const httpAgent = new http.Agent({ keepAlive: true })
const httpsAgent = new https.Agent({ keepAlive: true })

// tslint:disable-next-line: interface-over-type-literal
export type SignerResponse<R extends OdisRequest> = {
url: string
res: OdisResponse<R>
Expand Down Expand Up @@ -85,6 +84,7 @@ export async function fetchSignerResponseWithFallback<R extends OdisRequest>(
[KEY_VERSION_HEADER]: keyVersion.toString()
},
body: JSON.stringify(request.body),
// @ts-expect-error throwIfAborted is not in the type definition
signal: abortSignal,
agent: url.startsWith("https://") ? httpsAgent : httpAgent
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('pnp threshold state', () => {
url: 'random url',
status: 200,
res: {
success: true as true,
success: true as const,
version: expectedVersion,
...o,
},
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('pnp threshold state', () => {
url: 'random url',
status: 200,
res: {
success: true as true,
success: true as const,
version: expectedVersion,
...o,
},
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('pnp threshold state', () => {
url: 'random url',
status: 200,
res: {
success: true as true,
success: true as const,
version: expectedVersion,
...o,
},
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('pnp threshold state', () => {
url: 'random url',
status: 200,
res: {
success: true as true,
success: true as const,
version: expectedVersion,
...o,
},
Expand Down
8 changes: 2 additions & 6 deletions packages/phone-number-privacy/combiner/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"extends": "@tsconfig/recommended/tsconfig.json",
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"plugins": [
{
"name": "typescript-tslint-plugin"
}
],
"esModuleInterop": true,
"declaration": true,
"rootDir": "src",
"outDir": "dist"
Expand Down
13 changes: 0 additions & 13 deletions packages/phone-number-privacy/combiner/tslint.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/phone-number-privacy/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"clean": "tsc -b . --clean",
"test": "jest --testPathIgnorePatterns test/end-to-end",
"test:coverage": "yarn test --coverage",
"lint": "tslint -c tslint.json --project ."
"lint": "eslint ."
},
"files": [
"lib/**/*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { Domain } from './domains'

// Concrete Domain subtypes are only assignable to Domain and EIP712Object when using type instead
// of interface. Otherwise the compiler complains about a missing index signature.
// tslint:disable:interface-over-type-literal

export type SequentialDelayStage = {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {

// Domain request types are only assignable to EIP712Object when using type instead
// of interface. Otherwise the compiler complains about a missing index signature.
// tslint:disable:interface-over-type-literal

export enum AuthenticationMethod {
WALLET_KEY = 'wallet_key',
Expand Down
2 changes: 0 additions & 2 deletions packages/phone-number-privacy/common/src/poprf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { randomBytes } from 'crypto'
* https://github.com/celo-org/celo-poprf-rs
*/

// tslint:disable: max-classes-per-file

let _poprf: typeof POPRF | undefined

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export function getMessageDigest(message: string) {
export function signWithRawKey(msg: string, rawKey: string) {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
const EC = require('elliptic').ec
const ec = new EC('secp256k1')

Expand All @@ -123,7 +122,6 @@ export function verifyDEKSignature(
try {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
const EC = require('elliptic').ec
const ec = new EC('secp256k1')
const key = ec.keyFromPublic(trimLeading0x(registeredEncryptionKey), 'hex')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ describe('Authentication test suite', () => {
getDataEncryptionKey: async (_: string) => {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
const EC = require('elliptic').ec
const ec = new EC('secp256k1')
const key = ec.keyFromPrivate(hexToBuffer(rawKey))
Expand Down Expand Up @@ -185,7 +184,6 @@ describe('Authentication test suite', () => {
getDataEncryptionKey: async (_: string) => {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
const EC = require('elliptic').ec
const ec = new EC('secp256k1')
const key = ec.keyFromPrivate(hexToBuffer(rawKey))
Expand Down Expand Up @@ -226,7 +224,6 @@ describe('Authentication test suite', () => {
getDataEncryptionKey: async (_: string) => {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
const EC = require('elliptic').ec
const ec = new EC('secp256k1')
// Send back a manipulated key.
Expand Down Expand Up @@ -269,7 +266,6 @@ describe('Authentication test suite', () => {
getDataEncryptionKey: async (_: string) => {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
const EC = require('elliptic').ec
const ec = new EC('secp256k1')
// Send back a manipulated key.
Expand Down Expand Up @@ -299,7 +295,6 @@ describe('Authentication test suite', () => {
}
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
const EC = require('elliptic').ec
const ec = new EC('secp256k1')
const key = ec.keyFromPrivate(hexToBuffer(rawKey))
Expand Down
5 changes: 0 additions & 5 deletions packages/phone-number-privacy/common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"extends": "@tsconfig/recommended",
"compilerOptions": {
"plugins": [
{
"name": "typescript-tslint-plugin"
}
],
"declaration": true,
"rootDir": "src",
"outDir": "lib"
Expand Down
5 changes: 0 additions & 5 deletions packages/phone-number-privacy/common/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"extends": "@tsconfig/recommended",
"compilerOptions": {
"plugins": [
{
"name": "typescript-tslint-plugin"
}
],
"declaration": true,
"rootDir": ".",
"outDir": "lib"
Expand Down
7 changes: 0 additions & 7 deletions packages/phone-number-privacy/common/tslint.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/phone-number-privacy/monitor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"config:set:mainnet": "firebase functions:config:set --project celo-pgpnp-mainnet",
"clean": "tsc -b . --clean",
"build": "tsc -b .",
"lint": "tslint --project .",
"lint": "eslint .",
"loadTest": "ts-node src/scripts/run-load-test.ts run"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/phone-number-privacy/monitor/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const queryOdisForQuota = async (
}

export const queryOdisDomain = async (contextName: OdisContextName) => {
console.log(`contextName: ${contextName}`) // tslint:disable-line:no-console
console.log(`contextName: ${contextName}`)

const serviceContext = getServiceContext(contextName, OdisAPI.DOMAIN)
const monitorDomainConfig: OdisHardeningConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { concurrentRPSLoadTest } from '../test'

const logger = rootLogger('odis-monitor')

// tslint:disable-next-line: no-unused-expression
yargs
.scriptName('ODIS-load-test')
.recommendCommands()
Expand Down Expand Up @@ -94,6 +93,6 @@ yargs
args.movingAvgRequests,
args.privateKey,
args.privateKeyPercentage
) // tslint:disable-line:no-floating-promises
)
}
).argv
7 changes: 1 addition & 6 deletions packages/phone-number-privacy/monitor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"extends": "@tsconfig/recommended/tsconfig.json",
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"plugins": [
{
"name": "typescript-tslint-plugin"
}
],
"declaration": true,
"rootDir": "src",
"outDir": "dist"
Expand Down
7 changes: 0 additions & 7 deletions packages/phone-number-privacy/monitor/tslint.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/phone-number-privacy/signer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"start:docker:tracing": "yarn build && node --require ./dist/tracing.js dist/index.js",
"clean": "tsc -b . --clean",
"build": "tsc -b .",
"lint": "tslint --project .",
"lint": "eslint .",
"test": "jest --testPathIgnorePatterns test/end-to-end",
"test:debughandles": "jest --watch --runInBand --detectOpenHandles --testPathIgnorePatterns test/end-to-end",
"test:debug": "node --inspect ../../../node_modules/.bin/jest --runInBand",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable: no-console
import * as poprf from '@celo/poprf'
import crypto from 'crypto'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// tslint:disable: no-console

import { initDatabase } from '../src/common/database/database'
import { config } from '../src/config'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable: no-console
import threshold_bls from 'blind-threshold-bls'
import crypto from 'crypto'

Expand Down
Loading

0 comments on commit 312e06b

Please sign in to comment.