Skip to content

Commit

Permalink
feat: config eslint, prettier (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
lamngockhuong authored Sep 22, 2024
1 parent a6fb173 commit e02a32e
Show file tree
Hide file tree
Showing 19 changed files with 156 additions and 118 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,29 @@ out/
build
dist

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# Debug
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Misc
.DS_Store
Expand Down
20 changes: 2 additions & 18 deletions apps/api/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
parser: '@typescript-eslint/parser',
extends: ['@repo/eslint-config/nest.js'],
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
4 changes: 0 additions & 4 deletions apps/api/.prettierrc

This file was deleted.

4 changes: 4 additions & 0 deletions apps/api/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import("prettier").Config} */
module.exports = {
...require('@repo/eslint-config/prettier-base'),
};
37 changes: 16 additions & 21 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,30 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"reflect-metadata": "^0.2.0",
"@nestjs/common": "^10.4.3",
"@nestjs/core": "^10.4.3",
"@nestjs/platform-express": "^10.4.3",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"@nestjs/cli": "^10.4.5",
"@nestjs/schematics": "^10.1.4",
"@nestjs/testing": "^10.4.3",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.2",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.13",
"@types/node": "^20.3.1",
"@types/supertest": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.42.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"prettier": "^3.0.0",
"@types/supertest": "^6.0.2",
"jest": "^29.7.0",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
"typescript": "^5.6.2"
},
"jest": {
"moduleFileExtensions": [
Expand Down
12 changes: 6 additions & 6 deletions apps/docs/theme.config.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react'
import { DocsThemeConfig } from 'nextra-theme-docs'
import React from "react";
import { DocsThemeConfig } from "nextra-theme-docs";

const config: DocsThemeConfig = {
logo: <span>NestJS Turbo Monorepo</span>,
project: {
link: 'https://github.com/vndevteam/nestjs-turbo-monorepo',
link: "https://github.com/vndevteam/nestjs-turbo-monorepo",
},
docsRepositoryBase: 'https://github.com/vndevteam/nestjs-turbo-monorepo',
docsRepositoryBase: "https://github.com/vndevteam/nestjs-turbo-monorepo",
footer: {
text: 'VnDevTeam',
text: "VnDevTeam",
},
}
};

export default config;
4 changes: 4 additions & 0 deletions apps/web/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import("prettier").Config} */
module.exports = {
...require('@repo/eslint-config/prettier-base'),
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"scripts": {
"build": "turbo build",
"dev": "turbo dev",
"lint": "turbo lint",
"test": "turbo test",
"test:e2e": "turbo test:e2e",
"lint": "turbo lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"prepare": "husky || true"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# `@turbo/eslint-config`
# `@repo/eslint-config`

Collection of internal eslint configurations.
21 changes: 21 additions & 0 deletions packages/eslint-config/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier",
"turbo",
],
plugins: ["@typescript-eslint/eslint-plugin"],
parser: "@typescript-eslint/parser",
ignorePatterns: [
".*.js",
"*.setup.js",
"*.config.js",
".turbo/",
"dist/",
"coverage/",
"node_modules/",
],
};
2 changes: 1 addition & 1 deletion packages/eslint-config/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "turbo"],
extends: ["./base.js"],
plugins: ["only-warn"],
globals: {
React: true,
Expand Down
22 changes: 22 additions & 0 deletions packages/eslint-config/nest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["./base.js"],
rules: {
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
},
env: {
node: true,
jest: true,
},
};
12 changes: 1 addition & 11 deletions packages/eslint-config/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [
"eslint:recommended",
"prettier",
require.resolve("@vercel/style-guide/eslint/next"),
"turbo",
],
extends: ["./base.js", require.resolve("@vercel/style-guide/eslint/next")],
globals: {
React: true,
JSX: true,
Expand All @@ -26,10 +21,5 @@ module.exports = {
},
},
},
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
],
overrides: [{ files: ["*.js?(x)", "*.ts?(x)"] }],
};
10 changes: 7 additions & 3 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
"version": "0.0.0",
"private": true,
"files": [
"base.js",
"library.js",
"nest.js",
"next.js",
"prettier-base.js",
"react-internal.js"
],
"devDependencies": {
"@vercel/style-guide": "^5.2.0",
"eslint-config-turbo": "^2.0.0",
"eslint-config-turbo": "^2.1.2",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-only-warn": "^1.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"eslint-plugin-prettier": "^5.2.1",
"@typescript-eslint/parser": "^7.1.1",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"typescript": "^5.3.3"
}
}
5 changes: 5 additions & 0 deletions packages/eslint-config/prettier-base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import("prettier").Config} */
module.exports = {
singleQuote: true,
trailingComma: 'all',
};
11 changes: 7 additions & 4 deletions packages/eslint-config/react-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ const { resolve } = require("node:path");

const project = resolve(process.cwd(), "tsconfig.json");

/*
/**
* This is a custom ESLint configuration for use with
* internal (bundled by their consumer) libraries
* that utilize React.
*
* This config extends the Vercel Engineering Style Guide.
* For more information, see https://github.com/vercel/style-guide
*
* @type {import("eslint").Linter.Config}
*/

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "turbo"],
extends: ["./base.js"],
plugins: ["only-warn"],
globals: {
React: true,
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import("prettier").Config} */
module.exports = {
...require('@repo/eslint-config/prettier-base'),
};
Loading

0 comments on commit e02a32e

Please sign in to comment.