Skip to content

Commit

Permalink
Add eslint rules to avoid misuse of promises/await, fix one issue it …
Browse files Browse the repository at this point in the history
…found (langchain-ai#60)

* Update hnswlib, fix missing await/return, fix index resize, add test for addTexts/resize

* Add two eslint rules to avoid misuse of promises/await

* Fix missing await in BaseChain.call
  • Loading branch information
nfcampos authored Feb 20, 2023
1 parent 428ae2b commit 6d23799
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"eslint.workingDirectories": [
"./langchain",
"./examples",
"./docs",
],
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "./.github/workflows/deploy.yml"
}
Expand Down
5 changes: 4 additions & 1 deletion langchain/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ module.exports = {
parserOptions: {
ecmaVersion: 12,
parser: "@typescript-eslint/parser",
project: "./tsconfig.json",
sourceType: "module",
},
plugins: ["@typescript-eslint"],
ignorePatterns: ["dist", "docs", "node_modules"],
ignorePatterns: ["dist", "docs", "node_modules", "*.d.ts", "*.js", "*.mjs"],
rules: {
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-shadow": 0,
"@typescript-eslint/no-use-before-define": ["error", "nofunc"],
"@typescript-eslint/no-unused-vars": ["warn", { args: "none" }],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
camelcase: 0,
"class-methods-use-this": 0,
"import/extensions": 0,
Expand Down
3 changes: 2 additions & 1 deletion langchain/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist/
docs/
docs/
*.d.ts
2 changes: 1 addition & 1 deletion langchain/chains/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export abstract class BaseChain implements ChainInputs {
// TODO(sean) add callback support
const outputValues = this._call(fullValues);
if (!(this.memory == null)) {
this.memory.saveContext(values, outputValues);
await this.memory.saveContext(values, outputValues);
}
return outputValues;
}
Expand Down
2 changes: 1 addition & 1 deletion langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@
"embeddings",
"vectorstores"
]
}
}
3 changes: 1 addition & 2 deletions langchain/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"exclude": [
"node_modules/",
"dist/",
"docs/",
"tests/"
"docs/"
],
"include": [
"./"
Expand Down

0 comments on commit 6d23799

Please sign in to comment.