From b482ddd3c927e4a4c2f039b149ada7d84c87fdb8 Mon Sep 17 00:00:00 2001 From: Brendan Miller Date: Fri, 4 Oct 2024 15:43:32 -0700 Subject: [PATCH 1/6] * Add husky lint-staged linting pre-commit hook. * Add audit:critical command for later use in hooks (not yet enabled). * Run initial linting to standardize code formatting. * Correct some small issues in README. * Set up polls within channels with placeholder page. --- .editorconfig | 11 + .eslintignore | 2 + .eslintrc.js | 1 + .husky/pre-commit | 3 + .lintstagedrc.js | 4 + .prettierrc.json | 8 +- README.md | 4 +- package.json | 16 +- src/components/Banner/BannerSection.vue | 129 +- src/components/Banner/GuestBanner.vue | 13 +- src/components/Banner/LoggedInBanner.vue | 52 +- src/components/Channels/ChannelList.vue | 12 +- src/components/Channels/ChannelListItem.vue | 58 +- src/components/Channels/Channels.vue | 84 +- src/components/Channels/CreateChannel.vue | 115 +- src/components/Channels/DeleteChannel.vue | 40 +- src/components/Channels/EditChannel.vue | 103 +- src/components/CreateAccountForm.vue | 56 +- src/components/LoginForm.vue | 50 +- src/components/Messages/MessageViewItem.vue | 185 +- src/components/Messages/MessagesView.vue | 29 +- src/components/Messages/PromptDirtyDraft.vue | 34 +- src/components/Messages/TagList.vue | 40 +- src/components/Messages/TagListItem.vue | 21 +- src/components/SearchBox.vue | 6 +- src/components/Shared/FooterSection.vue | 25 +- src/components/Shared/HeaderSection.vue | 31 +- src/components/Shared/Modal.vue | 18 +- src/components/Threads/CreateThread.vue | 58 +- src/components/Threads/DeleteThread.vue | 68 +- src/components/Threads/EditThread.vue | 84 +- src/components/Threads/ThreadList.vue | 15 +- src/components/Threads/ThreadListItem.vue | 63 +- src/composables/global/useStore.js | 361 +- src/layout/HomePageLayout.vue | 4 +- src/main.js | 34 +- src/plugins/axios.js | 55 +- src/plugins/navigationGuard.js | 50 +- src/routes/index.js | 102 +- src/service/index.js | 129 +- src/service/socket.service.js | 74 +- src/utils/index.js | 6 +- src/views/CreateAccountPage.vue | 18 +- src/views/ForgotPassword.vue | 73 +- src/views/LandingPage.vue | 29 +- src/views/LoginPage.vue | 32 +- src/views/MessagesPage.vue | 415 +- src/views/NotFound.vue | 14 +- src/views/PollPage.vue | 11 + src/views/ResetPassword.vue | 49 +- src/views/ThreadsPage.vue | 237 +- yarn.lock | 6527 +++++++++--------- 52 files changed, 4599 insertions(+), 5059 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .husky/pre-commit create mode 100644 .lintstagedrc.js create mode 100644 src/views/PollPage.vue diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8951c39 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +tab_width = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..b947077 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +node_modules/ +dist/ diff --git a/.eslintrc.js b/.eslintrc.js index bbc1a00..091c269 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,6 +7,7 @@ module.exports = { "vue/setup-compiler-macros": true, }, extends: [ + "standard", "eslint:recommended", "plugin:vue/vue3-recommended", "plugin:prettier/recommended", diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..ea641f5 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,3 @@ +yarn lint-staged + +# TODO: enable after this task is complete! yarn audit:critical diff --git a/.lintstagedrc.js b/.lintstagedrc.js new file mode 100644 index 0000000..b18258a --- /dev/null +++ b/.lintstagedrc.js @@ -0,0 +1,4 @@ +module.exports = { + '*.js': 'eslint --fix', + '*.vue': 'eslint --fix' +} diff --git a/.prettierrc.json b/.prettierrc.json index 9e26dfe..107b500 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1 +1,7 @@ -{} \ No newline at end of file +{ + "singleQuote": true, + "trailingComma": "none", + "tabWidth": 2, + "semi": false, + "printWidth": 125 +} diff --git a/README.md b/README.md index 072f04b..95ff22f 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ## Description -This is the Frontend vue app which depends on the [berkmancenter/threads_server](https://github.com/berkmancenter/threads_client) repo to run. +This is the Frontend vue app which depends on the [berkmancenter/nymspace_server](https://github.com/berkmancenter/nymspace_client) repo to run. ## Installation -- Install and start [berkmancenter/threads_server](https://github.com/berkmancenter/threads_server). +- Install and start [berkmancenter/nymspace_server](https://github.com/berkmancenter/nymspace_server). - Come back to this repo and `yarn install` to install packages. - Connect backend by copying `.env.example` to `.env.local`. Make sure the ports are correctly configured in threads_server repo. - Run `yarn dev --port 3001` and browse the app at https://localhost:3001. diff --git a/package.json b/package.json index ee0e8bb..a5581a2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,11 @@ "scripts": { "dev": "vite", "build": "vite build", - "serve": "vite preview" + "serve": "vite preview", + "lint": "eslint --ext .js,.vue src/", + "lint:fix": "eslint --ext .js,.vue --fix src/", + "audit:critical": "npm run audit-ci --critical", + "prepare": "husky install" }, "dependencies": { "@heroicons/vue": "^1.0.6", @@ -18,12 +22,20 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^1.9.3", + "audit-ci": "^7.1.0", "autoprefixer": "^10.4.0", "eslint": "^8.3.0", "eslint-config-prettier": "^8.3.0", + "eslint-config-standard": "^17.1.0", + "eslint-plugin-import": "^2.31.0", + "eslint-plugin-n": "^17.10.3", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-promise": "^7.1.0", "eslint-plugin-vue": "^8.1.1", + "husky": "^9.1.6", + "lint-staged": "^15.2.10", "postcss": "^8.4.1", - "prettier": "^2.5.0", + "prettier": "^3.3.3", "tailwindcss": "^2.2.19", "vite": "^2.6.4" }, diff --git a/src/components/Banner/BannerSection.vue b/src/components/Banner/BannerSection.vue index 500285c..75ce961 100644 --- a/src/components/Banner/BannerSection.vue +++ b/src/components/Banner/BannerSection.vue @@ -1,17 +1,14 @@