From 35a5e2533e49aa4a88840ae87a3ee3c9d9fe731b Mon Sep 17 00:00:00 2001 From: versecafe <147033096+versecafe@users.noreply.github.com> Date: Tue, 3 Sep 2024 17:53:48 -0500 Subject: [PATCH] turbo eslint for packages (#248) --- packages/api/.eslintrc.cjs | 13 +++++++++++ packages/api/package.json | 1 + packages/api/tsconfig.lint.json | 4 ++++ packages/configs/eslint/library.js | 33 ++++++++++++++++++++++++++++ packages/configs/package.json | 9 +++++++- packages/shared/.eslintrc.cjs | 13 +++++++++++ packages/shared/package.json | 1 + packages/shared/tsconfig.lint.json | 4 ++++ pnpm-lock.yaml | 35 +++++++++++++++++++++++++++++- srcbook/.eslintrc.cjs | 13 +++++++++++ srcbook/package.json | 1 + srcbook/tsconfig.lint.json | 4 ++++ 12 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 packages/api/.eslintrc.cjs create mode 100644 packages/api/tsconfig.lint.json create mode 100644 packages/configs/eslint/library.js create mode 100644 packages/shared/.eslintrc.cjs create mode 100644 packages/shared/tsconfig.lint.json create mode 100644 srcbook/.eslintrc.cjs create mode 100644 srcbook/tsconfig.lint.json diff --git a/packages/api/.eslintrc.cjs b/packages/api/.eslintrc.cjs new file mode 100644 index 00000000..d8465d3c --- /dev/null +++ b/packages/api/.eslintrc.cjs @@ -0,0 +1,13 @@ +/** @type {import("eslint").Linter.Config} */ +module.exports = { + root: true, + extends: [require.resolve('@srcbook/configs/eslint/library.js')], + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.lint.json', + tsconfigRootDir: __dirname, + }, + globals: { + Bun: false, + }, +}; diff --git a/packages/api/package.json b/packages/api/package.json index 79b9c0a2..1d485a60 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -12,6 +12,7 @@ "test": "vitest", "prebuild": "rm -rf ./dist", "build": "tsc && cp -R ./drizzle ./dist/drizzle && cp -R ./srcbook/examples ./dist/srcbook/examples && cp -R ./prompts ./dist/prompts", + "lint": "eslint . --max-warnings 0", "check-types": "tsc", "depcheck": "depcheck", "generate": "drizzle-kit generate", diff --git a/packages/api/tsconfig.lint.json b/packages/api/tsconfig.lint.json new file mode 100644 index 00000000..dca67157 --- /dev/null +++ b/packages/api/tsconfig.lint.json @@ -0,0 +1,4 @@ +{ + "include": ["**/*.mts", "vite.config.ts", "drizzle.config.ts"], + "exclude": ["node_modules", "dist"] +} diff --git a/packages/configs/eslint/library.js b/packages/configs/eslint/library.js new file mode 100644 index 00000000..b394055c --- /dev/null +++ b/packages/configs/eslint/library.js @@ -0,0 +1,33 @@ +const { resolve } = require('node:path'); + +const project = resolve(process.cwd(), 'tsconfig.json'); + +/** @type {import("eslint").Linter.Config} */ +module.exports = { + extends: ['prettier', 'turbo'], + globals: { + React: true, + JSX: true, + }, + env: { + node: true, + }, + settings: { + 'import/resolver': { + typescript: { + project, + }, + }, + }, + ignorePatterns: [ + // Ignore dotfiles + '.*.js', + 'node_modules/', + 'dist/', + ], + overrides: [ + { + files: ['*.js?(x)', '*.ts?(x)'], + }, + ], +}; diff --git a/packages/configs/package.json b/packages/configs/package.json index 49b1945e..e0c9ac6e 100644 --- a/packages/configs/package.json +++ b/packages/configs/package.json @@ -1,5 +1,12 @@ { "name": "@srcbook/configs", "version": "0.0.0", - "private": true + "private": true, + "files": [ + "./eslint/library.js" + ], + "devDependencies": { + "eslint-config-turbo": "^2.1.1", + "eslint-config-prettier": "^9.1.0" + } } diff --git a/packages/shared/.eslintrc.cjs b/packages/shared/.eslintrc.cjs new file mode 100644 index 00000000..d8465d3c --- /dev/null +++ b/packages/shared/.eslintrc.cjs @@ -0,0 +1,13 @@ +/** @type {import("eslint").Linter.Config} */ +module.exports = { + root: true, + extends: [require.resolve('@srcbook/configs/eslint/library.js')], + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.lint.json', + tsconfigRootDir: __dirname, + }, + globals: { + Bun: false, + }, +}; diff --git a/packages/shared/package.json b/packages/shared/package.json index 3789f521..765c5147 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -7,6 +7,7 @@ "prebuild": "rm -rf ./dist", "build": "tsc", "dev": "tsc --watch --project .", + "lint": "eslint . --max-warnings 0", "check-types": "tsc", "prepublishOnly": "npm run build" }, diff --git a/packages/shared/tsconfig.lint.json b/packages/shared/tsconfig.lint.json new file mode 100644 index 00000000..c9eee2c3 --- /dev/null +++ b/packages/shared/tsconfig.lint.json @@ -0,0 +1,4 @@ +{ + "include": ["src", "index.ts", "tests"], + "exclude": ["node_modules", "dist"] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e3f08754..85c988be 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -125,7 +125,14 @@ importers: specifier: ^1.6.0 version: 1.6.0(@types/node@20.14.2) - packages/configs: {} + packages/configs: + devDependencies: + eslint-config-prettier: + specifier: ^9.1.0 + version: 9.1.0(eslint@8.57.0) + eslint-config-turbo: + specifier: ^2.1.1 + version: 2.1.1(eslint@8.57.0) packages/shared: dependencies: @@ -2610,6 +2617,10 @@ packages: resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} engines: {node: '>=6.0.0'} + dotenv@16.0.3: + resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==} + engines: {node: '>=12'} + drizzle-kit@0.22.7: resolution: {integrity: sha512-9THPCb2l1GPt7wxhws9LvTR0YG565ZlVgTuqGMwjs590Kch1pXu4GyjEArVijSF5m0OBj3qgdeKmuJXhKXgWFw==} hasBin: true @@ -2775,6 +2786,11 @@ packages: peerDependencies: eslint: '>=7.0.0' + eslint-config-turbo@2.1.1: + resolution: {integrity: sha512-JJF8SZErmgKCGkt124WUmTt0sQ5YLvPo2YxDsfzn9avGJC7/BQIa+3FZoDb3zeYYsZx91pZ6htQAJaKK8NQQAg==} + peerDependencies: + eslint: '>6.6.0' + eslint-plugin-jest@28.5.0: resolution: {integrity: sha512-6np6DGdmNq/eBbA7HOUNV8fkfL86PYwBfwyb8n23FXgJNTR8+ot3smRHjza9LGsBBZRypK3qyF79vMjohIL8eQ==} engines: {node: ^16.10.0 || ^18.12.0 || >=20.0.0} @@ -2813,6 +2829,11 @@ packages: peerDependencies: eslint: '>=7' + eslint-plugin-turbo@2.1.1: + resolution: {integrity: sha512-E/34kdQd0n3RP18+e0DSV0f3YTSCOojUh1p4X0Xrho2PBYmJ3umSnNo9FhkZt6UDACl+nBQcYTFkRHMz76lJdw==} + peerDependencies: + eslint: '>6.6.0' + eslint-scope@7.2.2: resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -6624,6 +6645,8 @@ snapshots: dependencies: esutils: 2.0.3 + dotenv@16.0.3: {} + drizzle-kit@0.22.7: dependencies: '@esbuild-kit/esm-loader': 2.6.5 @@ -6764,6 +6787,11 @@ snapshots: dependencies: eslint: 8.57.0 + eslint-config-turbo@2.1.1(eslint@8.57.0): + dependencies: + eslint: 8.57.0 + eslint-plugin-turbo: 2.1.1(eslint@8.57.0) + eslint-plugin-jest@28.5.0(@typescript-eslint/eslint-plugin@7.12.0(@typescript-eslint/parser@7.12.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5): dependencies: '@typescript-eslint/utils': 7.12.0(eslint@8.57.0)(typescript@5.4.5) @@ -6791,6 +6819,11 @@ snapshots: dependencies: eslint: 8.57.0 + eslint-plugin-turbo@2.1.1(eslint@8.57.0): + dependencies: + dotenv: 16.0.3 + eslint: 8.57.0 + eslint-scope@7.2.2: dependencies: esrecurse: 4.3.0 diff --git a/srcbook/.eslintrc.cjs b/srcbook/.eslintrc.cjs new file mode 100644 index 00000000..d8465d3c --- /dev/null +++ b/srcbook/.eslintrc.cjs @@ -0,0 +1,13 @@ +/** @type {import("eslint").Linter.Config} */ +module.exports = { + root: true, + extends: [require.resolve('@srcbook/configs/eslint/library.js')], + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.lint.json', + tsconfigRootDir: __dirname, + }, + globals: { + Bun: false, + }, +}; diff --git a/srcbook/package.json b/srcbook/package.json index a3810fe4..f509d32d 100644 --- a/srcbook/package.json +++ b/srcbook/package.json @@ -9,6 +9,7 @@ "depcheck": "depcheck", "prebuild": "rm -rf ./dist", "build": "tsc", + "lint": "eslint . --max-warnings 0", "prepublishOnly": "pnpm run --workspace-root build", "preversion": "pnpm run build", "postversion": "git push && git push --tags" diff --git a/srcbook/tsconfig.lint.json b/srcbook/tsconfig.lint.json new file mode 100644 index 00000000..cf3193f7 --- /dev/null +++ b/srcbook/tsconfig.lint.json @@ -0,0 +1,4 @@ +{ + "include": ["src", "bin", "tests", "public"], + "exclude": ["node_modules", "dist"] +}