From 53cb35666a7f0ecb6a6f8524ab078b6bb3af952a Mon Sep 17 00:00:00 2001 From: Artem Derevnjuk Date: Fri, 11 Feb 2022 20:24:21 +0300 Subject: [PATCH] build(tools): setup linting & formatting for project's file --- .eslintignore | 6 +++--- .eslintrc | 14 +++----------- .prettierignore | 3 ++- docs/configuration.md | 11 ++++++----- docs/package.json | 6 ------ lint-staged.config.js | 3 ++- package.json | 18 +++++++++--------- tsconfig.base.json | 24 +++--------------------- tsconfig.json | 17 +---------------- 9 files changed, 29 insertions(+), 73 deletions(-) diff --git a/.eslintignore b/.eslintignore index f592605ea45..e991834e776 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,10 +1,10 @@ -docs -examples node_modules -packages/**/test/**/*.ts +docs **/lib **/dist **/coverage +**/.nyc_output **/node_modules *-lock.json *.lock +benchmarks.* diff --git a/.eslintrc b/.eslintrc index 19f8301763f..3d3a1cd6033 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,10 +1,7 @@ { "parser": "@typescript-eslint/parser", - "extends": [ - "plugin:@typescript-eslint/recommended", - "prettier/@typescript-eslint", - "plugin:prettier/recommended" - ], + "extends": ["prettier", "plugin:@typescript-eslint/recommended"], + "plugins": ["@typescript-eslint"], "parserOptions": { "ecmaVersion": 2018, "sourceType": "module", @@ -31,10 +28,5 @@ "no-empty": "off", "prefer-const": "off", "no-fallthrough": "off" - }, - "ignorePatterns": [ - "**/lib/**/*.ts", - "**/test/**/*.ts", - "**/node_modules/**/*.ts" - ] + } } diff --git a/.prettierignore b/.prettierignore index f609b895621..60d0db0bba9 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,8 +1,9 @@ -docs node_modules **/lib **/dist **/coverage +**/.nyc_output **/node_modules *-lock.json *.lock +benchmarks.* diff --git a/docs/configuration.md b/docs/configuration.md index 4bf6f1771d4..e595073d6c1 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -4,11 +4,12 @@ next: false sidebar: auto otherTopics: true meta: - - name: description - content: Documentation over the server configuration. Ts.ED is built on top of Express/Koa and use TypeScript language. - - name: keywords - content: configuration ts.ed express typescript node.js javascript decorators mvc class models + - name: description + content: Documentation over the server configuration. Ts.ED is built on top of Express/Koa and use TypeScript language. + - name: keywords + content: configuration ts.ed express typescript node.js javascript decorators mvc class models --- + # Configuration -This page has moved to [/docs/configuration.html](/docs/configuration.html). \ No newline at end of file +This page has moved to [/docs/configuration.html](/docs/configuration.html). diff --git a/docs/package.json b/docs/package.json index 64d3417cc6a..a0a445671b5 100644 --- a/docs/package.json +++ b/docs/package.json @@ -8,12 +8,6 @@ "vuepress:serve": "vuepress dev .", "browserslist": "npx browserslist@latest --update-db" }, - "husky": { - "hooks": { - "pre-commit": "lint-staged", - "post-commit": "git update-index --again" - } - }, "repository": { "type": "git", "url": "https://github.com/tsedio/tsed.git" diff --git a/lint-staged.config.js b/lint-staged.config.js index e3abb3a4779..f63bf136417 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -1,3 +1,4 @@ module.exports = { - "packages/**/*.{ts,js}": ["prettier --write", "eslint --fix"] + "**/*.{ts,js}": ["eslint --fix"], + "**/*.{ts,js,json,md,yml,yaml}": ["prettier --write"] }; diff --git a/package.json b/package.json index 29c7f44a4c2..5ff9fbddfd5 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "test:packages": "lerna run test --stream --concurrency 2", "test:global": "cross-env NODE_ENV=test nyc mocha", "test:coverage": "yarn test:global && yarn test:packages", - "test:lint": "eslint packages --ext .ts", - "test:lint:fix": "eslint packages --ext .ts --fix", + "test:lint": "eslint '**/*.{ts,js}'", + "test:lint:fix": "yarn test:lint --fix", "coveralls": "nyc report --reporter=text-lcov | coveralls", "build": "monorepo build --verbose", "sync:packages": "monorepo sync packages", @@ -48,7 +48,7 @@ "vuepress:ref:build": "cd ./docs-references && yarn vuepress:build", "vuepress:docs:serve": "yarn docs:install && cd docs && yarn vuepress:serve -p 8080", "vuepress:ref:serve": "yarn docs:install && cd docs-references && yarn vuepress:serve -p 8081", - "prettier": "prettier '{packages,test}/**/*.ts' --write", + "prettier": "prettier '**/*.{ts,js,json,md,yml,yaml}' --write", "release": "semantic-release", "release:dryRun": "semantic-release --dry-run", "benchmarks": "lerna run benchmarks --stream --no-prefix", @@ -119,8 +119,8 @@ "@types/sinon-chai": "3.2.4", "@types/superagent": "4.1.10", "@types/supertest": "2.0.10", - "@typescript-eslint/eslint-plugin": "^4.27.0", - "@typescript-eslint/parser": "^4.27.0", + "@typescript-eslint/eslint-plugin": "^5.11.0", + "@typescript-eslint/parser": "^5.11.0", "chai": "4.2.0", "chai-as-promised": "7.1.1", "chalk": "4.1.0", @@ -128,9 +128,9 @@ "coveralls": "3.1.0", "cross-env": "7.0.2", "eslint": "^7.10.0", - "eslint-config-prettier": "6.12.0", - "eslint-plugin-mocha": "8.0.0", - "eslint-plugin-prettier": "3.1.4", + "eslint-config-prettier": "8.3.0", + "eslint-plugin-mocha": "10.0.3", + "eslint-plugin-prettier": "4.0.0", "faker": "^5.1.0", "fs-extra": "9.0.1", "husky": "^7.0.4", @@ -141,7 +141,7 @@ "mocha": "8.2.1", "moment": "2.29.1", "nyc": "15.1.0", - "prettier": "2.1.2", + "prettier": "2.5.1", "proxyquire": "2.1.3", "semantic-release": "17.2.3", "sinon": "9.0.3", diff --git a/tsconfig.base.json b/tsconfig.base.json index f070d42b987..16f806cda4c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -21,26 +21,8 @@ "noEmit": true, "allowJs": true, "skipLibCheck": true, - "lib": [ - "ES2019", - "esnext.asynciterable" - ], - "typeRoots": [ - "./node_modules/@types" - ] + "lib": ["ES2019", "esnext.asynciterable"], + "typeRoots": ["./node_modules/@types"] }, - "linterOptions": { - "exclude": [ - "docs", - "integration", - "examples/**" - ] - }, - "exclude": [ - "docs", - "integration", - "examples/**", - "coverage", - ".nyc_output" - ] + "exclude": ["docs", "integration", "examples/**", "coverage", ".nyc_output"] } diff --git a/tsconfig.json b/tsconfig.json index b0f8ccedf30..76fe399294e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,20 +15,5 @@ ] } }, - "linterOptions": { - "exclude": [ - "docs", - "integration", - "examples" - ] - }, - "exclude": [ - "test", - "**/test", - "docs", - "integration", - "examples", - "lib", - "**/lib" - ] + "exclude": ["node_modules", "**/node_modules", "**/dist", "**/.*/"] }