From 48eeb11391f1a5b83eb288fbc62213dcf17e2b36 Mon Sep 17 00:00:00 2001 From: Alistair McKinlay Date: Wed, 17 Jul 2019 10:32:26 +0100 Subject: [PATCH 1/5] Set up prettier on js/vue --- .eslintrc.yml | 50 ++----------------------------------------------- .prettierignore | 2 -- .prettierrc.yml | 1 + package.json | 2 ++ yarn.lock | 12 ++++++++++++ 5 files changed, 17 insertions(+), 50 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 05068e87..d6b27290 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -11,48 +11,21 @@ env: node: true rules: - arrow-body-style: error - arrow-parens: [error, always] - arrow-spacing: error block-scoped-var: error - block-spacing: [error, always] - brace-style: [error, 1tbs] - comma-dangle: - - error - - always-multiline curly: [error, all] - dot-location: [error, property] dot-notation: error - eol-last: error eqeqeq: error handle-callback-err: error - indent: [error, tab] - key-spacing: - - error - - beforeColon: false - afterColon: true - keyword-spacing: - - error - - before: true - after: true linebreak-style: [error, unix] no-alert: error no-catch-shadow: error - no-confusing-arrow: - - error - - allowParens: true no-control-regex: off no-console: error no-duplicate-imports: error no-else-return: error no-implicit-globals: error - no-multi-spaces: error - no-multiple-empty-lines: - - error - - max: 1 no-shadow: error no-template-curly-in-string: error - no-trailing-spaces: error no-unsafe-negation: error no-useless-computed-key: error no-useless-constructor: error @@ -61,12 +34,10 @@ rules: - error - functions: false no-var: error - object-curly-spacing: [error, never] object-shorthand: - error - methods - avoidExplicitReturnArrows: true - padded-blocks: [error, never] padding-line-between-statements: - error - blankLine: always @@ -82,31 +53,12 @@ rules: prefer-const: error prefer-rest-params: error prefer-spread: error - quote-props: [error, consistent-as-needed] - quotes: [error, double, avoid-escape] - rest-spread-spacing: error - semi-spacing: error - semi-style: [error, last] - semi: [error, always] - space-before-blocks: error - space-before-function-paren: - - error - - anonymous: never - named: never - asyncArrow: always # Otherwise requires `async()` - space-in-parens: [error, never] - space-infix-ops: error spaced-comment: [error, always] strict: off - template-curly-spacing: error yoda: error - vue/html-indent: [error, tab] vue/require-default-prop: off vue/no-v-html: off vue/no-use-v-if-with-v-for: off - vue/html-closing-bracket-newline: error - vue/multiline-html-element-content-newline: off - vue/singleline-html-element-content-newline: off plugins: - vue @@ -114,3 +66,5 @@ plugins: extends: - eslint:recommended - plugin:vue/recommended + - prettier + - prettier/vue diff --git a/.prettierignore b/.prettierignore index 08d66ad2..c01534b0 100644 --- a/.prettierignore +++ b/.prettierignore @@ -23,5 +23,3 @@ yarn.lock .gitattributes *.css -*.js -*.vue diff --git a/.prettierrc.yml b/.prettierrc.yml index 659327e6..4bad5750 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -1,5 +1,6 @@ arrowParens: always bracketSpacing: false +printWidth: 100 trailingComma: "es5" overrides: - files: "*.webmanifest" diff --git a/package.json b/package.json index ddaa8435..7a74d70c 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "coverage": "run-s test:{client,server} && nyc --nycrc-path=test/.nycrc-report.json report", "dev": "run-p watch start", "format:prettier": "prettier --write \"**/*.*\"", + "lint:check-eslint": "eslint --print-config .eslintrc.yml | eslint-config-prettier-check", "lint:eslint": "eslint . --ext .js,.vue --report-unused-disable-directives --color", "lint:prettier": "prettier --list-different \"**/*.*\"", "lint:stylelint": "stylelint --color \"client/**/*.css\"", @@ -84,6 +85,7 @@ "css.escape": "1.5.1", "emoji-regex": "8.0.0", "eslint": "6.0.1", + "eslint-config-prettier": "4.0.0", "eslint-plugin-vue": "5.2.3", "fuzzy": "0.1.3", "graphql-request": "1.8.2", diff --git a/yarn.lock b/yarn.lock index bc3a9760..2277e344 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2973,6 +2973,13 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +eslint-config-prettier@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-4.0.0.tgz#16cedeea0a56e74de60dcbbe3be0ab2c645405b9" + integrity sha512-kWuiJxzV5NwOwZcpyozTzDT5KJhBw292bbYro9Is7BWnbNMg15Gmpluc1CTetiCatF8DRkNvgPAOaSyg+bYr3g== + dependencies: + get-stdin "^6.0.0" + eslint-plugin-vue@5.2.3: version "5.2.3" resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-5.2.3.tgz#3ee7597d823b5478804b2feba9863b1b74273961" @@ -3577,6 +3584,11 @@ get-func-name@^2.0.0: resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= +get-stdin@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" + integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== + get-stdin@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-7.0.0.tgz#8d5de98f15171a125c5e516643c7a6d0ea8a96f6" From 133e7bf7102c29490070e688cbaea021d163aa5f Mon Sep 17 00:00:00 2001 From: Alistair McKinlay Date: Wed, 17 Jul 2019 10:33:59 +0100 Subject: [PATCH 2/5] Format js/vue with prettier --- client/components/App.vue | 120 +- client/components/Channel.vue | 34 +- client/components/ChannelWrapper.vue | 17 +- client/components/Chat.vue | 79 +- client/components/ChatInput.vue | 32 +- client/components/ChatUserList.vue | 26 +- client/components/DateMarker.vue | 10 +- client/components/JoinChannel.vue | 13 +- client/components/LinkPreview.vue | 109 +- client/components/LinkPreviewToggle.vue | 2 +- client/components/Message.vue | 37 +- client/components/MessageCondensed.vue | 89 +- client/components/MessageList.vue | 20 +- client/components/MessageTypes/away.vue | 11 +- client/components/MessageTypes/back.vue | 6 +- client/components/MessageTypes/chghost.vue | 8 +- client/components/MessageTypes/ctcp.vue | 2 +- .../components/MessageTypes/ctcp_request.vue | 2 +- client/components/MessageTypes/invite.vue | 10 +- client/components/MessageTypes/kick.vue | 10 +- client/components/MessageTypes/motd.vue | 7 +- client/components/MessageTypes/part.vue | 11 +- client/components/MessageTypes/quit.vue | 11 +- client/components/MessageTypes/topic.vue | 16 +- client/components/MessageTypes/whois.vue | 26 +- client/components/NetworkList.vue | 5 +- client/components/NetworkLobby.vue | 30 +- client/components/ParsedMessage.vue | 4 +- client/components/Special/ListBans.vue | 5 +- client/components/Special/ListChannels.vue | 20 +- client/components/Special/ListIgnored.vue | 5 +- client/components/Special/ListInvites.vue | 5 +- client/components/Username.vue | 7 +- client/components/UsernameFiltered.vue | 2 +- client/js/autocompletion.js | 119 +- client/js/constants.js | 12 +- client/js/contextMenu.js | 37 +- client/js/contextMenuFactory.js | 4 +- client/js/keybinds.js | 58 +- client/js/libs/handlebars/colorClass.js | 2 +- .../ircmessageparser/anyIntersection.js | 10 +- .../handlebars/ircmessageparser/findLinks.js | 16 +- .../libs/handlebars/ircmessageparser/merge.js | 20 +- .../handlebars/ircmessageparser/parseStyle.js | 193 +- client/js/libs/handlebars/parse.js | 106 +- client/js/loading-error-handlers.js | 3 +- client/js/lounge.js | 9 +- client/js/options.js | 21 +- client/js/renderPreview.js | 59 +- client/js/slideout.js | 4 +- client/js/socket-events/auth.js | 9 +- client/js/socket-events/changelog.js | 8 +- client/js/socket-events/configuration.js | 30 +- client/js/socket-events/init.js | 5 +- client/js/socket-events/join.js | 3 +- client/js/socket-events/msg.js | 14 +- client/js/socket-events/network.js | 17 +- client/js/socket-events/open.js | 3 +- client/js/socket-events/part.js | 5 +- client/js/socket-events/setting.js | 6 +- client/js/socket-events/sync_sort.js | 24 +- client/js/upload.js | 22 +- client/js/utils.js | 5 +- client/js/webpush.js | 140 +- client/service-worker.js | 60 +- client/views/index.js | 19 +- index.js | 8 +- scripts/changelog.js | 251 ++- scripts/generate-config-doc.js | 21 +- scripts/generate-emoji.js | 28 +- src/client.js | 200 +- src/clientManager.js | 47 +- src/command-line/index.js | 17 +- src/command-line/install.js | 90 +- src/command-line/start.js | 11 +- src/command-line/uninstall.js | 22 +- src/command-line/upgrade.js | 18 +- src/command-line/users/add.js | 55 +- src/command-line/users/edit.js | 9 +- src/command-line/users/list.js | 9 +- src/command-line/users/reset.js | 33 +- src/command-line/utils.js | 59 +- src/helper.js | 91 +- src/identification.js | 38 +- src/log.js | 5 +- src/models/chan.js | 7 +- src/models/msg.js | 6 +- src/models/network.js | 62 +- src/plugins/auth/ldap.js | 8 +- src/plugins/auth/local.js | 16 +- src/plugins/changelog.js | 2 +- src/plugins/inputs/action.js | 49 +- src/plugins/inputs/away.js | 3 +- src/plugins/inputs/ban.js | 46 +- src/plugins/inputs/connect.js | 11 +- src/plugins/inputs/ctcp.js | 24 +- src/plugins/inputs/ignore.js | 207 ++- src/plugins/inputs/invite.js | 18 +- src/plugins/inputs/kick.js | 11 +- src/plugins/inputs/mode.js | 36 +- src/plugins/inputs/msg.js | 49 +- src/plugins/inputs/nick.js | 33 +- src/plugins/inputs/part.js | 21 +- src/plugins/inputs/rejoin.js | 11 +- src/plugins/inputs/topic.js | 11 +- src/plugins/irc-events/away.js | 58 +- src/plugins/irc-events/connection.js | 113 +- src/plugins/irc-events/ctcp.js | 57 +- src/plugins/irc-events/link.js | 210 ++- src/plugins/irc-events/list.js | 4 +- src/plugins/irc-events/message.js | 34 +- src/plugins/irc-events/unhandled.js | 14 +- src/plugins/messageStorage/sqlite.js | 129 +- src/plugins/messageStorage/text.js | 100 +- src/plugins/packages/index.js | 12 +- src/plugins/storage.js | 32 +- src/plugins/webpush.js | 33 +- src/server.js | 89 +- .../components/ParsedMessageTestWrapper.vue | 6 +- test/client/js/constantsTest.js | 15 +- test/client/js/libs/handlebars/equalTest.js | 3 +- .../ircmessageparser/cleanIrcMessage.js | 122 +- .../libs/handlebars/ircmessageparser/fill.js | 24 +- .../ircmessageparser/findChannels.js | 108 +- .../handlebars/ircmessageparser/findEmoji.js | 48 +- .../handlebars/ircmessageparser/findLinks.js | 351 ++-- .../libs/handlebars/ircmessageparser/merge.js | 209 ++- .../handlebars/ircmessageparser/parseStyle.js | 1623 +++++++++-------- test/client/js/libs/handlebars/parse.js | 674 ++++--- test/models/chan.js | 104 +- test/models/msg.js | 50 +- test/models/network.js | 148 +- test/plugins/auth/ldap.js | 8 +- test/plugins/link.js | 125 +- test/plugins/packages/indexTest.js | 13 +- test/plugins/sqlite.js | 103 +- test/plugins/storage.js | 28 +- test/server.js | 8 +- test/src/command-line/utilsTest.js | 52 +- test/src/helperTest.js | 8 +- test/tests/build.js | 3 +- test/tests/customhighlights.js | 4 +- test/tests/mergeConfig.js | 265 ++- test/tests/passwords.js | 22 +- test/tests/textLogFolder.js | 40 +- test/util.js | 33 +- webpack.config-test.js | 4 +- webpack.config.js | 67 +- 148 files changed, 4775 insertions(+), 3855 deletions(-) diff --git a/client/components/App.vue b/client/components/App.vue index 74e27533..76820e4d 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -1,8 +1,5 @@ diff --git a/client/components/Channel.vue b/client/components/Channel.vue index 100ad0e0..e48df51a 100644 --- a/client/components/Channel.vue +++ b/client/components/Channel.vue @@ -1,15 +1,9 @@