mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
Fixed linting issues and comments.
This commit is contained in:
parent
136e83afc2
commit
43a3b57dd9
@ -156,7 +156,7 @@ describe('PostSlug', () => {
|
||||
{ id: 'Bw' },
|
||||
{ id: 'a' },
|
||||
]
|
||||
|
||||
|
||||
wrapper = await Wrapper()
|
||||
})
|
||||
|
||||
@ -167,16 +167,16 @@ describe('PostSlug', () => {
|
||||
|
||||
it('are alphabetically ordered', async () => {
|
||||
// Get all HcHastag components
|
||||
let wrappers = wrapper.findAll(HcHashtag).wrappers
|
||||
const wrappers = wrapper.findAll(HcHashtag).wrappers
|
||||
// Exctract ID properties (tag names) from component.
|
||||
let ids = []
|
||||
const ids = []
|
||||
wrappers.forEach((x) => {
|
||||
ids.push({
|
||||
id: x.props().id,
|
||||
})
|
||||
})
|
||||
// Compare extracted IDs with solution.
|
||||
let idsAlphabetically = [
|
||||
const idsAlphabetically = [
|
||||
{ id: '42' },
|
||||
{ id: 'a' },
|
||||
{ id: 'BQ' },
|
||||
|
||||
@ -182,13 +182,16 @@ export default {
|
||||
sortedTags() {
|
||||
// Make sure the property is valid.
|
||||
if (!this.post.tags || !this.post.tags.length) return false
|
||||
// Sorting actually happens in place but that should not be a problem.
|
||||
return this.post.tags.sort(function (a, b) {
|
||||
// Converting to lowercase to make sort case insensitive.
|
||||
const tagA = a.id.toLowerCase()
|
||||
const tagB = b.id.toLowerCase()
|
||||
return tagA < tagB ? -1 : tagA > tagB ? 1 : 0
|
||||
})
|
||||
/* Using .slice(0) to make a shallow copy. Otherwise a vue/no-side-effects-in-computed-properties error
|
||||
would be thrown because sort() sorts in place. A shallow copy is fine because only first level objects are
|
||||
affected by the sort, the original this.post.tags object remains unchanged.
|
||||
*/
|
||||
return this.post.tags.slice(0).sort(function (a, b) {
|
||||
// Converting to lowercase to make sort case insensitive.
|
||||
const tagA = a.id.toLowerCase()
|
||||
const tagB = b.id.toLowerCase()
|
||||
return tagA < tagB ? -1 : tagA > tagB ? 1 : 0
|
||||
})
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
@ -65,13 +65,16 @@ export default {
|
||||
sortedTags() {
|
||||
// Make sure the property is valid.
|
||||
if (!this.post.tags || !this.post.tags.length) return false
|
||||
// Sorting actually happens in place but that should not be a problem.
|
||||
return this.post.tags.sort(function (a, b) {
|
||||
// Converting to lowercase to make sort case insensitive.
|
||||
const tagA = a.id.toLowerCase()
|
||||
const tagB = b.id.toLowerCase()
|
||||
return tagA < tagB ? -1 : tagA > tagB ? 1 : 0
|
||||
})
|
||||
/* Using .slice(0) to make a shallow copy. Otherwise a vue/no-side-effects-in-computed-properties error
|
||||
would be thrown because sort() sorts in place. A shallow copy is fine because only first level objects are
|
||||
affected by the sort, the original this.post.tags object remains unchanged.
|
||||
*/
|
||||
return this.post.tags.slice(0).sort(function (a, b) {
|
||||
// Converting to lowercase to make sort case insensitive.
|
||||
const tagA = a.id.toLowerCase()
|
||||
const tagB = b.id.toLowerCase()
|
||||
return tagA < tagB ? -1 : tagA > tagB ? 1 : 0
|
||||
})
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user