From 6e98f3fdfc63d213623ec4cce30d8010ff7d3179 Mon Sep 17 00:00:00 2001 From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:33:13 +0330 Subject: [PATCH] [CI]: fixed lint errors --- .eslintrc.json | 41 ++++++++------------- .prettierignore | 0 .prettierrc.json | 2 +- README.md | 2 +- bable.config.js | 2 +- docker-compose.test.yml | 5 +-- jest.config.js | 39 +++++++++----------- mongo-init.js | 8 ++-- package.json | 4 +- src/migrations/utils/ts-compiler.js | 2 +- tsconfig.json | 57 ++++++++++++----------------- 11 files changed, 68 insertions(+), 94 deletions(-) create mode 100644 .prettierignore diff --git a/.eslintrc.json b/.eslintrc.json index a1436192..8bb20223 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,27 +1,16 @@ { - "env": { - "es2021": true, - "node": true - }, - "extends": [ - "standard-with-typescript", - "prettier" - ], - "overrides": [], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module", - "project": "./tsconfig.json" - }, - "rules": {}, - "ignorePatterns": [ - "coverage", - "dist", - "__tests__/", - "jest.config.js", - "*.yml", - "mongo-init.js", - "bable.config.js", - ] -} \ No newline at end of file + "env": { + "es2021": true, + "node": true + }, + "extends": ["standard-with-typescript", "prettier"], + "overrides": [], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module", + "project": "./tsconfig.json" + }, + "rules": {}, + "ignorePatterns": ["coverage", "dist", "__tests__/", "jest.config.js", "*.yml", "mongo-init.js", "bable.config.js"] +} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..e69de29b diff --git a/.prettierrc.json b/.prettierrc.json index 4ddba9ab..a0d1c9a9 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -2,4 +2,4 @@ "printWidth": 120, "trailingComma": "all", "singleQuote": true -} \ No newline at end of file +} diff --git a/README.md b/README.md index 327ac98a..22e3e06c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ [![Maintainability](https://api.codeclimate.com/v1/badges/e1239b895f0ee2569b61/maintainability)](https://codeclimate.com/github/RnDAO/tc-discordBot/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/e1239b895f0ee2569b61/test_coverage)](https://codeclimate.com/github/RnDAO/tc-discordBot/test_coverage) -# tc-discordBot \ No newline at end of file +# tc-discordBot diff --git a/bable.config.js b/bable.config.js index b58143a8..a2efd0c1 100644 --- a/bable.config.js +++ b/bable.config.js @@ -1,2 +1,2 @@ // eslint-disable-next-line no-undef -module.exports = { presets: ['@babel/preset-env'] } \ No newline at end of file +module.exports = { presets: ['@babel/preset-env'] }; diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 55789f5b..744ccfb2 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -10,8 +10,8 @@ services: - NODE_ENV=test - DB_HOST=mongo - DB_PORT=27017 - - DB_USER=user - - DB_PASSWORD=1234 + - DB_USER=root + - DB_PASSWORD=pass - DB_NAME=RnDAO - DISCORD_CLIENT_ID=1 - DISCORD_CLIENT_SECRET=1 @@ -40,7 +40,6 @@ services: environment: - MONGO_INITDB_ROOT_USERNAME=root - MONGO_INITDB_ROOT_PASSWORD=pass - - MONGO_INITDB_DATABASE=RnDAO volumes: - ./docker-entrypoint-initdb.d/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro healthcheck: diff --git a/jest.config.js b/jest.config.js index e34f9740..0afca8d5 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,25 +1,20 @@ // eslint-disable-next-line no-undef module.exports = { - testPathIgnorePatterns: [ - "/__tests__/fixtures", - "/__tests__/utils", - ], - transform: { - '^.+\\.(ts|tsx)?$': 'ts-jest', - "^.+\\.(js|jsx)$": "babel-jest", + testPathIgnorePatterns: ['/__tests__/fixtures', '/__tests__/utils'], + transform: { + '^.+\\.(ts|tsx)?$': 'ts-jest', + '^.+\\.(js|jsx)$': 'babel-jest', + }, + collectCoverage: true, + testEnvironment: 'node', + coverageReporters: ['json', 'lcov', 'text', 'clover', 'html'], + collectCoverageFrom: ['src/**/*.ts*'], + coverageThreshold: { + global: { + branches: 80, + functions: 80, + lines: 80, + statements: -10, }, - collectCoverage: true, - testEnvironment: "node", - coverageReporters: ["json", "lcov", "text", "clover", "html"], - collectCoverageFrom: [ - "src/**/*.ts*" - ], - coverageThreshold: { - global: { - branches: 80, - functions: 80, - lines: 80, - statements: -10, - }, - } -}; \ No newline at end of file + }, +}; diff --git a/mongo-init.js b/mongo-init.js index 920ed657..10eed80b 100644 --- a/mongo-init.js +++ b/mongo-init.js @@ -1,4 +1,4 @@ -print("Started Adding the Users."); -db = db.getSiblingDB("RnDAO"); -db.createUser({ user: "user", pwd: "1234", roles: ["readWrite"] }) -print("End Adding the User Roles."); \ No newline at end of file +print('Started Adding the Users.'); +db = db.getSiblingDB('RnDAO'); +db.createUser({ user: 'root', pwd: 'pass', roles: ['readWrite'] }); +print('End Adding the User Roles.'); \ No newline at end of file diff --git a/package.json b/package.json index 74beec15..d11f8c18 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "test:ci": "jest --ci --detectOpenHandles", "lint": "eslint **/*.ts", "lint-fix": "eslint --fix **/*.ts", - "format": "prettier --write \"src/**/*.ts\" \"types/*.ts\" \"__tests__/**/*.ts\"", + "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\" \"types/*.ts\" \"__tests__/**/*.ts\" \"*.js\" \"*.json\" \"*.md\"", "migrate:create": "migrate create --template-file ./src/migrations/utils/template.ts --migrations-dir=\"./src/migrations/db\"", "migrate:up": "migrate --migrations-dir=\"./lib/migrations/db\" up", "migrate:down": "migrate --migrations-dir=\"./lib/migrations/db\" down" @@ -68,4 +68,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} \ No newline at end of file +} diff --git a/src/migrations/utils/ts-compiler.js b/src/migrations/utils/ts-compiler.js index 07ca65c5..1424f7e7 100644 --- a/src/migrations/utils/ts-compiler.js +++ b/src/migrations/utils/ts-compiler.js @@ -1,3 +1,3 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const tsNode = require('ts-node'); -module.exports = tsNode.register; \ No newline at end of file +module.exports = tsNode.register; diff --git a/tsconfig.json b/tsconfig.json index f73b1323..88e65525 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,34 +1,25 @@ { - "compilerOptions": { - "module": "commonjs", - "declaration": false, - "removeComments": false, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "ES2017", - "sourceMap": false, - "outDir": "./lib", - "baseUrl": "./", - "incremental": true, - "strict": true, - "noImplicitAny": true, - "skipLibCheck": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true - }, - "include": [ - "src/**/*", - "__tests__/**/*", - "types/**/*" - ], - "ts-node": { - "transpileOnly": true, - "files": true - }, - "exclude": [ - "./coverage", - "./lib", - "__tests__", - "jest.config.js" - ], -} \ No newline at end of file + "compilerOptions": { + "module": "commonjs", + "declaration": false, + "removeComments": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "ES2017", + "sourceMap": false, + "outDir": "./lib", + "baseUrl": "./", + "incremental": true, + "strict": true, + "noImplicitAny": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true + }, + "include": ["src/**/*", "__tests__/**/*", "types/**/*"], + "ts-node": { + "transpileOnly": true, + "files": true + }, + "exclude": ["./coverage", "./lib", "__tests__", "jest.config.js"] +}