From a32f12c8f30f9267835fd35f09b14dc0df61a14a Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Fri, 9 Dec 2022 13:27:27 +0100 Subject: [PATCH] Add prettier --- .prettierignore | 23 +++++++++++++++++++++++ .prettierrc.js | 1 + .stylelintrc.js | 1 + package.json | 9 ++++++--- yarn.lock | 23 +++++++++++++++++++---- 5 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc.js diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..b0e23c13a5 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,23 @@ +/build +/dist +/lib +/node_modules +/packages/ +/webapp +/*.log +yarn.lock +electron/dist +electron/pub +**/.idea +/.tmp +/webpack-stats.json +.vscode +.vscode/ +.env +/coverage +# Auto-generated file +/src/modules.ts +/src/i18n/strings +/build_config.yaml +# Raises an error because it contains a template var breaking the script tag +src/vector/index.html diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000000..6a17910f1a --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1 @@ +module.exports = require("eslint-plugin-matrix-org/.prettierrc.js"); diff --git a/.stylelintrc.js b/.stylelintrc.js index 2c7693849c..f3d7a268b8 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -1,3 +1,4 @@ module.exports = { ...require("matrix-react-sdk/.stylelintrc.js"), + extends: ["stylelint-config-standard", "stylelint-config-prettier"], }; diff --git a/package.json b/package.json index fa44f51c57..87ca6c2e57 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,8 @@ "start:res": "yarn build:jitsi && node scripts/copy-res.js -w", "start:js": "webpack-dev-server --host=0.0.0.0 --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js -w --mode development --disable-host-check --hot", "lint": "yarn lint:types && yarn lint:js && yarn lint:style", - "lint:js": "eslint --max-warnings 0 src module_system test", - "lint:js-fix": "eslint --fix src module_system test", + "lint:js": "eslint --max-warnings 0 src module_system test && prettier --check .", + "lint:js-fix": "prettier --write . && eslint --fix src module_system test", "lint:types": "tsc --noEmit --jsx react && tsc --noEmit --project ./tsconfig.module_system.json", "lint:style": "stylelint \"res/css/**/*.pcss\"", "test": "jest", @@ -111,9 +111,10 @@ "dotenv": "^16.0.2", "eslint": "8.28.0", "eslint-config-google": "^0.14.0", + "eslint-config-prettier": "^8.5.0", "eslint-plugin-deprecate": "^0.7.0", "eslint-plugin-import": "^2.25.4", - "eslint-plugin-matrix-org": "^0.8.0", + "eslint-plugin-matrix-org": "^0.9.0", "eslint-plugin-react": "^7.28.0", "eslint-plugin-react-hooks": "^4.3.0", "eslint-plugin-unicorn": "^45.0.0", @@ -148,6 +149,7 @@ "postcss-preset-env": "^6.7.0", "postcss-scss": "^4.0.4", "postcss-simple-vars": "^5.0.2", + "prettier": "2.8.0", "raw-loader": "^4.0.2", "rimraf": "^3.0.2", "semver": "^7.3.7", @@ -155,6 +157,7 @@ "string-replace-loader": "3", "style-loader": "2", "stylelint": "^14.9.1", + "stylelint-config-prettier": "^9.0.4", "stylelint-config-standard": "^29.0.0", "stylelint-scss": "^4.2.0", "terser-webpack-plugin": "^4.0.0", diff --git a/yarn.lock b/yarn.lock index 1ed02f17b4..abb0d1960b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5017,6 +5017,11 @@ eslint-config-google@^0.14.0: resolved "https://registry.yarnpkg.com/eslint-config-google/-/eslint-config-google-0.14.0.tgz#4f5f8759ba6e11b424294a219dbfa18c508bcc1a" integrity sha512-WsbX4WbjuMvTdeVL6+J3rK1RGhCTqjsFjX7UMSMgZiyxxaNLkoJENbrGExzERFeoTpGw3F3FypTiWAP9ZXzkEw== +eslint-config-prettier@^8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1" + integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q== + eslint-import-resolver-node@^0.3.6: version "0.3.6" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz#4048b958395da89668252001dbd9eca6b83bacbd" @@ -5056,10 +5061,10 @@ eslint-plugin-import@^2.25.4: resolve "^1.22.0" tsconfig-paths "^3.14.1" -eslint-plugin-matrix-org@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-matrix-org/-/eslint-plugin-matrix-org-0.8.0.tgz#daa1396900a8cb1c1d88f1a370e45fc32482cd9e" - integrity sha512-/Poz/F8lXYDsmQa29iPSt+kO+Jn7ArvRdq10g0CCk8wbRS0sb2zb6fvd9xL1BgR5UDQL771V0l8X32etvY5yKA== +eslint-plugin-matrix-org@^0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-matrix-org/-/eslint-plugin-matrix-org-0.9.0.tgz#b2a5186052ddbfa7dc9878779bafa5d68681c7b4" + integrity sha512-+j6JuMnFH421Z2vOxc+0YMt5Su5vD76RSatviy3zHBaZpgd+sOeAWoCLBHD5E7mMz5oKae3Y3wewCt9LRzq2Nw== eslint-plugin-react-hooks@^4.3.0: version "4.6.0" @@ -10147,6 +10152,11 @@ preserve@^0.2.0: resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" integrity sha512-s/46sYeylUfHNjI+sA/78FAHlmIuKqI9wNnzEOGehAlUUYeObv5C2mOinXBjyUyWmJ2SfcS2/ydApH4hTF4WXQ== +prettier@2.8.0: + version "2.8.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.0.tgz#c7df58393c9ba77d6fba3921ae01faf994fb9dc9" + integrity sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA== + pretty-error@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.2.tgz#be89f82d81b1c86ec8fdfbc385045882727f93b6" @@ -11672,6 +11682,11 @@ stylehacks@^4.0.0: postcss "^7.0.0" postcss-selector-parser "^3.0.0" +stylelint-config-prettier@^9.0.4: + version "9.0.4" + resolved "https://registry.yarnpkg.com/stylelint-config-prettier/-/stylelint-config-prettier-9.0.4.tgz#1b1dda614d5b3ef6c1f583fa6fa55f88245eb00b" + integrity sha512-38nIGTGpFOiK5LjJ8Ma1yUgpKENxoKSOhbDNSemY7Ep0VsJoXIW9Iq/2hSt699oB9tReynfWicTAoIHiq8Rvbg== + stylelint-config-recommended@^9.0.0: version "9.0.0" resolved "https://registry.yarnpkg.com/stylelint-config-recommended/-/stylelint-config-recommended-9.0.0.tgz#1c9e07536a8cd875405f8ecef7314916d94e7e40"