Skip to content

Commit 212dc1c

Browse files
ESLint: Added curly rule (#2901)
1 parent 415651a commit 212dc1c

File tree

7 files changed

+28
-12
lines changed

7 files changed

+28
-12
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88

99
// stylistic rules
1010
'brace-style': ['warn', '1tbs', { allowSingleLine: true }],
11+
'curly': ['warn', 'all'],
1112
'no-tabs': ['warn', { allowIndentationTabs: true }],
1213
'no-var': 'error',
1314
'one-var': ['warn', 'never'],

assets/code.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@
119119

120120
// calc()
121121
(function () {
122-
if (!window.PrefixFree) return;
122+
if (!window.PrefixFree) {
123+
return;
124+
}
123125

124126
if (PrefixFree.functions.indexOf('calc') == -1) {
125127
var style = document.createElement('_').style;

assets/download.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,16 @@
187187
}
188188

189189
function getLanguageTitle(lang) {
190-
if (!lang.aliasTitles)
190+
if (!lang.aliasTitles) {
191191
return lang.title;
192+
}
192193

193194
var titles = [lang.title];
194-
for (var alias in lang.aliasTitles)
195-
if (lang.aliasTitles.hasOwnProperty(alias))
195+
for (var alias in lang.aliasTitles) {
196+
if (lang.aliasTitles.hasOwnProperty(alias)) {
196197
titles.push(lang.aliasTitles[alias]);
198+
}
199+
}
197200
return titles.join(' + ');
198201
}
199202

components/prism-markup-templating.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
var placeholder;
4040

4141
// Check for existing strings
42-
while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1)
42+
while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
4343
++i;
44+
}
4445

4546
// Create a sparse array
4647
tokenStack[i] = match;

dangerfile.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ const getChangedMinifiedFiles = async () => {
4545

4646
// https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript
4747
const formatBytes = (bytes, decimals = 2) => {
48-
if (bytes === 0) return '0 Bytes';
48+
if (bytes === 0) {
49+
return '0 Bytes';
50+
}
4951

5052
const k = 1000;
5153
const dm = decimals < 0 ? 0 : decimals;

plugins/normalize-whitespace/prism-normalize-whitespace.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
var assign = Object.assign || function (obj1, obj2) {
88
for (var name in obj2) {
9-
if (obj2.hasOwnProperty(name))
9+
if (obj2.hasOwnProperty(name)) {
1010
obj1[name] = obj2[name];
11+
}
1112
}
1213
return obj1;
1314
};
@@ -25,8 +26,9 @@
2526
function tabLen(str) {
2627
var res = 0;
2728
for (var i = 0; i < str.length; ++i) {
28-
if (str.charCodeAt(i) == '\t'.charCodeAt(0))
29+
if (str.charCodeAt(i) == '\t'.charCodeAt(0)) {
2930
res += 3;
31+
}
3032
}
3133
return str.length + res;
3234
}
@@ -76,13 +78,15 @@
7678
removeIndent: function (input) {
7779
var indents = input.match(/^[^\S\n\r]*(?=\S)/gm);
7880

79-
if (!indents || !indents[0].length)
81+
if (!indents || !indents[0].length) {
8082
return input;
83+
}
8184

8285
indents.sort(function (a, b) { return a.length - b.length; });
8386

84-
if (!indents[0].length)
87+
if (!indents[0].length) {
8588
return input;
89+
}
8690

8791
return input.replace(RegExp('^' + indents[0], 'gm'), '');
8892
},
@@ -94,8 +98,9 @@
9498

9599
var lines = input.split('\n');
96100
for (var i = 0; i < lines.length; ++i) {
97-
if (tabLen(lines[i]) <= characters)
101+
if (tabLen(lines[i]) <= characters) {
98102
continue;
103+
}
99104

100105
var line = lines[i].split(/(\s+)/g);
101106
var len = 0;

tests/helper/test-case.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ function translateIndexIgnoreSpaces(spacey, withoutSpaces, withoutSpaceIndex) {
306306
let i = 0;
307307
let j = 0;
308308
while (i < spacey.length && j < withoutSpaces.length) {
309-
while (spacey[i] !== withoutSpaces[j]) i++;
309+
while (spacey[i] !== withoutSpaces[j]) {
310+
i++;
311+
}
310312
if (j === withoutSpaceIndex) {
311313
return i;
312314
}

0 commit comments

Comments
 (0)