Skip to content

Commit 2d6044d

Browse files
authored
eslint: require trailing comma on multiline objects and arrays (#1110)
This is beneficial for the following reasons: * improves clarity of diffs when an item is added or removed from an object or array * reduces the chances of having merge conflicts, since only the lines you are modifying are touched * simplifies adding and removing items to objects and arrays, since only the lines you are modifying must be touched Bug: T420768
1 parent 0bf06bd commit 2d6044d

73 files changed

Lines changed: 361 additions & 362 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
parser: '@babel/eslint-parser'
1212
},
1313
rules: {
14+
'comma-dangle': ['error', 'always-multiline'],
1415
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
1516
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
1617
'vue/multi-word-component-names': 'warn',

src/App.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ export default {
2424
components: {
2525
Navbar,
2626
Foot,
27-
Interval
27+
Interval,
2828
},
2929
computed: {
3030
customLayout: function () {
3131
return this.$route.meta.customLayout
32-
}
32+
},
3333
},
3434
methods: {
3535
checkVerified () {
3636
this.$api
3737
.checkVerified()
3838
.then(verified => verified && this.$store.dispatch('markAsVerified'))
39-
}
40-
}
39+
},
40+
},
4141
}
4242
</script>
4343

src/backend/api.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ export const updateLogo = async ({ file, fileName, wikiId }) => {
7575
form,
7676
{
7777
headers: {
78-
'Content-Type': 'multipart/form-data'
79-
}
80-
}
78+
'Content-Type': 'multipart/form-data',
79+
},
80+
},
8181
)
8282
}
8383
// TODO the api should get the setting from the path (so it isn't needed in the payload)
@@ -93,8 +93,8 @@ export const wikiDiscovery = async ({ sort, direction, active, currentPage, resu
9393
direction,
9494
is_active: active,
9595
page: currentPage,
96-
per_page: resultsPerPage
97-
}
96+
per_page: resultsPerPage,
97+
},
9898
})).data
9999
}
100100

@@ -112,14 +112,14 @@ export const importEntities = async ({
112112
'Q5@2212749099',
113113
'Q64@2215506799',
114114
'Q42@2213635313',
115-
'Q3107329@2211072210'
115+
'Q3107329@2211072210',
116116
],
117-
sourceWikiUrl = 'https://www.wikidata.org'
117+
sourceWikiUrl = 'https://www.wikidata.org',
118118
}) => {
119119
const { data: { data } } = await axios.post('/wiki/entityImport', {
120120
wiki: wikiId,
121121
entity_ids: entityIds.join(','),
122-
source_wiki_url: sourceWikiUrl
122+
source_wiki_url: sourceWikiUrl,
123123
})
124124
return data
125125
}

src/backend/axios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import Axios from 'axios'
33
const axios = Axios.create({
44
baseURL: '/api',
55
headers: {
6-
'Content-Type': 'application/json'
7-
}
6+
'Content-Type': 'application/json',
7+
},
88
})
99

1010
export default axios

src/backend/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import axios from './axios'
33

44
export {
55
api,
6-
axios
6+
axios,
77
}

src/backend/mocks/default_handlers.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function makeUser (email = 'test@local') {
1111
email,
1212
verified: true,
1313
created_at: '2020-01-01',
14-
updated_at: '2020-01-01'
14+
updated_at: '2020-01-01',
1515
}
1616
}
1717

@@ -25,21 +25,21 @@ const makeNewWiki = ({ domain, sitename }) => {
2525
updated_at: '2020-01-01',
2626
pivot: {
2727
user_id: user.id,
28-
wiki_id: lastWikiId
28+
wiki_id: lastWikiId,
2929
},
3030
wiki_managers: [{
3131
email: user.email,
3232
pivot: {
3333
user_id: user.id,
34-
wiki_id: lastWikiId
35-
}
34+
wiki_id: lastWikiId,
35+
},
3636
}],
3737
wiki_db_version: {
3838
id: 101,
3939
wiki_id: lastWikiId,
40-
version: 'mw1.33-wbs1'
40+
version: 'mw1.33-wbs1',
4141
},
42-
public_settings: []
42+
public_settings: [],
4343
}
4444

4545
myWikis.push(newWiki)
@@ -59,12 +59,12 @@ const wikiDiscovery = (referrer, params) => {
5959
next: function () {
6060
const x = Math.sin(this.seed++) * 10000
6161
return x - Math.floor(x)
62-
}
62+
},
6363
}
6464

6565
const names = [
6666
'Wikibase Name',
67-
'A Very Long Wikibase Name'
67+
'A Very Long Wikibase Name',
6868
]
6969

7070
let wikis = [...Array(75).keys()].map((id) => {
@@ -73,12 +73,12 @@ const wikiDiscovery = (referrer, params) => {
7373
domain: id + '-wikibase.wbaas.localhost',
7474
sitename: id + ' - ' + names[id % names.length],
7575
wiki_site_stats: null,
76-
logo_url: null
76+
logo_url: null,
7777
}
7878

7979
if (pseudorandom.next() >= 0.1) {
8080
wiki.wiki_site_stats = {
81-
pages: Math.ceil(pseudorandom.next() * 250)
81+
pages: Math.ceil(pseudorandom.next() * 250),
8282
}
8383
}
8484

@@ -125,8 +125,8 @@ const wikiDiscovery = (referrer, params) => {
125125
data: wikis.slice(start, end),
126126
meta: {
127127
last_page: Math.ceil(wikis.length / resultsPerPage),
128-
total: wikis.length
129-
}
128+
total: wikis.length,
129+
},
130130
}
131131
}
132132

@@ -135,7 +135,7 @@ export const handlers = [
135135
rest.post(/\/api\/auth\/login$/, (req, res, ctx) => {
136136
user = makeUser(req.body.email)
137137
return res(ctx.json({
138-
user
138+
user,
139139
}), ctx.cookie('authToken', 'token_value'))
140140
}),
141141
rest.get(/\/api\/auth\/login$/, (req, res, ctx) => {
@@ -145,7 +145,7 @@ export const handlers = [
145145
}
146146
user = makeUser(req.body.email)
147147
return res(ctx.json({
148-
user
148+
user,
149149
}))
150150
}),
151151
rest.delete(/\/api\/auth\/login$/, (req, res, ctx) => {
@@ -157,7 +157,7 @@ export const handlers = [
157157
return res(ctx.status(400, 'Mocked Server Error'))
158158
}
159159
return res(ctx.status(200))
160-
}
160+
},
161161
),
162162
rest.post(/\/api\/user\/resetPassword$/, (_, res, ctx) => res(ctx.status(200))),
163163
rest.post(/\/api\/user\/sendVerifyEmail$/, (_, res, ctx) => res(ctx.json({ message: 'Already verified' }))),
@@ -174,7 +174,7 @@ export const handlers = [
174174
return res(ctx.status(400, 'Mocked recaptcha empty Error'))
175175
}
176176
return res(ctx.status(200))
177-
}
177+
},
178178
),
179179

180180
/* Wiki endpoints */
@@ -219,5 +219,5 @@ export const handlers = [
219219
}),
220220
rest.get(/\/api\/wiki$/, (req, res, ctx) => {
221221
return res(ctx.json(wikiDiscovery(req.referrer, req.url.searchParams)))
222-
})
222+
}),
223223
]

src/components/Cards/AudienceAndPurposeWizardStep.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ export default {
120120
title: String,
121121
inFlight: Boolean,
122122
value: Object,
123-
dismissable: Boolean
123+
dismissable: Boolean,
124124
},
125125
data () {
126126
return {
127127
purposeError: '',
128128
audienceError: '',
129129
purposeOtherError: '',
130-
audienceOtherError: ''
130+
audienceOtherError: '',
131131
}
132132
},
133133
methods: {
@@ -145,8 +145,8 @@ export default {
145145
if (this.$refs.inputForm.validate() === true) {
146146
this.$emit('next-step')
147147
}
148-
}
149-
}
148+
},
149+
},
150150
}
151151
</script>
152152

src/components/Cards/CreateAccount.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ export default {
8989
name: 'CreateAccountCard',
9090
props: [
9191
'title',
92-
'buttonText'
92+
'buttonText',
9393
],
9494
components: {},
9595
computed: {
9696
isLoggedIn: function () {
9797
return this.$store.getters.isLoggedIn
98-
}
98+
},
9999
},
100100
data () {
101101
return {
@@ -105,7 +105,7 @@ export default {
105105
terms: false,
106106
hasError: false,
107107
error: [],
108-
inFlight: false
108+
inFlight: false,
109109
}
110110
},
111111
created () {
@@ -165,7 +165,7 @@ export default {
165165
{
166166
email: this.email,
167167
password: this.password,
168-
recaptcha: token
168+
recaptcha: token,
169169
})
170170
.then(success => this.createSuccessful(success))
171171
.catch(errors => {
@@ -214,8 +214,8 @@ export default {
214214
if (this.isLoggedIn) {
215215
this.$router.replace(this.$route.query.redirect || '/dashboard')
216216
}
217-
}
218-
}
217+
},
218+
},
219219
}
220220
</script>
221221

src/components/Cards/CreateWiki.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ export default {
5858
SiteDetailsCreateWikiWizardStep,
5959
AudienceAndPurposeWizardStep,
6060
TemporalityCreateWikiWizardStep,
61-
KnowledgeEquityCreateWikiWizardStep
61+
KnowledgeEquityCreateWikiWizardStep,
6262
},
6363
props: [
64-
'title'
64+
'title',
6565
],
6666
computed: {
6767
currentUser: function () {
6868
return this.$store.getters.currentUser
69-
}
69+
},
7070
},
7171
data () {
7272
return {
@@ -75,21 +75,21 @@ export default {
7575
domainRadioChoice: 'sub',
7676
subdomain: '',
7777
domain: '',
78-
username: ''
78+
username: '',
7979
},
8080
stepTwo: {
8181
purpose: '',
8282
otherPurpose: '',
8383
audience: '',
84-
otherAudience: ''
84+
otherAudience: '',
8585
},
8686
stepThree: {
8787
temporality: '',
88-
otherTemporality: ''
88+
otherTemporality: '',
8989
},
9090
stepFour: {
9191
selectedOption: '',
92-
freeTextResponse: ''
92+
freeTextResponse: '',
9393
},
9494
hasError: false,
9595
error: [],
@@ -98,9 +98,9 @@ export default {
9898
CNAME_RECORD: config.CNAME_RECORD,
9999
errorMessages: {
100100
domainTaken: 'The domain has already been taken.',
101-
domainFormat: 'The subdomain must be at least five characters long and may contain only lowercase Latin letters (a-z), digits (0-9) and hyphens (-).'
101+
domainFormat: 'The subdomain must be at least five characters long and may contain only lowercase Latin letters (a-z), digits (0-9) and hyphens (-).',
102102
},
103-
step: 1
103+
step: 1,
104104
}
105105
},
106106
created () {
@@ -142,20 +142,20 @@ export default {
142142
...(this.stepTwo.audience && { audience: this.stepTwo.audience }),
143143
...(this.stepTwo.otherAudience && { audience_other: this.stepTwo.otherAudience }),
144144
temporality: this.stepThree.temporality,
145-
...(this.stepThree.otherTemporality && { temporality_other: this.stepThree.otherTemporality })
145+
...(this.stepThree.otherTemporality && { temporality_other: this.stepThree.otherTemporality }),
146146
}
147147
148148
const requestBody = {
149149
domain: domainToSubmit,
150150
sitename: this.stepOne.sitename,
151151
username: this.stepOne.username,
152-
profile: JSON.stringify(profileObject)
152+
profile: JSON.stringify(profileObject),
153153
}
154154
155155
if (this.stepThree.temporality === 'permanent' && this.stepFour.selectedOption) {
156156
requestBody.knowledgeEquityResponse = {
157157
selectedOption: this.stepFour.selectedOption,
158-
freeTextResponse: this.stepFour.freeTextResponse
158+
freeTextResponse: this.stepFour.freeTextResponse,
159159
}
160160
}
161161
@@ -216,8 +216,8 @@ export default {
216216
if (!this.currentUser) {
217217
this.$router.replace(this.$route.query.redirect || '/')
218218
}
219-
}
220-
}
219+
},
220+
},
221221
}
222222
</script>
223223

0 commit comments

Comments
 (0)