Skip to content

Commit 296e412

Browse files
Update ESLint Config (#17)
1 parent a58ec5e commit 296e412

28 files changed

+542
-386
lines changed

.eslintrc.json

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,17 @@
11
{
2+
"root": true,
23
"parser": "@typescript-eslint/parser",
34
"parserOptions": {
45
"project": "tsconfig.json",
56
"sourceType": "module"
67
},
7-
"plugins": ["@typescript-eslint/eslint-plugin", "import-helpers"],
8+
"plugins": ["import-helpers"],
89
"extends": [
9-
"plugin:@typescript-eslint/recommended",
10-
"plugin:prettier/recommended"
10+
"@techmmunity/eslint-config/common",
11+
"@techmmunity/eslint-config/typescript",
12+
"@techmmunity/eslint-config/jest"
1113
],
12-
"root": true,
13-
"env": {
14-
"node": true,
15-
"jest": true
16-
},
17-
"ignorePatterns": [".eslintrc.js"],
1814
"rules": {
19-
"@typescript-eslint/explicit-member-accessibility": ["error"],
20-
"no-case-declarations": 0,
21-
"accessor-pairs": ["warn", { "setWithoutGet": false }],
22-
"no-param-reassign": "error",
23-
"no-new": "off",
24-
"no-prototype-builtins": "off",
25-
"no-restricted-syntax": "off",
26-
"max-classes-per-file": "off",
27-
"no-underscore-dangle": "off",
28-
"@typescript-eslint/camelcase": "off",
29-
"prettier/prettier": "error",
30-
"class-methods-use-this": "off",
31-
"@typescript-eslint/no-unused-vars": 0,
32-
"@typescript-eslint/interface-name-prefix": "off",
33-
"@typescript-eslint/explicit-function-return-type": "off",
34-
"@typescript-eslint/explicit-module-boundary-types": "off",
35-
"@typescript-eslint/no-use-before-define": [
36-
"error",
37-
{ "functions": false }
38-
],
3915
"import-helpers/order-imports": [
4016
"warn",
4117
{

.lintstagedrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"*.{ts,tsx}": [
3+
"npx prettier --write src",
4+
"eslint src/**/*.ts --fix-dry-run"
5+
]
6+
}

.prettierignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Compiled Output
2+
/dist
3+
/node_modules
4+
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# OS
14+
.DS_Store
15+
16+
# Tests
17+
/coverage
18+
/.nyc_output
19+
20+
# IDEs and editors
21+
/.idea
22+
.project
23+
.classpath
24+
.c9/
25+
*.launch
26+
.settings/
27+
*.sublime-workspace
28+
29+
# IDE - VSCode
30+
.vscode/*
31+
!.vscode/settings.json
32+
!.vscode/tasks.json
33+
!.vscode/launch.json
34+
!.vscode/extensions.json
35+
36+
# Enviroment
37+
*.env*
38+
!.env.docker
39+
40+
# Core
41+
src/core
42+
43+
# Local Database
44+
/mongo-volume
45+
46+
# Auto Generated Files
47+
src/schemas.gql
48+
49+
# Docker
50+
docker/
51+
52+
# tsconfig
53+
tsconfig*
54+
!tsconfig.json
55+
!tsconfig.build.json

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"bierner.markdown-preview-github-styles",
88
"pkief.material-icon-theme",
99
"esbenp.prettier-vscode",
10-
"gruntfuggly.todo-tree"
10+
"gruntfuggly.todo-tree",
11+
"shardulm94.trailing-spaces"
1112
]
1213
}

.vscode/settings.json

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
// Disable Tab To Space Conversion
66
"editor.insertSpaces": false,
77

8-
// Make Prettier The Default Code Formatter
9-
"editor.defaultFormatter": "esbenp.prettier-vscode",
10-
118
// Config Default End Of Line Formatting
129
"files.eol": "\n",
1310

@@ -26,30 +23,23 @@
2623

2724
// Make VSCode understand this files as files of this languages
2825
"files.associations": {
29-
".env.hmg": "env",
30-
".env.docker": "env",
31-
".env.test": "env"
32-
},
26+
".prettierignore": "ignore",
27+
".lintstagedrc": "json",
28+
".env.*": "env"
29+
},
30+
"material-icon-theme.languages.associations": {
31+
"env": "tune"
32+
},
3333

3434
// ================ Languages General Config ====================
3535

3636
// TypeScript
3737
"typescript.updateImportsOnFileMove.enabled": "always",
3838
"typescript.tsserver.log": "verbose",
3939
"typescript.suggest.autoImports": true,
40-
"[typescript]": {
41-
"editor.defaultFormatter": "vscode.typescript-language-features"
42-
},
4340
// JavaScript
4441
"javascript.updateImportsOnFileMove.enabled": "always",
4542
"javascript.suggest.autoImports": true,
46-
"[javascript]": {
47-
"editor.defaultFormatter": "esbenp.prettier-vscode"
48-
},
49-
// JSON
50-
"[json]": {
51-
"editor.defaultFormatter": "vscode.json-language-features"
52-
},
5343

5444
// =========== Plugins & Extensions General Config ===============
5545

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
coverageDirectory: "../coverage",
1616
testEnvironment: "node",
1717
moduleDirectories: ["node_modules", "src"],
18-
clearMocks: true,
18+
resetMocks: true,
1919
// coverageThreshold: {
2020
// global: {
2121
// branches: 100,

package.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@nestjs/swagger": "^4.8.0",
1313
"@nestjs/terminus": "^7.1.2",
1414
"@nestjs/typeorm": "^7.1.5",
15+
"@techmmunity/database-error-handler": "^0.0.5",
1516
"moment-timezone": "^0.5.33",
1617
"node-fetch": "^2.6.1",
1718
"pg": "^8.6.0",
@@ -27,44 +28,41 @@
2728
"@nestjs/cli": "^7.6.0",
2829
"@nestjs/schematics": "^7.3.1",
2930
"@nestjs/testing": "^7.6.15",
31+
"@techmmunity/eslint-config": "^1.2.1",
3032
"@types/express": "^4.17.8",
3133
"@types/jest": "^26.0.23",
3234
"@types/node": "^15.0.1",
3335
"@types/node-fetch": "^2.5.10",
3436
"@types/supertest": "^2.0.11",
35-
"@typescript-eslint/eslint-plugin": "^4.22.0",
36-
"@typescript-eslint/parser": "^4.22.0",
37-
"env-cmd": "^10.1.0",
38-
"eslint": "^7.25.0",
39-
"eslint-config-prettier": "8.3.0",
40-
"eslint-plugin-import": "^2.22.1",
37+
"@typescript-eslint/eslint-plugin": "^4.25.0",
38+
"@typescript-eslint/parser": "^4.25.0",
39+
"eslint": "^7.27.0",
40+
"eslint-plugin-filenames": "^1.3.2",
41+
"eslint-plugin-import": "^2.23.4",
4142
"eslint-plugin-import-helpers": "^1.1.0",
43+
"eslint-plugin-jest": "^24.3.6",
44+
"eslint-plugin-jest-formatting": "^3.0.0",
45+
"eslint-plugin-prefer-arrow": "^1.2.3",
4246
"eslint-plugin-prettier": "^3.4.0",
47+
"eslint-plugin-sonarjs": "^0.7.0",
4348
"husky": "^6.0.0",
4449
"jest": "^26.6.3",
4550
"lint-staged": "^10.5.4",
46-
"prettier": "^2.1.2",
51+
"prettier": "^2.3.0",
4752
"supertest": "^6.0.0",
4853
"ts-jest": "^26.5.5",
4954
"ts-loader": "^9.1.1",
5055
"ts-node": "^9.0.0",
5156
"tsconfig-paths": "^3.9.0",
5257
"typescript": "^4.2.4"
5358
},
54-
"lint-staged": {
55-
"*.{ts,tsx}": [
56-
"npx prettier --write src",
57-
"eslint src/**/*.ts --fix-dry-run"
58-
]
59-
},
6059
"scripts": {
6160
"clear": "rimraf dist && rimraf tsconfig.build.tsbuildinfo && rimraf tsconfig.tsbuildinfo",
6261
"clear:dev": "yarn clear && yarn dev",
6362
"prebuild": "rimraf dist",
6463
"build": "nest build",
6564
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
6665
"start": "nest start",
67-
"dev": "env-cmd yarn dev:docker",
6866
"dev:docker": "nest start --watch --exec 'node -r tsconfig-paths/register'",
6967
"start:debug": "nest start --debug --watch",
7068
"start:prod": "node dist/main",

src/app.module.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@ import { V1Module } from "v1/v1.module";
55
@Module({
66
imports: [V1Module],
77
})
8-
export class AppModule {
9-
//
10-
}
8+
export class AppModule {}

src/main.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Logger } from "@nestjs/common";
22
import { NestFactory } from "@nestjs/core";
3-
import { Swagger } from "swagger";
3+
import { setSwagger } from "swagger";
44
import {
55
initializeTransactionalContext,
66
patchTypeORMRepositoryWithBaseRepository,
@@ -10,17 +10,17 @@ import { AppModule } from "./app.module";
1010

1111
const { PORT } = process.env;
1212

13-
async function server() {
13+
const server = async () => {
1414
initializeTransactionalContext();
1515
patchTypeORMRepositoryWithBaseRepository();
1616

1717
const logger = new Logger("Main");
1818

1919
const app = await NestFactory.create(AppModule);
2020

21-
Swagger(app);
21+
setSwagger(app);
2222

2323
app.listen(PORT, () => logger.log("Server Ready"));
24-
}
24+
};
2525

2626
server();

src/swagger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { INestApplication } from "@nestjs/common";
22
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
33

4-
export const Swagger = (app: INestApplication) => {
4+
export const setSwagger = (app: INestApplication) => {
55
const config = new DocumentBuilder()
66
.setTitle("Base Service")
77
.setDescription("")

0 commit comments

Comments
 (0)