From 8875cba0f35316d49b51f503ac61ffca63e9654c Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 11 Jan 2020 19:11:23 +0100 Subject: [PATCH] Manually fix more linter errors Signed-off-by: Knut Ahlers --- .eslintrc.js | 22 +++++------- Makefile | 7 ++++ src/main.js | 8 ++--- src/store/index.js | 87 ++++++++++++++++++++++++---------------------- 4 files changed, 65 insertions(+), 59 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index cc28c19..a3e227d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,14 +1,14 @@ // https://eslint.org/docs/user-guide/configuring module.exports = { - 'root': true, - 'parserOptions': { + root: true, + parserOptions: { parser: 'babel-eslint', }, - 'env': { + env: { browser: true, }, - 'extends': [ + extends: [ /* * https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention * consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. @@ -18,12 +18,13 @@ module.exports = { 'eslint:recommended', ], // required to lint *.vue files - 'plugins': ['vue'], - 'globals': { + plugins: ['vue'], + globals: { + Go: true, process: true, }, // add your custom rules here - 'rules': { + rules: { 'array-bracket-newline': ['error', { multiline: true }], 'array-bracket-spacing': ['error'], 'arrow-body-style': ['error', 'as-needed'], @@ -38,7 +39,7 @@ module.exports = { 'dot-location': ['error', 'property'], 'dot-notation': ['error'], 'eol-last': ['error', 'always'], - 'eqeqeq': ['error', 'always', { 'null': 'ignore' }], + 'eqeqeq': ['error', 'always', { null: 'ignore' }], 'func-call-spacing': ['error', 'never'], 'function-paren-newline': ['error', 'multiline'], 'generator-star-spacing': ['off'], // allow async-await @@ -73,11 +74,6 @@ module.exports = { 'quote-props': ['error', 'consistent-as-needed', { keywords: false }], 'quotes': ['error', 'single', { allowTemplateLiterals: true }], 'semi': ['error', 'never'], - 'sort-imports': ['error', { - ignoreCase: true, - ignoreDeclarationSort: false, - ignoreMemberSort: false, - }], 'sort-keys': ['error', 'asc', { caseSensitive: true, natural: false }], 'space-before-blocks': ['error', 'always'], 'spaced-comment': ['warn', 'always'], diff --git a/Makefile b/Makefile index 321ebab..b1b32f8 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,13 @@ lint-fix: node:10-alpine \ sh -exc "apk add python && npm ci && npx eslint --fix src" +lint-watch: + docker run --rm -i \ + -v "$(CURDIR):/src" \ + -w "/src" \ + node:10-alpine \ + sh -exc "apk add python && npm ci && while true; do npx eslint src || true; sleep 5; done" + .PHONY: bindata.go bindata.go: build_vue go-bindata -o bindata.go dist/... diff --git a/src/main.js b/src/main.js index b88e955..c5ade18 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,6 @@ import Vue from 'vue' import BootstrapVue from 'bootstrap-vue' -import Vuex from 'vuex' +// import Vuex from 'vuex' import VueClipboard from 'vue-clipboard2' import VueShortkey from 'vue-shortkey' @@ -39,10 +39,10 @@ const go = new Go() WebAssembly.instantiateStreaming(fetch('cryptocore.wasm'), go.importObject) .then(async obj => await go.run(obj.instance)) -const instance = new Vue({ - store, - render: h => h(App), +window.instance = new Vue({ mounted: () => store.dispatch('reload_users'), + render: h => h(App), + store, }).$mount('#app') // Wait for the cryptocore to be loaded (which makes encryption available) diff --git a/src/store/index.js b/src/store/index.js index 1041680..b48efed 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -7,40 +7,6 @@ import uuidv4 from 'uuid/v4' Vue.use(Vuex) export default new Vuex.Store({ - state: { - /* - *account_info: { - * data: [{ - * "title": "Test entry", - * "username": "testuser", - * "password": "quitesecretpass", - * "url": "https://example.com", - * "comment": "", - * "tags": "", - * "id": "f106cdd5-7b52-4c51-a386-6f2016ee70c8", - * }, - * { - * "title": "Test entry 2", - * "username": "testuser", - * "password": "quitesecretpass", - * "url": "https://example.com", - * "comment": "", - * "tags": "foobar", - * "id": "e956814f-c7dd-4730-b383-624f8bbc6923", - * }, - * ], - * data_raw: "", - * loaded: "Luzifer", - * master_password: "foobar", - * selected: null, - *}, - *accounts: ["Luzifer"], - */ - account_info: {}, - accounts: [], - cryptocore_available: false, - filter: null, - }, actions: { add_entry(context, entry) { @@ -51,7 +17,7 @@ export default new Vuex.Store({ decrypt_data(context) { // Do not try to decrypt empty data - if (context.state.account_info.data_raw == '') { + if (context.state.account_info.data_raw === '') { return } @@ -113,7 +79,7 @@ export default new Vuex.Store({ register(context, data) { axios.post('/register', data) - .then(response => { + .then(() => { context.dispatch('reload_users', data.username) }) .catch(error => console.log(error)) @@ -125,7 +91,7 @@ export default new Vuex.Store({ const users = [] for (const user in response.data) { const login_state = response.data[user] - if (login_state == 'logged-in') { + if (login_state === 'logged-in') { users.push(user) } } @@ -151,9 +117,9 @@ export default new Vuex.Store({ }).then(checksum => { axios.put(`/user/${context.state.account_info.loaded}/data`, { checksum, - old_checksum: context.state.account_info.checksum, data: context.state.account_info.data_raw, - }).then(response => { + old_checksum: context.state.account_info.checksum, + }).then(() => { context.commit('update_checksum', checksum) }) .catch(error => console.log(error)) @@ -164,7 +130,7 @@ export default new Vuex.Store({ sign_in(context, auth) { console.log(auth) axios.post('/login', auth) - .then(response => { + .then(() => { context.dispatch('reload_users', auth.username) }) .catch(error => { @@ -178,12 +144,13 @@ export default new Vuex.Store({ sign_out(context) { axios.post(`/user/${context.state.account_info.loaded}/logout`) - .then(response => { + .then(() => { context.dispatch('reload_users') }) .catch(error => console.log(error)) }, }, + getters: { filtered_entries: state => { if (state.filter === '' || state.filter === null) { @@ -214,13 +181,14 @@ export default new Vuex.Store({ return null } for (const item of state.account_info.data) { - if (item.id == state.account_info.selected) { + if (item.id === state.account_info.selected) { return item } } return null }, }, + mutations: { account_loaded(state, account_info) { state.account_info = account_info @@ -279,4 +247,39 @@ export default new Vuex.Store({ state.filter = value }, }, + + state: { + /* + *account_info: { + * data: [{ + * "title": "Test entry", + * "username": "testuser", + * "password": "quitesecretpass", + * "url": "https://example.com", + * "comment": "", + * "tags": "", + * "id": "f106cdd5-7b52-4c51-a386-6f2016ee70c8", + * }, + * { + * "title": "Test entry 2", + * "username": "testuser", + * "password": "quitesecretpass", + * "url": "https://example.com", + * "comment": "", + * "tags": "foobar", + * "id": "e956814f-c7dd-4730-b383-624f8bbc6923", + * }, + * ], + * data_raw: "", + * loaded: "Luzifer", + * master_password: "foobar", + * selected: null, + *}, + *accounts: ["Luzifer"], + */ + account_info: {}, + accounts: [], + cryptocore_available: false, + filter: null, + }, })