1
0
Fork 0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-11-08 22:20:05 +00:00

Manually fix more linter errors

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-01-11 19:11:23 +01:00
parent e659999b3d
commit 8875cba0f3
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
4 changed files with 65 additions and 59 deletions

View file

@ -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'],

View file

@ -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/...

View file

@ -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)

View file

@ -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,
},
})