diff --git a/.eslintrc.json b/.eslintrc.json index fe39e77..94c77c5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,11 +1,48 @@ { - "extends": [ "airbnb-base", "prettier" ], - "plugins": ["prettier"], - "rules": { - "prettier/prettier": "error" - }, "env": { "browser": true, + "es6": true, + "commonjs": true, "node": true + }, + "extends": [ + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended", + "prettier/@typescript-eslint", + "plugin:import/typescript" + ], + "plugins": [ + "@typescript-eslint", + "prettier", + "import" + ], + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module" + }, + "rules": { + "indent": 0, + "@typescript-eslint/indent": [2, 2], + "@typescript-eslint/explicit-function-return-type": 0, + "@typescript-eslint/no-explicit-any": 0, + "@typescript-eslint/explicit-member-accessibility": 0, + "@typescript-eslint/no-unused-vars": [0, {"argsIgnorePattern": "^_"}], + "no-undefined": 0, + "default-case": 0, + "prettier/prettier": 2, + "import/no-absolute-path": 2, + "import/no-cycle": 1, + "import/export": 2, + "import/no-named-as-default": 2, + "import/no-named-as-default-member": 2, + "import/first": 2, + "import/order": 2, + "import/newline-after-import": 2, + "import/no-default-export": 2 } } diff --git a/.gitignore b/.gitignore index 1054af2..42bc679 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,6 @@ typings/ # VSCode settings .vscode + +# Documentation +docs diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..928d845 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +# 2019 May 25 +# https://github.com/textileio/base + +**/docs/ +**/dist/ +**/vendor/ +**/node_modules/ +**/*.d.ts diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..0692aab --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,7 @@ +{ + "semi": false, + "printWidth": 120, + "trailingComma": "all", + "singleQuote": true, + "tabWidth": 2 +} diff --git a/package-lock.json b/package-lock.json index ed1d07d..74aff11 100644 --- a/package-lock.json +++ b/package-lock.json @@ -401,12 +401,6 @@ "google-protobuf": "^3.10.0" } }, - "@textile/tslint-rules": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@textile/tslint-rules/-/tslint-rules-1.0.3.tgz", - "integrity": "sha512-OENriDthBfnstZWWhX1WvoRyFp0vBJRdpeU82rlKLtk2eW5n4Bc6iE3GQPH53PwavMaKSxrovxi/8yU5ClpTbw==", - "dev": true - }, "@types/babel__core": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.3.tgz", @@ -568,43 +562,123 @@ "integrity": "sha512-gCubfBUZ6KxzoibJ+SCUc/57Ms1jz5NjHe4+dI2krNmU5zCPAphyLJYyTOg06ueIyfj+SaCUqmzun7ImlxDcKg==", "dev": true }, + "@typescript-eslint/eslint-plugin": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.9.0.tgz", + "integrity": "sha512-98rfOt3NYn5Gr9wekTB8TexxN6oM8ZRvYuphPs1Atfsy419SDLYCaE30aJkRiiTCwGEY98vOhFsEVm7Zs4toQQ==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "2.9.0", + "eslint-utils": "^1.4.3", + "functional-red-black-tree": "^1.0.1", + "regexpp": "^3.0.0", + "tsutils": "^3.17.1" + }, + "dependencies": { + "@typescript-eslint/experimental-utils": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.9.0.tgz", + "integrity": "sha512-0lOLFdpdJsCMqMSZT7l7W2ta0+GX8A3iefG3FovJjrX+QR8y6htFlFdU7aOVPL6pDvt6XcsOb8fxk5sq+girTw==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "2.9.0", + "eslint-scope": "^5.0.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.9.0.tgz", + "integrity": "sha512-v6btSPXEWCP594eZbM+JCXuFoXWXyF/z8kaSBSdCb83DF+Y7+xItW29SsKtSULgLemqJBT+LpT+0ZqdfH7QVmA==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "eslint-visitor-keys": "^1.1.0", + "glob": "^7.1.6", + "is-glob": "^4.0.1", + "lodash.unescape": "4.0.1", + "semver": "^6.3.0", + "tsutils": "^3.17.1" + } + }, + "eslint-scope": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "regexpp": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.0.0.tgz", + "integrity": "sha512-Z+hNr7RAVWxznLPuA7DIh8UNX1j9CDrUQxskw9IrBE1Dxue2lyXT+shqEIeLUjrokxIP8CMy1WkjgG3rTsd5/g==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "@typescript-eslint/experimental-utils": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-1.13.0.tgz", - "integrity": "sha512-zmpS6SyqG4ZF64ffaJ6uah6tWWWgZ8m+c54XXgwFtUv0jNz8aJAVx8chMCvnk7yl6xwn8d+d96+tWp7fXzTuDg==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.9.0.tgz", + "integrity": "sha512-0lOLFdpdJsCMqMSZT7l7W2ta0+GX8A3iefG3FovJjrX+QR8y6htFlFdU7aOVPL6pDvt6XcsOb8fxk5sq+girTw==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "1.13.0", - "eslint-scope": "^4.0.0" + "@typescript-eslint/typescript-estree": "2.9.0", + "eslint-scope": "^5.0.0" + }, + "dependencies": { + "eslint-scope": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + } } }, "@typescript-eslint/parser": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-1.13.0.tgz", - "integrity": "sha512-ITMBs52PCPgLb2nGPoeT4iU3HdQZHcPaZVw+7CsFagRJHUhyeTgorEwHXhFf3e7Evzi8oujKNpHc8TONth8AdQ==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.9.0.tgz", + "integrity": "sha512-fJ+dNs3CCvEsJK2/Vg5c2ZjuQ860ySOAsodDPwBaVlrGvRN+iCNC8kUfLFL8cT49W4GSiLPa/bHiMjYXA7EhKQ==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "1.13.0", - "@typescript-eslint/typescript-estree": "1.13.0", - "eslint-visitor-keys": "^1.0.0" + "@typescript-eslint/experimental-utils": "2.9.0", + "@typescript-eslint/typescript-estree": "2.9.0", + "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-1.13.0.tgz", - "integrity": "sha512-b5rCmd2e6DCC6tCTN9GSUAuxdYwCM/k/2wdjHGrIRGPSJotWMCe/dGpi66u42bhuh8q3QBzqM4TMA1GUUCJvdw==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.9.0.tgz", + "integrity": "sha512-v6btSPXEWCP594eZbM+JCXuFoXWXyF/z8kaSBSdCb83DF+Y7+xItW29SsKtSULgLemqJBT+LpT+0ZqdfH7QVmA==", "dev": true, "requires": { + "debug": "^4.1.1", + "eslint-visitor-keys": "^1.1.0", + "glob": "^7.1.6", + "is-glob": "^4.0.1", "lodash.unescape": "4.0.1", - "semver": "5.5.0" + "semver": "^6.3.0", + "tsutils": "^3.17.1" }, "dependencies": { "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true } } @@ -1667,12 +1741,6 @@ "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", @@ -2146,12 +2214,6 @@ } } }, - "confusing-browser-globals": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.9.tgz", - "integrity": "sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw==", - "dev": true - }, "connect-history-api-fallback": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz", @@ -2567,12 +2629,6 @@ "integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==", "dev": true }, - "diff": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", - "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", - "dev": true - }, "diff-sequences": { "version": "24.9.0", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-24.9.0.tgz", @@ -2920,17 +2976,6 @@ } } }, - "eslint-config-airbnb-base": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.0.0.tgz", - "integrity": "sha512-2IDHobw97upExLmsebhtfoD3NAKhV4H0CJWP3Uprd/uk+cHuWYOczPVxQ8PxLFUAw7o3Th1RAU8u1DoUpr+cMA==", - "dev": true, - "requires": { - "confusing-browser-globals": "^1.0.7", - "object.assign": "^4.1.0", - "object.entries": "^1.1.0" - } - }, "eslint-config-prettier": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.5.0.tgz", @@ -7560,18 +7605,6 @@ "object-keys": "^1.0.11" } }, - "object.entries": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.0.tgz", - "integrity": "sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.12.0", - "function-bind": "^1.1.1", - "has": "^1.0.3" - } - }, "object.getownpropertydescriptors": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", @@ -8070,6 +8103,47 @@ "vue-eslint-parser": "^2.0.2" }, "dependencies": { + "@typescript-eslint/experimental-utils": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-1.13.0.tgz", + "integrity": "sha512-zmpS6SyqG4ZF64ffaJ6uah6tWWWgZ8m+c54XXgwFtUv0jNz8aJAVx8chMCvnk7yl6xwn8d+d96+tWp7fXzTuDg==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "1.13.0", + "eslint-scope": "^4.0.0" + } + }, + "@typescript-eslint/parser": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-1.13.0.tgz", + "integrity": "sha512-ITMBs52PCPgLb2nGPoeT4iU3HdQZHcPaZVw+7CsFagRJHUhyeTgorEwHXhFf3e7Evzi8oujKNpHc8TONth8AdQ==", + "dev": true, + "requires": { + "@types/eslint-visitor-keys": "^1.0.0", + "@typescript-eslint/experimental-utils": "1.13.0", + "@typescript-eslint/typescript-estree": "1.13.0", + "eslint-visitor-keys": "^1.0.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-1.13.0.tgz", + "integrity": "sha512-b5rCmd2e6DCC6tCTN9GSUAuxdYwCM/k/2wdjHGrIRGPSJotWMCe/dGpi66u42bhuh8q3QBzqM4TMA1GUUCJvdw==", + "dev": true, + "requires": { + "lodash.unescape": "4.0.1", + "semver": "5.5.0" + }, + "dependencies": { + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + } + } + }, "ansi-regex": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", @@ -10217,31 +10291,10 @@ "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", "dev": true }, - "tslint": { - "version": "5.20.1", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz", - "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^4.0.1", - "glob": "^7.1.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.8.0", - "tsutils": "^2.29.0" - } - }, "tsutils": { - "version": "2.29.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", - "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", + "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", "dev": true, "requires": { "tslib": "^1.8.1" diff --git a/package.json b/package.json index 43c1812..9e59f32 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "build": "tsc", "prepublishOnly": "npm run build", "test": "ts-mocha -p tsconfig.json src/__test__/**/*.test.ts", - "lint": "./node_modules/tslint/bin/tslint -c tslint.json --project .", - "docs": "./node_modules/typedoc/bin/typedoc", + "lint": "eslint --fix --ext .mjs,.js,.jsx,.ts,.tsx src", + "docs": "typedoc", "precommit": "npm run lint && npm test", "preversion": "npm run docs; npm run precommit", "release": "npm version patch", @@ -45,18 +45,18 @@ }, "devDependencies": { "@improbable-eng/grpc-web-node-http-transport": "^0.11.0", - "@textile/tslint-rules": "^1.0.3", "@types/chai": "^4.2.5", "@types/mocha": "^5.2.7", "@types/uuid": "^3.4.6", + "@typescript-eslint/eslint-plugin": "^2.9.0", + "@typescript-eslint/parser": "^2.3.3", "chai": "^4.2.0", "eslint": "^6.6.0", - "eslint-config-airbnb-base": "^14.0.0", + "eslint-plugin-prettier": "^3.1.1", "eslint-config-prettier": "^6.5.0", "eslint-config-strict": "^14.0.1", "eslint-plugin-import": "^2.18.2", "eslint-plugin-node": "^10.0.0", - "eslint-plugin-prettier": "^3.1.1", "jest-cli": "^24.9.0", "jsdoc": "^3.6.3", "mocha": "^6.2.2", @@ -66,7 +66,6 @@ "ts-jest": "^24.1.0", "ts-loader": "^6.2.1", "ts-mocha": "^6.0.0", - "tslint": "^5.20.1", "typedoc": "^0.15.0", "typedoc-plugin-markdown": "^2.2.11", "typescript": "^3.7.2", diff --git a/src/ReadTransaction.ts b/src/ReadTransaction.ts index eb5f0cb..5584738 100644 --- a/src/ReadTransaction.ts +++ b/src/ReadTransaction.ts @@ -4,12 +4,11 @@ import { ModelFindByIDRequest, StartTransactionRequest, ReadTransactionRequest, - ReadTransactionReply + ReadTransactionReply, } from '@textile/threads-client-grpc/api_pb' -import {Transaction} from './Transaction' +import { Transaction } from './Transaction' export class ReadTransaction extends Transaction { - public async start() { const startReq = new StartTransactionRequest() startReq.setStoreid(super.storeID) diff --git a/src/Transaction.ts b/src/Transaction.ts index 7efffb2..01200bb 100644 --- a/src/Transaction.ts +++ b/src/Transaction.ts @@ -1,4 +1,4 @@ -import {grpc} from '@improbable-eng/grpc-web' +import { grpc } from '@improbable-eng/grpc-web' export class Transaction { protected readonly client: grpc.Client diff --git a/src/WriteTransaction.ts b/src/WriteTransaction.ts index b8f2a31..5ea9b5a 100644 --- a/src/WriteTransaction.ts +++ b/src/WriteTransaction.ts @@ -8,12 +8,11 @@ import { ModelFindByIDRequest, StartTransactionRequest, WriteTransactionRequest, - WriteTransactionReply + WriteTransactionReply, } from '@textile/threads-client-grpc/api_pb' -import {Transaction} from './Transaction' +import { Transaction } from './Transaction' export class WriteTransaction extends Transaction { - public async start() { const startReq = new StartTransactionRequest() startReq.setStoreid(this.storeID) @@ -28,7 +27,7 @@ export class WriteTransaction extends Transaction((resolve, reject) => { const createReq = new ModelCreateRequest() const list: any[] = [] - values.forEach((v) => { + values.forEach(v => { v['ID'] = uuid.v4() list.push(JSON.stringify(v)) }) @@ -47,7 +46,7 @@ export class WriteTransaction extends Transaction((resolve, reject) => { const saveReq = new ModelSaveRequest() const list: any[] = [] - values.forEach((v) => { + values.forEach(v => { v['ID'] = uuid.v4() list.push(JSON.stringify(v)) }) diff --git a/src/__test__/basic.test.ts b/src/__test__/basic.test.ts index 50ad81e..a50d83c 100644 --- a/src/__test__/basic.test.ts +++ b/src/__test__/basic.test.ts @@ -33,4 +33,3 @@ describe('basic store', function() { }) }) }) - diff --git a/src/__test__/index.test.ts b/src/__test__/index.test.ts index 8cda92e..3771f0b 100644 --- a/src/__test__/index.test.ts +++ b/src/__test__/index.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai' import { NodeHttpTransport } from '@improbable-eng/grpc-web-node-http-transport' -import {Client} from '../index' +import { Client } from '../index' const host = 'http://localhost:9091' const client = new Client(NodeHttpTransport()) diff --git a/src/index.ts b/src/index.ts index c2b7a4d..88d86ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as uuid from 'uuid' import { grpc } from '@improbable-eng/grpc-web' import { API } from '@textile/threads-client-grpc/api_pb_service' @@ -26,11 +27,11 @@ import { ReadTransactionReply, WriteTransactionRequest, WriteTransactionReply, - ListenRequest + ListenRequest, } from '@textile/threads-client-grpc/api_pb' +import * as pack from '../package.json' import { ReadTransaction } from './ReadTransaction' import { WriteTransaction } from './WriteTransaction' -import * as pack from '../package.json' // interface Response { // onMessage(callback: (message: T) => void): void @@ -38,7 +39,6 @@ import * as pack from '../package.json' // } export class Client { - public static version(): string { return pack.version } @@ -89,7 +89,7 @@ export class Client { req.setStoreid(storeID) req.setModelname(modelName) const list: any[] = [] - values.forEach((v) => { + values.forEach(v => { v['ID'] = uuid.v4() list.push(JSON.stringify(v)) }) @@ -102,7 +102,7 @@ export class Client { req.setStoreid(storeID) req.setModelname(modelName) const list: any[] = [] - values.forEach((v) => { + values.forEach(v => { v['ID'] = uuid.v4() list.push(JSON.stringify(v)) }) @@ -146,7 +146,7 @@ export class Client { return } const client = grpc.client(API.ReadTransaction, { - host: this.host + host: this.host, }) as grpc.Client return new ReadTransaction(client, storeID, modelName) } @@ -156,7 +156,7 @@ export class Client { return } const client = grpc.client(API.WriteTransaction, { - host: this.host! + host: this.host!, }) as grpc.Client return new WriteTransaction(client, storeID, modelName) } @@ -172,7 +172,8 @@ export class Client { private async unary< TRequest extends grpc.ProtobufMessage, TResponse extends grpc.ProtobufMessage, - M extends grpc.UnaryMethodDefinition>(methodDescriptor: M, req: TRequest) { + M extends grpc.UnaryMethodDefinition + >(methodDescriptor: M, req: TRequest) { return new Promise((resolve, reject) => { if (!this.host) { reject(new Error('host URL is not set')) @@ -181,7 +182,7 @@ export class Client { grpc.unary(methodDescriptor, { request: req, host: this.host, - onEnd: (res) => { + onEnd: res => { const { status, statusMessage, headers, message, trailers } = res if (status === grpc.Code.OK) { if (message) { @@ -192,10 +193,11 @@ export class Client { } else { reject(new Error(statusMessage)) } - } + }, }) }) } } +// eslint-disable-next-line import/no-default-export export default new Client() diff --git a/tslint.json b/tslint.json deleted file mode 100644 index e1e3529..0000000 --- a/tslint.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "defaultSeverity": "error", - "extends": [ - "@textile/tslint-rules/tslint" - ], - "linterOptions": { - "exclude": [ - "**/*.json", - "**/*.js", - "node_modules" - ] - }, - "jsRules": { - "quotemark": [true, "single", "jsx-single", "avoid-escape"], - "semicolon": [true, "never"], - "jsx-no-multiline-js": false, - "no-shadowed-variable": false, - "no-null-keyword": true, - "no-string-literal": false, - "no-this-assignment": false, - "no-submodule-imports": false, - "variable-name": false, - "no-console": [true, "log"], - "no-implicit-dependencies": [true, "dev"], - "max-classes-per-file": false, - "object-literal-sort-keys": false, - "ordered-imports": false, - "space-before-function-paren": false, - "trailing-comma": [ - true, - { - "multiline": "never", - "singleline": "never" - } - ], - "max-line-length": [true, 200] - }, - "rules": { - "member-access": false, - "quotemark": [true, "single", "jsx-single", "avoid-escape"], - "semicolon": [true, "never"], - "jsx-no-multiline-js": false, - "no-object-literal-type-assertion": false, - "no-implicit-dependencies": [false, "dev"], - "trailing-comma": [ - true, - { - "multiline": "never", - "singleline": "never" - } - ], - "max-line-length": [true, 200] - }, - "rulesDirectory": [] -}