Skip to content

Commit

Permalink
eslint: +custom fp/no-mutating-methods to allow Vue router
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Jan 1, 2021
1 parent 4d43553 commit 9f8b42b
Show file tree
Hide file tree
Showing 18 changed files with 10 additions and 28 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ module.exports = {
'vue/attribute-hyphenation': 0,
'vue/require-prop-types': 0,
'vue/require-default-prop': 0,
'vue/multiline-html-element-content-newline': 0
'vue/multiline-html-element-content-newline': 0,
// use fork to allow MemberExpressions
// https://github.com/jfmengels/eslint-plugin-fp/pull/54
"fp/no-mutating-methods": [2, {
"allowedObjects": ["$router"]
}]

}
}
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"eslint": "^7.15.0",
"eslint-config-raine": "^0.1.2",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-fp": "^2.3.0",
"eslint-plugin-fp": "git+https://github.com/raineorshine/eslint-plugin-fp.git#allowedObjects",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest-dom": "^3.6.4",
"eslint-plugin-jsdoc": "^30.7.8",
Expand Down
1 change: 0 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default ({
if (!prev && next && this.$store.state.noAccessPath.length) {
const nap = this.$store.state.noAccessPath + ''
this.$store.commit('setNAP', '')
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push(nap)
}
}
Expand Down
1 change: 0 additions & 1 deletion src/components/BookmarkButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default {
methods: {
toggleBookmark() {
if (!this.$iam('authorized')) {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'LogIn' })
}
else {
Expand Down
1 change: 0 additions & 1 deletion src/components/BooksFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default {
methods: {
toggleFilter(fid) {
this.$store.commit('books/toggleFilter', fid)
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'Home' })
},
resetFilters() {
Expand Down
2 changes: 0 additions & 2 deletions src/components/MainMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export default {
methods: {
logout() {
firebase.auth().signOut()
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'LogIn' })
}
},
Expand Down
1 change: 0 additions & 1 deletion src/components/MobileFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default {
},
toggleBookmarks() {
if (!this.$iam('authorized')) {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'LogIn' })
return
}
Expand Down
1 change: 0 additions & 1 deletion src/components/RightBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default {
},
toggleBookmarks() {
if (!this.$iam('authorized')) {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'LogIn' })
return
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/AuthorDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export default {
// author not found! drop to 404
// timeout to make router finish any his current work, if doing any
setTimeout(() => {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push('/404')
}, 0)
}
Expand Down
3 changes: 0 additions & 3 deletions src/pages/BookManagerForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,9 @@ export default {
})
},
save() {
/**/
this.$store.dispatch('saveBook', { book: this.book, roles: this.authorsRoles }).then(() => {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'BooksManager' })
})
/**/
},
reloadCover() {
this.searching = true
Expand Down
1 change: 0 additions & 1 deletion src/pages/BookSubmissionForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export default {
this.$store.commit('ui/setBusy', true)
await this.$store.dispatch('bookSubmissions/submit', this.submissions)
this.$store.commit('ui/setBusy', false)
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'SubmissionThankYou', params: { type: 'book' } })
},
async saveDraft() {
Expand Down
1 change: 0 additions & 1 deletion src/pages/BundleManagerForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default {
methods: {
save() {
this.$store.dispatch('saveBundle', this.bundle).then(() => {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'BundlesManager' })
})
},
Expand Down
2 changes: 0 additions & 2 deletions src/pages/BundleSubmissionForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default {
}
this.$store.dispatch('saveBundleSubmissionsDraft', data)
.then(() => {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'Dashboard' })
})
},
Expand All @@ -57,7 +56,6 @@ export default {
}
this.$store.dispatch('submitBundleSubmission', data)
.then(() => {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'Dashboard' })
})
},
Expand Down
5 changes: 0 additions & 5 deletions src/pages/LogIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ export default {
'$store.state.user.user'(next, prev) {
if (!prev && !!next) {
if (this.$can('viewDashboard')) {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'Dashboard' })
}
else {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'Home' })
}
}
Expand Down Expand Up @@ -163,7 +161,6 @@ export default {
password: this.password
})
.then(() => {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'Dashboard' })
})
)
Expand All @@ -181,7 +178,6 @@ export default {
...this.signupData,
})
.then(() => {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'Dashboard' })
})
)
Expand Down Expand Up @@ -235,7 +231,6 @@ export default {
this.active = active
this.error = null
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({
name: active === 'signup' ? 'Signup'
: active === 'login' ? 'LogIn'
Expand Down
1 change: 0 additions & 1 deletion src/pages/PasswordReset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default {
watch: {
'$store.state.user.user'(next, prev) {
if (!prev && !!next) {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'Dashboard' })
}
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/PeopleSubmissionForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export default {
this.$store.commit('ui/setBusy', true)
await this.$store.dispatch('bookSubmissions/submit', this.submissions)
this.$store.commit('ui/setBusy', false)
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'SubmissionThankYou', params: { type: 'people' } })
},
async saveDraft() {
Expand Down
1 change: 0 additions & 1 deletion src/pages/PersonManagerForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export default {
},
save() {
this.$store.dispatch('savePerson', this.person).then(() => {
// eslint-disable-next-line fp/no-mutating-methods
this.$router.push({ name: 'PeopleManager' })
})
}
Expand Down

0 comments on commit 9f8b42b

Please sign in to comment.