Skip to content

Commit

Permalink
chore(sdk): setup deprecate warning lint (stephenh#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 authored Jan 4, 2023
1 parent c0d8949 commit 055eac4
Show file tree
Hide file tree
Showing 20 changed files with 121 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
- run:
command: ./scripts/test-all.sh
name: Build & Test All
- run:
command: yarn lint
name: Lint
- run:
command: sudo npm link
name: Link CLI globally for template testing
Expand Down
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ docs
gen
types
builtin
templates
templates
packages/protos
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": [
"eslint:recommended",
// "plugin:@typescript-eslint/recommended",
// "eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier"
Expand All @@ -13,6 +13,8 @@
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-inferrable-types": ["off"],
"@typescript-eslint/no-empty-function": ["off"],
"@typescript-eslint/no-unused-vars": ["off"],
"@typescript-eslint/no-this-alias": ["off"],
// "@typescript-eslint/no-unused-vars": ["warn", { "args": "none" }],
Expand Down
3 changes: 1 addition & 2 deletions examples/sui/src/processor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SuiBindOptions } from '@sentio/sdk'
import { SuiBaseProcessor } from '@sentio/sdk'
import { SuiBindOptions, SuiBaseProcessor } from '@sentio/sdk'

// class TicTacToeProcessor extends SuiBaseProcessor {
// static bind(options: SuiBindOptions): TicTacToeProcessor {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.6.0",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-deprecation": "^1.3.3",
"eslint-plugin-import": "^2.26.0",
"jest": "^29.0.3",
"lerna": "^6.3.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": [
"../../.eslintrc.json"
],
"plugins": [
"deprecation"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"deprecation/deprecation": "error"
}
}
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"open": "^8.4.0",
"ts-loader": "^9.3.0",
"webpack": "^5.72.1",
"webpack-cli": "^5.0.0"
"webpack-cli": "^5.0.0",
"chalk": "^4.1.0"
},
"devDependencies": {
"@types/chai": "^4.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const TEST_CONTEXT: CallContext = <CallContext>{}
class TestPlugin extends Plugin {
async processBinding(request: DataBinding): Promise<ProcessResult> {
if (request.handlerType === HandlerType.UNKNOWN) {
assert(request.data!.raw.length > 0)
assert((request.data?.raw.length || 0) > 0)
}
return ProcessResult.fromPartial({})
}
Expand Down
14 changes: 14 additions & 0 deletions packages/sdk-all/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": [
"../../.eslintrc.json"
],
"plugins": [
"deprecation"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"deprecation/deprecation": "error"
}
}
14 changes: 14 additions & 0 deletions packages/sdk-aptos/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": [
"../../.eslintrc.json"
],
"plugins": [
"deprecation"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"deprecation/deprecation": "error"
}
}
4 changes: 3 additions & 1 deletion packages/sdk-aptos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
},
"dependencies": {
"@sentio/sdk": "^1.0.0-development",
"chalk": "^4.1.0",
"aptos-sdk": "npm:aptos@^1.3.17",
"prettier": "^2.8.1"
"prettier": "^2.8.1",
"@types/prettier": "^2.7.2"
},
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-aptos/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function getChainQueryClient(address?: string): AptosQueryClient {
if (!address) {
address = Endpoints.INSTANCE.chainQueryAPI
}
const channel = createChannel(address!)
const channel = createChannel(address)

return createClient(AptosQueryDefinition, channel)
}
4 changes: 1 addition & 3 deletions packages/sdk-aptos/src/aptos-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plugin, PluginManager } from '@sentio/runtime'
import { Plugin, PluginManager, errorString, mergeProcessResults, USER_PROCESSOR } from '@sentio/runtime'
import {
AccountConfig,
AptosCallHandlerConfig,
Expand All @@ -13,8 +13,6 @@ import {
ProcessResult,
} from '@sentio/protos'

import { errorString, mergeProcessResults, USER_PROCESSOR } from '@sentio/runtime'

import { ServerError, Status } from 'nice-grpc'

import { AptosAccountProcessorState, AptosProcessorState } from './aptos-processor'
Expand Down
10 changes: 5 additions & 5 deletions packages/sdk-aptos/src/codegen/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'
import prettier from 'prettier'
import * as fs from 'fs'
import * as path from 'path'
import { format } from 'prettier'
import { MoveFunction, MoveModule, MoveModuleBytecode, MoveStruct } from 'aptos-sdk/src/generated'
import { AccountModulesImportInfo, AccountRegister, generateType } from './typegen'
import { getMeaningfulFunctionParams, isFrameworkAccount, moduleQname, SPLITTER } from '../utils'
Expand Down Expand Up @@ -96,7 +96,7 @@ export async function generateForNetwork(srcDir: string, outputDir: string, netw
}

for (const output of outputs) {
const content = prettier.format(output.fileContent, { parser: 'typescript' })
const content = format(output.fileContent, { parser: 'typescript' })
fs.writeFileSync(path.join(outputDir, output.fileName), content)
}
}
Expand Down Expand Up @@ -419,7 +419,7 @@ function camelize(input: string): string {
.split('_')
.reduce(
(res, word, i) =>
i === 0 ? word.toLowerCase() : `${res}${word.charAt(0).toUpperCase()}${word.substr(1).toLowerCase()}`,
i === 0 ? word.toLowerCase() : `${res}${word.charAt(0).toUpperCase()}${word.slice(1).toLowerCase()}`,
''
)
}
Expand Down
14 changes: 14 additions & 0 deletions packages/sdk-solana/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": [
"../../.eslintrc.json"
],
"plugins": [
"deprecation"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"deprecation/deprecation": "error"
}
}
14 changes: 14 additions & 0 deletions packages/sdk/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": [
"../../.eslintrc.json"
],
"plugins": [
"deprecation"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"deprecation/deprecation": "error"
}
}
4 changes: 1 addition & 3 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@
"devDependencies": {
"@types/command-line-args": "^5.2.0",
"@types/command-line-usage": "^5.0.2",
"@types/expect": "^24.3.0",
"@types/fs-extra": "^9.0.13",
"@types/google-protobuf": "^3.15.6",
"@types/node": "^18.0.4"
"@types/google-protobuf": "^3.15.6"
},
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk/src/core/numberish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ describe('Numberish tests', () => {
const complexDec = '-7.350918e-428'
expect(toMetricValue(new BigDecimal(complexDec)).bigDecimal == complexDec)

expect(BigIntegerToBigInt(toMetricValue(new BigDecimal('100000')).bigInteger!) === 100000n)
expect(
BigIntegerToBigInt(toMetricValue(new BigDecimal('100000')).bigInteger || BigInteger.fromPartial({})) === 100000n
)
})
})

Expand Down
3 changes: 1 addition & 2 deletions packages/sdk/src/utils/dex-price.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { EthereumDexPrice, GoerliDexPrice } from './dex-price'
import { State } from '@sentio/runtime'
import { State, Endpoints } from '@sentio/runtime'
import { loadTestProvidersFromEnv } from '../testing/test-provider'

import { expect } from 'chai'
import { Endpoints } from '@sentio/runtime'

describe('dex price tests', () => {
State.reset()
Expand Down
23 changes: 22 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2736,6 +2736,11 @@
resolved "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.0.tgz"
integrity sha512-RI1L7N4JnW5gQw2spvL7Sllfuf1SaHdrZpCHiBlCXjIlufi1SMNnbu2teze3/QE67Fg2tBlH7W+mi4hVNk4p0A==

"@types/prettier@^2.7.2":
version "2.7.2"
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.2.tgz#6c2324641cc4ba050a8c710b2b251b377581fbf0"
integrity sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==

"@types/qs@*":
version "6.9.7"
resolved "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz"
Expand Down Expand Up @@ -2803,6 +2808,13 @@
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/experimental-utils@^5.0.0":
version "5.48.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.48.0.tgz#10c0871a1dfee734fbcd49399b6a07ce38bdb61c"
integrity sha512-ehoJFf67UViwnYuz6JUneZ8qxgDk0qEWKiTLmpE8WpPEr15e2cSLtp0E6Zicx2DaYdwctUA0uLRTbLckxQpurg==
dependencies:
"@typescript-eslint/utils" "5.48.0"

"@typescript-eslint/parser@^5.48.0":
version "5.48.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.48.0.tgz#02803355b23884a83e543755349809a50b7ed9ba"
Expand Down Expand Up @@ -4828,6 +4840,15 @@ eslint-module-utils@^2.7.3:
dependencies:
debug "^3.2.7"

eslint-plugin-deprecation@^1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-deprecation/-/eslint-plugin-deprecation-1.3.3.tgz#065b5d36ff220afe139f2b19af57454a13464731"
integrity sha512-Bbkv6ZN2cCthVXz/oZKPwsSY5S/CbgTLRG4Q2s2gpPpgNsT0uJ0dB5oLNiWzFYY8AgKX4ULxXFG1l/rDav9QFA==
dependencies:
"@typescript-eslint/experimental-utils" "^5.0.0"
tslib "^2.3.1"
tsutils "^3.21.0"

eslint-plugin-import@^2.26.0:
version "2.26.0"
resolved "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz"
Expand Down Expand Up @@ -10007,7 +10028,7 @@ tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.0:
resolved "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==

tslib@^2.3.0:
tslib@^2.3.0, tslib@^2.3.1:
version "2.4.1"
resolved "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz"
integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==
Expand Down

0 comments on commit 055eac4

Please sign in to comment.