Skip to content

Commit be2d497

Browse files
Dannebicquemysiar
authored andcommitted
Improved consistency and compatibility with eslint (#67)
* Update foo.js Improve consistency and compatibility with linter * Update create.js * Update Create.vue * Update Form.vue * Update List.vue * Update Show.vue * Update Update.vue * Update delete.js * Update index.js * Update list.js * Update mutation-types.js * Update show.js * Update update.js * Update fetch.js * Update fetch.js
1 parent da1d0b4 commit be2d497

File tree

14 files changed

+303
-299
lines changed

14 files changed

+303
-299
lines changed

templates/vue/components/foo/Create.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
</template>
1212

1313
<script>
14-
import {{{titleUcFirst}}}Form from './Form.vue';
15-
import { createNamespacedHelpers } from 'vuex';
14+
import {{{titleUcFirst}}}Form from './Form.vue'
15+
import { createNamespacedHelpers } from 'vuex'
1616
17-
const { mapActions, mapGetters } = createNamespacedHelpers('{{{lc}}}/create');
17+
const { mapGetters } = createNamespacedHelpers('{{{lc}}}/create')
1818
1919
export default {
2020
components: {
2121
{{{titleUcFirst}}}Form
2222
},
23-
data: function() {
23+
data () {
2424
return {
2525
item: {}
2626
}
@@ -33,13 +33,13 @@
3333
]),
3434
methods: {
3535
create: function(item) {
36-
this.$store.dispatch('{{{lc}}}/create/create', item);
36+
this.$store.dispatch('{{{lc}}}/create/create', item)
3737
}
3838
},
3939
watch: {
4040
created: function (created) {
4141
if (created) {
42-
this.$router.push({ name: '{{{titleUcFirst}}}Update', params: { id: created['@id']} });
42+
this.$router.push({ name: '{{{titleUcFirst}}}Update', params: { id: created['@id']} })
4343
}
4444
}
4545
}

templates/vue/components/foo/Form.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
props: {
1818
handleSubmit: {
1919
type: Function,
20-
required: true,
20+
required: true
2121
},
2222
values: {
2323
type: Object,
@@ -32,7 +32,7 @@
3232
},
3333
computed: {
3434
item: function () {
35-
return this.initialValues ? this.initialValues : this.values;
35+
return this.initialValues ? this.initialValues : this.values
3636
}
3737
}
3838
}

templates/vue/components/foo/List.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</template>
7575

7676
<script>
77-
import { mapActions, mapGetters } from 'vuex';
77+
import { mapActions, mapGetters } from 'vuex'
7878
7979
export default {
8080
computed: mapGetters({

templates/vue/components/foo/Show.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,27 @@
3131
</template>
3232

3333
<script>
34-
import { mapGetters } from 'vuex';
34+
import { mapGetters } from 'vuex'
3535
3636
export default {
3737
computed: mapGetters({
3838
deleteError: '{{{lc}}}/del/error',
3939
error: '{{{lc}}}/show/error',
4040
loading: '{{{lc}}}/show/loading',
41-
item: '{{{lc}}}/show/item',
41+
item: '{{{lc}}}/show/item'
4242
}),
4343
methods: {
4444
deleteItem (item) {
45-
if (window.confirm('Are you sure you want to delete this item?'))
46-
this.$store.dispatch('{{{lc}}}/del/delete', item).then(response => this.$router.push({ name: '{{{titleUcFirst}}}List' }));
45+
if (window.confirm('Are you sure you want to delete this item?')) {
46+
this.$store.dispatch('{{{lc}}}/del/delete', item).then(response => this.$router.push({ name: '{{{titleUcFirst}}}List' }))
47+
}
4748
}
4849
},
4950
created () {
50-
this.$store.dispatch('{{{lc}}}/show/retrieve', decodeURIComponent(this.$route.params.id));
51+
this.$store.dispatch('{{{lc}}}/show/retrieve', decodeURIComponent(this.$route.params.id))
5152
},
52-
beforeDestroy() {
53-
this.$store.dispatch('{{{lc}}}/show/reset');
53+
beforeDestroy () {
54+
this.$store.dispatch('{{{lc}}}/show/reset')
5455
}
5556
}
5657
</script>

templates/vue/components/foo/Update.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
</template>
1717

1818
<script>
19-
import {{{titleUcFirst}}}Form from './Form.vue';
20-
import { mapGetters } from 'vuex';
19+
import {{{titleUcFirst}}}Form from './Form.vue'
20+
import { mapGetters } from 'vuex'
2121
2222
export default {
2323
created () {
24-
this.$store.dispatch('{{{lc}}}/update/retrieve', decodeURIComponent(this.$route.params.id));
24+
this.$store.dispatch('{{{lc}}}/update/retrieve', decodeURIComponent(this.$route.params.id))
2525
},
2626
components: {
2727
{{{titleUcFirst}}}Form
@@ -48,28 +48,28 @@
4848
},
4949
methods: {
5050
update (values) {
51-
this.$store.dispatch('{{{lc}}}/update/update', {item: this.retrieved, values: values });
51+
this.$store.dispatch('{{{lc}}}/update/update', {item: this.retrieved, values: values })
5252
},
5353
del () {
54-
if (window.confirm('Are you sure you want to delete this item?'))
55-
this.$store.dispatch('{{{lc}}}/del/delete', this.retrieved);
54+
if (window.confirm('Are you sure you want to delete this item?')) {
55+
this.$store.dispatch('{{{lc}}}/del/delete', this.retrieved)
56+
}
5657
},
5758
reset () {
58-
this.$store.dispatch('{{{lc}}}/update/reset');
59-
this.$store.dispatch('{{{lc}}}/del/reset');
60-
this.$store.dispatch('{{{lc}}}/create/reset');
61-
59+
this.$store.dispatch('{{{lc}}}/update/reset')
60+
this.$store.dispatch('{{{lc}}}/del/reset')
61+
this.$store.dispatch('{{{lc}}}/create/reset')
6262
}
6363
},
6464
watch: {
6565
deleted: function (deleted) {
6666
if (deleted) {
67-
this.$router.push({ name: '{{{titleUcFirst}}}List' });
67+
this.$router.push({ name: '{{{titleUcFirst}}}List' })
6868
}
6969
}
7070
},
71-
beforeDestroy() {
72-
this.reset();
71+
beforeDestroy () {
72+
this.reset()
7373
}
7474
}
7575
</script>

templates/vue/routes/foo.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import {{{titleUcFirst}}}Show from '../components/{{{lc}}}/Show.vue';
66
export default [
77
{ name: '{{{titleUcFirst}}}List', path: '/{{{name}}}/', component: {{{titleUcFirst}}}List },
88
{ name: '{{{titleUcFirst}}}Create', path: '/{{{name}}}/create', component: {{{titleUcFirst}}}Create },
9-
{ name: '{{{titleUcFirst}}}Update', path: "/{{{name}}}/edit/:id", component: {{{titleUcFirst}}}Update },
10-
{ name: '{{{titleUcFirst}}}Show', path: "/{{{name}}}/show/:id", component: {{{titleUcFirst}}}Show }
11-
];
9+
{ name: '{{{titleUcFirst}}}Update', path: '/{{{name}}}/edit/:id', component: {{{titleUcFirst}}}Update },
10+
{ name: '{{{titleUcFirst}}}Show', path: '/{{{name}}}/show/:id', component: {{{titleUcFirst}}}Show }
11+
]
Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,101 @@
1-
import SubmissionError from '../../../error/SubmissionError';
2-
import fetch from '../../../utils/fetch';
1+
import SubmissionError from '../../../error/SubmissionError'
2+
import fetch from '../../../utils/fetch'
33
import {
44
{{{ uc }}}_CREATE_ERROR,
55
{{{ uc }}}_CREATE_LOADING,
66
{{{ uc }}}_CREATE_SUCCESS,
77
{{{ uc }}}_CREATE_VIOLATIONS,
88
{{{ uc }}}_CREATE_RESET
9-
} from './mutation-types';
9+
} from './mutation-types'
1010

1111
const state = {
1212
loading: false,
1313
error: '',
1414
created: null,
1515
violations: null
16-
};
16+
}
1717

18-
function error(error) {
19-
return {type: {{{ uc }}}_CREATE_ERROR, error};
18+
function error (error) {
19+
return {type: {{{ uc }}}_CREATE_ERROR, error}
2020
}
2121

22-
function loading(loading) {
23-
return {type: {{{ uc }}}_CREATE_LOADING, loading};
22+
function loading (loading) {
23+
return {type: {{{ uc }}}_CREATE_LOADING, loading}
2424
}
2525

26-
function success(created) {
26+
function success (created) {
2727
return {type: {{{ uc }}}_CREATE_SUCCESS, created};
2828
}
2929

30-
function violations(violations) {
31-
return {type: {{{ uc }}}_CREATE_VIOLATIONS, violations};
30+
function violations (violations) {
31+
return {type: {{{ uc }}}_CREATE_VIOLATIONS, violations}
3232
}
3333

34-
function reset() {
35-
return {type: {{{ uc }}}_CREATE_RESET};
34+
function reset () {
35+
return {type: {{{ uc }}}_CREATE_RESET}
3636
}
3737

3838
const getters = {
3939
created: state => state.created,
4040
error: state => state.error,
4141
loading: state => state.loading,
42-
violations: state => state.violations,
43-
};
42+
violations: state => state.violations
43+
}
4444

4545
const actions = {
46-
create({ commit }, values) {
47-
commit(loading(true));
46+
create ({ commit }, values) {
47+
commit(loading(true))
4848

4949
return fetch('/{{{ name }}}', {method: 'POST', body: JSON.stringify(values)})
5050
.then(response => {
51-
commit(loading(false));
52-
53-
return response.json();
51+
commit(loading(false))
52+
return response.json()
5453
})
5554
.then(data => {
56-
commit(success(data));
55+
commit(success(data))
5756
})
5857
.catch(e => {
59-
commit(loading(false));
58+
commit(loading(false))
6059

6160
if (e instanceof SubmissionError) {
62-
commit(violations(e.errors));
63-
commit(error(e.errors._error));
64-
return;
61+
commit(violations(e.errors))
62+
commit(error(e.errors._error))
63+
return
6564
}
6665

67-
commit(error(e.message));
66+
commit(error(e.message))
6867
});
6968
},
70-
reset({ commit }) {
71-
commit(reset());
69+
reset ({ commit }) {
70+
commit(reset())
7271
}
7372
};
7473

7574
const mutations = {
76-
[{{{ uc }}}_CREATE_ERROR] (state, payload) {
77-
state.error = payload.error;
78-
},
79-
[{{{ uc }}}_CREATE_LOADING] (state, payload) {
80-
state.loading = payload.loading;
81-
},
82-
[{{{ uc }}}_CREATE_SUCCESS] (state, payload) {
83-
state.created = payload.created;
84-
},
85-
[{{{ uc }}}_CREATE_VIOLATIONS] (state, payload) {
86-
state.violations = payload.violations;
87-
},
88-
[{{{ uc }}}_CREATE_RESET] (state) {
89-
state.loading = false;
90-
state.error = '';
91-
state.created = null;
92-
state.violations = null;
93-
}
94-
};
75+
[{{{ uc }}}_CREATE_ERROR] (state, payload) {
76+
state.error = payload.error
77+
},
78+
[{{{ uc }}}_CREATE_LOADING] (state, payload) {
79+
state.loading = payload.loading
80+
},
81+
[{{{ uc }}}_CREATE_SUCCESS] (state, payload) {
82+
state.created = payload.created
83+
},
84+
[{{{ uc }}}_CREATE_VIOLATIONS] (state, payload) {
85+
state.violations = payload.violations
86+
},
87+
[{{{ uc }}}_CREATE_RESET] (state) {
88+
state.loading = false
89+
state.error = ''
90+
state.created = null
91+
state.violations = null
92+
}
93+
}
9594

9695
export default {
9796
namespaced: true,
9897
state,
9998
getters,
10099
actions,
101100
mutations
102-
};
101+
}

0 commit comments

Comments
 (0)