diff --git a/.eslintrc.js b/.eslintrc.js index d24484c405..a5c8070e61 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,7 +19,6 @@ module.exports = { "no-constant-condition": "off", "prefer-promise-reject-errors": "off", "no-async-promise-executor": "off", - "quotes": "off", "no-extra-boolean-cast": "off", // Bind or arrow functions in props causes performance issues (but we @@ -107,7 +106,6 @@ module.exports = { // Things we do that break the ideal style "prefer-promise-reject-errors": "off", - "quotes": "off", "no-extra-boolean-cast": "off", // Remove Babel things manually due to override limitations @@ -121,10 +119,6 @@ module.exports = { "@typescript-eslint/ban-ts-comment": "off", // We're okay with assertion errors when we ask for them "@typescript-eslint/no-non-null-assertion": "off", - - // The non-TypeScript rule produces false positives - "func-call-spacing": "off", - "@typescript-eslint/func-call-spacing": ["error"], }, }, // temporary override for offending icon require files diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..84d380c576 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,16 @@ +/coverage +/lib + +/.idea +.vscode +.vscode/ + +# Legacy skinning file that some people might still have +/src/component-index.js + +/.npmrc +/*.log +package-lock.json +yarn.lock + +/src/i18n/strings 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 ab5c796837..9623a23875 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -1,12 +1,14 @@ module.exports = { - "extends": "stylelint-config-standard", + "extends": [ + "stylelint-config-standard", + "stylelint-config-prettier", + ], customSyntax: require('postcss-scss'), "plugins": [ "stylelint-scss", ], "rules": { "color-hex-case": null, - "indentation": 4, "comment-empty-line-before": null, "declaration-empty-line-before": null, "length-zero-no-unit": null, diff --git a/package.json b/package.json index 44ef1a35b3..aa0cc5c5ca 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,8 @@ "start:all": "echo THIS IS FOR LEGACY PURPOSES ONLY. && yarn start:build", "start:build": "babel src -w -s -d lib --verbose --extensions \".ts,.js\"", "lint": "yarn lint:types && yarn lint:js && yarn lint:style", - "lint:js": "eslint --max-warnings 0 src test cypress", - "lint:js-fix": "eslint --fix src test cypress", + "lint:js": "eslint --max-warnings 0 src test cypress && prettier --check .", + "lint:js-fix": "prettier --loglevel=warn --write . && eslint --fix src test cypress", "lint:types": "tsc --noEmit --jsx react && tsc --noEmit --jsx react -p cypress", "lint:style": "stylelint \"res/css/**/*.pcss\"", "test": "jest", @@ -184,10 +184,11 @@ "enzyme-to-json": "^3.6.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-jsx-a11y": "^6.5.1", - "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", @@ -203,10 +204,12 @@ "matrix-web-i18n": "^1.3.0", "node-fetch": "2", "postcss-scss": "^4.0.4", + "prettier": "2.8.0", "raw-loader": "^4.0.2", "react-test-renderer": "^17.0.2", "rimraf": "^3.0.2", "stylelint": "^14.9.1", + "stylelint-config-prettier": "^9.0.4", "stylelint-config-standard": "^29.0.0", "stylelint-scss": "^4.2.0", "typescript": "4.9.3", diff --git a/yarn.lock b/yarn.lock index 79bf9bdb40..e103b128b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4047,6 +4047,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" @@ -4105,10 +4110,10 @@ eslint-plugin-jsx-a11y@^6.5.1: minimatch "^3.1.2" semver "^6.3.0" -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" @@ -7044,6 +7049,11 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== +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-bytes@^5.6.0: version "5.6.0" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb" @@ -7996,6 +8006,11 @@ style-search@^0.1.0: resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902" integrity sha512-Dj1Okke1C3uKKwQcetra4jSuk0DqbzbYtXipzFlFMZtowbF1x7BKJwB9AayVMyFARvU8EDrZdcax4At/452cAg== +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"