From c71bb28928d74c0342828abc54eca22d862d7378 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Tue, 28 May 2024 10:04:57 -0700 Subject: [PATCH 1/3] infra[patch]: Improve yarn format --- libs/create-langchain-integration/.prettierrc | 19 +++++++++++++++++++ .../create-langchain-integration/package.json | 7 +++++-- package.json | 8 ++++---- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 libs/create-langchain-integration/.prettierrc diff --git a/libs/create-langchain-integration/.prettierrc b/libs/create-langchain-integration/.prettierrc new file mode 100644 index 000000000000..ba08ff04f677 --- /dev/null +++ b/libs/create-langchain-integration/.prettierrc @@ -0,0 +1,19 @@ +{ + "$schema": "https://json.schemastore.org/prettierrc", + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": false, + "quoteProps": "as-needed", + "jsxSingleQuote": false, + "trailingComma": "es5", + "bracketSpacing": true, + "arrowParens": "always", + "requirePragma": false, + "insertPragma": false, + "proseWrap": "preserve", + "htmlWhitespaceSensitivity": "css", + "vueIndentScriptAndStyle": false, + "endOfLine": "lf" +} diff --git a/libs/create-langchain-integration/package.json b/libs/create-langchain-integration/package.json index 431c608caf85..73af715c7bab 100644 --- a/libs/create-langchain-integration/package.json +++ b/libs/create-langchain-integration/package.json @@ -10,8 +10,11 @@ "scripts": { "dev": "ncc build ./index.ts -w -o dist/", "build": "ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register && cp ./template/.eslintrc.cjs ./template/.prettierrc ./template/.release-it.json ./dist/template", - "format": "prettier --write \"./\"", - "format:check": "prettier --check \"./\"" + "format": "prettier --config .prettierrc --write \".\"", + "format:check": "prettier --config .prettierrc --check \".\"", + "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", + "lint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", + "lint:fix": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --fix --ext .ts,.js src/" }, "devDependencies": { "@types/prompts": "^2", diff --git a/package.json b/package.json index 6f2fd9aab079..82c1d5abb96b 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,10 @@ "build": "turbo build --filter=\"!test-exports-*\"", "turbo:command": "turbo", "clean": "turbo clean", - "format": "turbo format", - "format:check": "turbo format:check", - "lint": "turbo lint", - "lint:fix": "turbo lint:fix", + "format": "turbo format --concurrency=50", + "format:check": "turbo format:check --concurrency=50", + "lint": "turbo lint --concurrency=50", + "lint:fix": "turbo lint:fix --concurrency=50", "test": "yarn test:unit && yarn test:exports:docker", "test:unit": "turbo test --filter=\"!test-exports-*\" --filter=!examples --filter=!api_refs --filter=!core_docs --filter=!create-langchain-integration", "test:unit:ci": "turbo test:ci", From ce572603b8b9b549886c0841ecdfb4500c44eb52 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Tue, 28 May 2024 11:27:27 -0700 Subject: [PATCH 2/3] chore: lint files --- docs/core_docs/package.json | 2 +- libs/create-langchain-integration/package.json | 7 +++++++ yarn.lock | 11 +++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/core_docs/package.json b/docs/core_docs/package.json index fed7f9f20dea..3aa329c28673 100644 --- a/docs/core_docs/package.json +++ b/docs/core_docs/package.json @@ -64,7 +64,7 @@ "eslint-plugin-react": "^7.30.1", "eslint-plugin-react-hooks": "^4.6.0", "glob": "^10.3.10", - "prettier": "^2.7.1", + "prettier": "^2.8.3", "rimraf": "^5.0.1", "supabase": "^1.148.6", "swc-loader": "^0.2.3", diff --git a/libs/create-langchain-integration/package.json b/libs/create-langchain-integration/package.json index 73af715c7bab..832b8a108e03 100644 --- a/libs/create-langchain-integration/package.json +++ b/libs/create-langchain-integration/package.json @@ -23,6 +23,13 @@ "commander": "^2.20.0", "conf": "^10.2.0", "dotenv": "^16.3.1", + "eslint": "^8.33.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^8.6.0", + "eslint-plugin-import": "^2.27.5", + "eslint-plugin-jest": "^27.6.0", + "eslint-plugin-no-instanceof": "^1.0.1", + "eslint-plugin-prettier": "^4.2.1", "fast-glob": "^3.3.2", "picocolors": "^1.0.0", "prettier": "^2.8.3", diff --git a/yarn.lock b/yarn.lock index 9afdba4f4310..dbc8d35a0e6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19330,7 +19330,7 @@ __metadata: isomorphic-dompurify: ^2.9.0 json-loader: ^0.5.7 marked: ^12.0.2 - prettier: ^2.7.1 + prettier: ^2.8.3 process: ^0.11.10 react: ^17.0.2 react-dom: ^17.0.2 @@ -19468,6 +19468,13 @@ __metadata: commander: ^2.20.0 conf: ^10.2.0 dotenv: ^16.3.1 + eslint: ^8.33.0 + eslint-config-airbnb-base: ^15.0.0 + eslint-config-prettier: ^8.6.0 + eslint-plugin-import: ^2.27.5 + eslint-plugin-jest: ^27.6.0 + eslint-plugin-no-instanceof: ^1.0.1 + eslint-plugin-prettier: ^4.2.1 fast-glob: ^3.3.2 picocolors: ^1.0.0 prettier: ^2.8.3 @@ -31849,7 +31856,7 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^2.6.2, prettier@npm:^2.7.1": +"prettier@npm:^2.6.2": version: 2.8.8 resolution: "prettier@npm:2.8.8" bin: From 0fc72ab67725e8d6c7a6a4403022757baf3bbb6b Mon Sep 17 00:00:00 2001 From: bracesproul Date: Tue, 28 May 2024 11:32:29 -0700 Subject: [PATCH 3/3] cr --- libs/create-langchain-integration/.eslintrc.cjs | 1 + libs/create-langchain-integration/helpers/git.ts | 16 ++++++++++++---- .../helpers/is-url.ts | 4 ++-- .../helpers/templates.ts | 2 +- libs/create-langchain-integration/package.json | 10 +++++----- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/libs/create-langchain-integration/.eslintrc.cjs b/libs/create-langchain-integration/.eslintrc.cjs index b50f0621e268..f05896865da6 100644 --- a/libs/create-langchain-integration/.eslintrc.cjs +++ b/libs/create-langchain-integration/.eslintrc.cjs @@ -29,6 +29,7 @@ module.exports = { "no-process-env": 2, "no-instanceof/no-instanceof": 2, "@typescript-eslint/explicit-module-boundary-types": 0, + "@typescript-eslint/no-explicit-any": "warn", "@typescript-eslint/no-empty-function": 0, "@typescript-eslint/no-shadow": 0, "@typescript-eslint/no-empty-interface": 0, diff --git a/libs/create-langchain-integration/helpers/git.ts b/libs/create-langchain-integration/helpers/git.ts index 416b381402ec..c0bafedb13f2 100644 --- a/libs/create-langchain-integration/helpers/git.ts +++ b/libs/create-langchain-integration/helpers/git.ts @@ -7,7 +7,9 @@ function isInGitRepository(): boolean { try { execSync("git rev-parse --is-inside-work-tree", { stdio: "ignore" }); return true; - } catch (_) {} + } catch (_) { + // no-op + } return false; } @@ -15,7 +17,9 @@ function isInMercurialRepository(): boolean { try { execSync("hg --cwd . root", { stdio: "ignore" }); return true; - } catch (_) {} + } catch (_) { + // no-op + } return false; } @@ -23,7 +27,9 @@ function isDefaultBranchSet(): boolean { try { execSync("git config init.defaultBranch", { stdio: "ignore" }); return true; - } catch (_) {} + } catch (_) { + // no-op + } return false; } @@ -54,7 +60,9 @@ export function tryGitInit(root: string): boolean { if (didInit) { try { fs.rmSync(path.join(root, ".git"), { recursive: true, force: true }); - } catch (_) {} + } catch (_) { + // no-op + } } return false; } diff --git a/libs/create-langchain-integration/helpers/is-url.ts b/libs/create-langchain-integration/helpers/is-url.ts index eb87b975252f..a84d26cf274b 100644 --- a/libs/create-langchain-integration/helpers/is-url.ts +++ b/libs/create-langchain-integration/helpers/is-url.ts @@ -1,7 +1,7 @@ export function isUrl(url: string): boolean { try { - new URL(url); - return true; + const newUrl = new URL(url); + return Boolean(newUrl); } catch (error) { return false; } diff --git a/libs/create-langchain-integration/helpers/templates.ts b/libs/create-langchain-integration/helpers/templates.ts index 2a3d0f8603f2..ce821f9f878f 100644 --- a/libs/create-langchain-integration/helpers/templates.ts +++ b/libs/create-langchain-integration/helpers/templates.ts @@ -2,7 +2,7 @@ import path from "path"; import fs from "fs/promises"; import os from "os"; -import { copy } from "./copy"; +import { copy } from "./copy.js"; /** * Install a internal template to a given `root` directory. diff --git a/libs/create-langchain-integration/package.json b/libs/create-langchain-integration/package.json index 832b8a108e03..c8b3e57b2458 100644 --- a/libs/create-langchain-integration/package.json +++ b/libs/create-langchain-integration/package.json @@ -10,11 +10,11 @@ "scripts": { "dev": "ncc build ./index.ts -w -o dist/", "build": "ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register && cp ./template/.eslintrc.cjs ./template/.prettierrc ./template/.release-it.json ./dist/template", - "format": "prettier --config .prettierrc --write \".\"", - "format:check": "prettier --config .prettierrc --check \".\"", - "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", - "lint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", - "lint:fix": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --fix --ext .ts,.js src/" + "format": "prettier --config .prettierrc --write \"./helpers\"", + "format:check": "prettier --config .prettierrc --check \"./helpers\"", + "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js ./helpers", + "lint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js ./helpers", + "lint:fix": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --fix --ext .ts,.js ./helpers" }, "devDependencies": { "@types/prompts": "^2",