Skip to content

Commit 3d751b6

Browse files
authored
Enforce trailing comma in JS on multiline (#30002)
To keep blame info accurate and to avoid [changes like this](https://github.com/go-gitea/gitea/pull/29977/files#diff-c3422631a14edbe1e508c4b22f0c718db318be08a6e889427802f9b6165d88d6R359), it's good to always have a trailing comma, so let's enforce it in JS. This rule is completely automatically fixable with `make lint-js-fix` and that's what I did here.
1 parent f88ad54 commit 3d751b6

Some content is hidden

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

48 files changed

+117
-117
lines changed

.eslintrc.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ rules:
119119
"@stylistic/js/arrow-spacing": [2, {before: true, after: true}]
120120
"@stylistic/js/block-spacing": [0]
121121
"@stylistic/js/brace-style": [2, 1tbs, {allowSingleLine: true}]
122-
"@stylistic/js/comma-dangle": [2, only-multiline]
122+
"@stylistic/js/comma-dangle": [2, always-multiline]
123123
"@stylistic/js/comma-spacing": [2, {before: false, after: true}]
124124
"@stylistic/js/comma-style": [2, last]
125125
"@stylistic/js/computed-property-spacing": [2, never]

playwright.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
* Maximum time expect() should wait for the condition to be met.
2121
* For example in `await expect(locator).toHaveText();`
2222
*/
23-
timeout: 2000
23+
timeout: 2000,
2424
},
2525

2626
/* Fail the build on CI if you accidentally left test.only in the source code. */

tools/generate-images.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async function generate(svg, path, {size, bg}) {
2020
'removeDimensions',
2121
{
2222
name: 'addAttributesToSVGElement',
23-
params: {attributes: [{width: size}, {height: size}]}
23+
params: {attributes: [{width: size}, {height: size}]},
2424
},
2525
],
2626
});

tools/generate-svg.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ async function processFile(file, {prefix, fullName} = {}) {
3939
attributes: [
4040
{'xmlns': 'http://www.w3.org/2000/svg'},
4141
{'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'},
42-
]
43-
}
42+
],
43+
},
4444
},
4545
],
4646
});

web_src/js/components/ActionRunStatus.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ export default {
1010
props: {
1111
status: {
1212
type: String,
13-
required: true
13+
required: true,
1414
},
1515
size: {
1616
type: Number,
17-
default: 16
17+
default: 16,
1818
},
1919
className: {
2020
type: String,
21-
default: ''
21+
default: '',
2222
},
2323
localeStatus: {
2424
type: String,
25-
default: ''
26-
}
25+
default: '',
26+
},
2727
},
2828
};
2929
</script>

web_src/js/components/ActivityHeatmap.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default {
1111
locale: {
1212
type: Object,
1313
default: () => {},
14-
}
14+
},
1515
},
1616
data: () => ({
1717
colorRange: [
@@ -49,7 +49,7 @@ export default {
4949
5050
const newSearch = params.toString();
5151
window.location.search = newSearch.length ? `?${newSearch}` : '';
52-
}
52+
},
5353
},
5454
};
5555
</script>

web_src/js/components/ContextPopup.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default {
6969
}
7070
return {name: label.name, color: `#${label.color}`, textColor};
7171
});
72-
}
72+
},
7373
},
7474
mounted() {
7575
this.$refs.root.addEventListener('ce-load-context-popup', (e) => {
@@ -97,8 +97,8 @@ export default {
9797
} finally {
9898
this.loading = false;
9999
}
100-
}
101-
}
100+
},
101+
},
102102
};
103103
</script>
104104
<template>

web_src/js/components/DashboardRepoList.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ const sfc = {
253253
...webSearchRepo.repository,
254254
latest_commit_status_state: webSearchRepo.latest_commit_status.State,
255255
locale_latest_commit_status_state: webSearchRepo.locale_latest_commit_status,
256-
latest_commit_status_state_link: webSearchRepo.latest_commit_status.TargetURL
256+
latest_commit_status_state_link: webSearchRepo.latest_commit_status.TargetURL,
257257
};
258258
});
259259
const count = response.headers.get('X-Total-Count');
@@ -325,7 +325,7 @@ const sfc = {
325325
if (this.activeIndex === -1 || this.activeIndex > this.repos.length - 1) {
326326
this.activeIndex = 0;
327327
}
328-
}
328+
},
329329
},
330330
};
331331

web_src/js/components/DiffCommitSelector.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default {
1414
},
1515
commits: [],
1616
hoverActivated: false,
17-
lastReviewCommitSha: null
17+
lastReviewCommitSha: null,
1818
};
1919
},
2020
computed: {
@@ -29,7 +29,7 @@ export default {
2929
},
3030
issueLink() {
3131
return this.$el.parentNode.getAttribute('data-issuelink');
32-
}
32+
},
3333
},
3434
mounted() {
3535
document.body.addEventListener('click', this.onBodyClick);
@@ -185,7 +185,7 @@ export default {
185185
}
186186
}
187187
},
188-
}
188+
},
189189
};
190190
</script>
191191
<template>

web_src/js/components/DiffFileList.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default {
3131
},
3232
loadMoreData() {
3333
loadMoreFiles(this.store.linkLoadMore);
34-
}
34+
},
3535
},
3636
};
3737
</script>

web_src/js/components/DiffFileTree.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default {
3030
let newParent = {
3131
name: split,
3232
children: [],
33-
isFile
33+
isFile,
3434
};
3535
3636
if (isFile === true) {
@@ -40,7 +40,7 @@ export default {
4040
if (parent) {
4141
// check if the folder already exists
4242
const existingFolder = parent.children.find(
43-
(x) => x.name === split
43+
(x) => x.name === split,
4444
);
4545
if (existingFolder) {
4646
newParent = existingFolder;
@@ -74,7 +74,7 @@ export default {
7474
// reduce the depth of our tree.
7575
mergeChildIfOnlyOneDir(result);
7676
return result;
77-
}
77+
},
7878
},
7979
mounted() {
8080
// Default to true if unset

web_src/js/components/DiffFileTreeItem.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
props: {
88
item: {
99
type: Object,
10-
required: true
10+
required: true,
1111
},
1212
},
1313
data: () => ({

web_src/js/components/PullRequestMergeForm.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default {
4343
for (const elem of document.querySelectorAll('[data-pull-merge-style]')) {
4444
toggleElem(elem, elem.getAttribute('data-pull-merge-style') === val);
4545
}
46-
}
46+
},
4747
},
4848
created() {
4949
this.mergeStyleAllowedCount = this.mergeForm.mergeStyles.reduce((v, msd) => v + (msd.allowed ? 1 : 0), 0);

web_src/js/components/RepoActionView.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const sfc = {
6666
name: '',
6767
link: '',
6868
},
69-
}
69+
},
7070
},
7171
currentJob: {
7272
title: '',
@@ -311,7 +311,7 @@ const sfc = {
311311
const logLine = this.$refs.steps.querySelector(selectedLogStep);
312312
if (!logLine) return;
313313
logLine.querySelector('.line-num').click();
314-
}
314+
},
315315
},
316316
};
317317
@@ -352,7 +352,7 @@ export function initRepositoryActionView() {
352352
skipped: el.getAttribute('data-locale-status-skipped'),
353353
blocked: el.getAttribute('data-locale-status-blocked'),
354354
},
355-
}
355+
},
356356
});
357357
view.mount(el);
358358
}

web_src/js/components/RepoActivityTopAuthors.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const sfc = {
4747
this.colors.barColor = refStyle.backgroundColor;
4848
this.colors.textColor = refStyle.color;
4949
this.colors.textAltColor = refAltStyle.color;
50-
}
50+
},
5151
};
5252
5353
export function initRepoActivityTopAuthorsChart() {

web_src/js/components/RepoBranchTagSelector.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const sfc = {
3636
},
3737
shouldCreateTag() {
3838
return this.mode === 'tags';
39-
}
39+
},
4040
},
4141
4242
watch: {
@@ -45,7 +45,7 @@ const sfc = {
4545
this.focusSearchField();
4646
this.fetchBranchesOrTags();
4747
}
48-
}
48+
},
4949
},
5050
5151
beforeMount() {
@@ -209,7 +209,7 @@ const sfc = {
209209
this.isLoading = false;
210210
}
211211
},
212-
}
212+
},
213213
};
214214
215215
export function initRepoBranchTagSelector(selector) {

web_src/js/components/RepoCodeFrequency.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default {
3939
props: {
4040
locale: {
4141
type: Object,
42-
required: true
42+
required: true,
4343
},
4444
},
4545
data: () => ({
@@ -128,12 +128,12 @@ export default {
128128
},
129129
ticks: {
130130
maxRotation: 0,
131-
maxTicksLimit: 12
131+
maxTicksLimit: 12,
132132
},
133133
},
134134
y: {
135135
ticks: {
136-
maxTicksLimit: 6
136+
maxTicksLimit: 6,
137137
},
138138
},
139139
},

web_src/js/components/RepoContributors.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const customEventListener = {
3434
chart.resetZoom();
3535
opts.instance.updateOtherCharts(args.event, true);
3636
}
37-
}
37+
},
3838
};
3939
4040
Chart.defaults.color = chartJsColors.text;
@@ -82,7 +82,7 @@ export default {
8282
this.xAxisMax = this.xAxisEnd;
8383
this.type = val;
8484
this.sortContributors();
85-
}
85+
},
8686
});
8787
},
8888
methods: {
@@ -175,7 +175,7 @@ export default {
175175
// Normally, chartjs handles this automatically, but it will resize the graph when you
176176
// zoom, pan etc. I think resizing the graph makes it harder to compare things visually.
177177
const maxValue = Math.max(
178-
...this.totalStats.weeks.map((o) => o[this.type])
178+
...this.totalStats.weeks.map((o) => o[this.type]),
179179
);
180180
const [coefficient, exp] = maxValue.toExponential().split('e').map(Number);
181181
if (coefficient % 1 === 0) return maxValue;
@@ -187,7 +187,7 @@ export default {
187187
// for contributors' graph. If I let chartjs do this for me, it will choose different
188188
// maxY value for each contributors' graph which again makes it harder to compare.
189189
const maxValue = Math.max(
190-
...this.sortedContributors.map((c) => c.max_contribution_type)
190+
...this.sortedContributors.map((c) => c.max_contribution_type),
191191
);
192192
const [coefficient, exp] = maxValue.toExponential().split('e').map(Number);
193193
if (coefficient % 1 === 0) return maxValue;

web_src/js/components/RepoRecentCommits.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default {
3535
props: {
3636
locale: {
3737
type: Object,
38-
required: true
38+
required: true,
3939
},
4040
},
4141
data: () => ({
@@ -105,12 +105,12 @@ export default {
105105
},
106106
ticks: {
107107
maxRotation: 0,
108-
maxTicksLimit: 52
108+
maxTicksLimit: 52,
109109
},
110110
},
111111
y: {
112112
ticks: {
113-
maxTicksLimit: 6
113+
maxTicksLimit: 6,
114114
},
115115
},
116116
},

web_src/js/components/ScopedAccessTokenSelector.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const sfc = {
3939
'repository',
4040
'user');
4141
return categories;
42-
}
42+
},
4343
},
4444
4545
mounted() {
@@ -68,7 +68,7 @@ const sfc = {
6868
}
6969
// no scopes selected, show validation error
7070
showElem(warningEl);
71-
}
71+
},
7272
},
7373
};
7474

web_src/js/features/captcha.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function initCaptcha() {
99

1010
const params = {
1111
sitekey: siteKey,
12-
theme: isDark ? 'dark' : 'light'
12+
theme: isDark ? 'dark' : 'light',
1313
};
1414

1515
switch (captchaEl.getAttribute('data-captcha-type')) {
@@ -42,7 +42,7 @@ export async function initCaptcha() {
4242
siteKey: {
4343
instanceUrl: new URL(instanceURL),
4444
key: siteKey,
45-
}
45+
},
4646
});
4747
break;
4848
}

web_src/js/features/code-frequency.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function initRepoCodeFrequency() {
1111
loadingTitle: el.getAttribute('data-locale-loading-title'),
1212
loadingTitleFailed: el.getAttribute('data-locale-loading-title-failed'),
1313
loadingInfo: el.getAttribute('data-locale-loading-info'),
14-
}
14+
},
1515
});
1616
View.mount(el);
1717
} catch (err) {

0 commit comments

Comments
 (0)