Skip to content

Commit f6316fd

Browse files
authored
Enable unicorn/switch-case-braces rule (#187)
1 parent acf904c commit f6316fd

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@
7272
"spaced-comment": "off",
7373
"unicorn/prefer-module": "off",
7474
"unicorn/prefer-top-level-await": "off",
75-
"unicorn/prevent-abbreviations": "off",
76-
"unicorn/switch-case-braces": "off"
75+
"unicorn/prevent-abbreviations": "off"
7776
}
7877
}
7978
}

src/js.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
}
6161

6262
switch (type) {
63-
case 'watch':
63+
case 'watch': {
6464
if (v === '2') {
6565
counter.textContent = obj.data.subscribers_count && addCommas(obj.data.subscribers_count);
6666
counter.setAttribute('aria-label', counter.textContent + ' watchers' + LABEL_SUFFIX);
@@ -70,18 +70,25 @@
7070
}
7171

7272
break;
73-
case 'star':
73+
}
74+
75+
case 'star': {
7476
counter.textContent = obj.data.stargazers_count && addCommas(obj.data.stargazers_count);
7577
counter.setAttribute('aria-label', counter.textContent + ' stargazers' + LABEL_SUFFIX);
7678
break;
77-
case 'fork':
79+
}
80+
81+
case 'fork': {
7882
counter.textContent = obj.data.network_count && addCommas(obj.data.network_count);
7983
counter.setAttribute('aria-label', counter.textContent + ' forks' + LABEL_SUFFIX);
8084
break;
81-
case 'follow':
85+
}
86+
87+
case 'follow': {
8288
counter.textContent = obj.data.followers && addCommas(obj.data.followers);
8389
counter.setAttribute('aria-label', counter.textContent + ' followers' + LABEL_SUFFIX);
8490
break;
91+
}
8592
}
8693

8794
// Show the count if asked and if it's not empty
@@ -98,7 +105,7 @@
98105

99106
// Add the class, change the text label, set count link href
100107
switch (type) {
101-
case 'watch':
108+
case 'watch': {
102109
if (v === '2') {
103110
mainButton.className += ' github-watchers';
104111
text.textContent = 'Watch';
@@ -111,32 +118,41 @@
111118

112119
title = text.textContent + ' ' + USER_REPO;
113120
break;
114-
case 'star':
121+
}
122+
123+
case 'star': {
115124
mainButton.className += ' github-stargazers';
116125
text.textContent = 'Star';
117126
counter.href = REPO_URL + '/stargazers';
118127
title = text.textContent + ' ' + USER_REPO;
119128
break;
120-
case 'fork':
129+
}
130+
131+
case 'fork': {
121132
mainButton.className += ' github-forks';
122133
text.textContent = 'Fork';
123134
button.href = REPO_URL + '/fork';
124135
counter.href = REPO_URL + '/network';
125136
title = text.textContent + ' ' + USER_REPO;
126137
break;
127-
case 'follow':
138+
}
139+
140+
case 'follow': {
128141
mainButton.className += ' github-me';
129142
text.textContent = 'Follow @' + user;
130143
button.href = GITHUB_URL + user;
131144
counter.href = GITHUB_URL + user + '?tab=followers';
132145
title = text.textContent;
133146
break;
134-
case 'sponsor':
147+
}
148+
149+
case 'sponsor': {
135150
mainButton.className += ' github-me';
136151
text.textContent = 'Sponsor @' + user;
137152
button.href = GITHUB_URL + 'sponsors/' + user;
138153
title = text.textContent;
139154
break;
155+
}
140156
}
141157

142158
button.setAttribute('aria-label', title + LABEL_SUFFIX);

0 commit comments

Comments
 (0)