From 0088646b70a9bcfe221b5a97e19eae6b90d03b1c Mon Sep 17 00:00:00 2001 From: Rafly Maulana Date: Sun, 20 Nov 2022 20:51:34 +0700 Subject: [PATCH] Share global eslint opt and move prettier config Share global eslint config from its root project to keep it low maintenance and reduce dry code Also move prettier config to it's own object to make all files including css, json, etc follows this rules, otherwise this rules will only works on eslint coverage files --- client/package.json | 16 +--------------- package.json | 25 +++++++++++++++++++++++++ server/package.json | 18 ++---------------- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/client/package.json b/client/package.json index d562336a..039a2e9c 100755 --- a/client/package.json +++ b/client/package.json @@ -34,13 +34,10 @@ }, "requireConfigFile": false }, - "plugins": [ - "prettier" - ], "extends": [ "airbnb", "airbnb/hooks", - "plugin:prettier/recommended" + "../package.json" ], "rules": { "import/no-extraneous-dependencies": [ @@ -51,14 +48,6 @@ "**/*.test.js" ] } - ], - "prettier/prettier": [ - "error", - { - "printWidth": 100, - "singleQuote": true, - "trailingComma": "all" - } ] } }, @@ -112,14 +101,11 @@ "enzyme": "^3.11.0", "eslint": "^8.20.0", "eslint-config-airbnb": "^19.0.4", - "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.6.1", - "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-react": "^7.30.1", "eslint-plugin-react-hooks": "^4.6.0", "jest-enzyme": "^7.1.2", - "prettier": "2.7.1", "react-app-rewired": "^2.2.1", "react-test-renderer": "^17.0.2" } diff --git a/package.json b/package.json index c3b0a3aa..27164892 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,34 @@ "npm run server:lint" ] }, + "eslintConfig": { + "plugins": [ + "prettier" + ], + "extends": [ + "plugin:prettier/recommended" + ], + "rules": { + "no-throw-literal": "off", + "no-undef": "off", + "prettier/prettier": "error" + } + }, + "prettier": { + "printWidth": 100, + "singleQuote": true, + "trailingComma": "all", + "endOfLine": "lf" + }, "dependencies": { "concurrently": "^7.3.0", "husky": "^8.0.1", "lint-staged": "^13.0.3" + }, + "devDependencies": { + "eslint": "^8.28.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.2.1", + "prettier": "^2.7.1" } } diff --git a/server/package.json b/server/package.json index 2a291ffe..0bfffe73 100644 --- a/server/package.json +++ b/server/package.json @@ -13,24 +13,13 @@ "test": "mocha test/lifecycle.test.js test/integration/**/*.test.js test/utils/**/*.test.js" }, "eslintConfig": { - "plugins": [ - "prettier" - ], "extends": [ "airbnb-base", - "plugin:prettier/recommended" + "../package.json" ], "rules": { "no-throw-literal": "off", - "no-undef": "off", - "prettier/prettier": [ - "error", - { - "printWidth": 100, - "singleQuote": true, - "trailingComma": "all" - } - ] + "no-undef": "off" }, "globals": { "_": true, @@ -63,12 +52,9 @@ "chai": "^4.3.6", "eslint": "^8.20.0", "eslint-config-airbnb-base": "^15.0.0", - "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", - "eslint-plugin-prettier": "^4.2.1", "mocha": "^9.2.2", "nodemon": "^2.0.19", - "prettier": "2.7.1", "supertest": "^6.2.4" }, "engines": {