ESLint: Added curly rule (#2901)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
diff --git a/.eslintrc.js b/.eslintrc.js
index af23f5b..7a758b1 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -8,6 +8,7 @@ module.exports = {
// stylistic rules
'brace-style': ['warn', '1tbs', { allowSingleLine: true }],
+ 'curly': ['warn', 'all'],
'no-tabs': ['warn', { allowIndentationTabs: true }],
'no-var': 'error',
'one-var': ['warn', 'never'],
diff --git a/assets/code.js b/assets/code.js
index 5c10d05..162cdb0 100644
--- a/assets/code.js
+++ b/assets/code.js
@@ -119,7 +119,9 @@
// calc()
(function () {
- if (!window.PrefixFree) return;
+ if (!window.PrefixFree) {
+ return;
+ }
if (PrefixFree.functions.indexOf('calc') == -1) {
var style = document.createElement('_').style;
diff --git a/assets/download.js b/assets/download.js
index 2d8855c..121bb11 100644
--- a/assets/download.js
+++ b/assets/download.js
@@ -187,13 +187,16 @@
}
function getLanguageTitle(lang) {
- if (!lang.aliasTitles)
+ if (!lang.aliasTitles) {
return lang.title;
+ }
var titles = [lang.title];
- for (var alias in lang.aliasTitles)
- if (lang.aliasTitles.hasOwnProperty(alias))
+ for (var alias in lang.aliasTitles) {
+ if (lang.aliasTitles.hasOwnProperty(alias)) {
titles.push(lang.aliasTitles[alias]);
+ }
+ }
return titles.join(' + ');
}
diff --git a/components/prism-markup-templating.js b/components/prism-markup-templating.js
index 1c22f94..2855b7c 100644
--- a/components/prism-markup-templating.js
+++ b/components/prism-markup-templating.js
@@ -39,8 +39,9 @@
var placeholder;
// Check for existing strings
- while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1)
+ while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
++i;
+ }
// Create a sparse array
tokenStack[i] = match;
diff --git a/dangerfile.js b/dangerfile.js
index 36face9..d9eb8c5 100644
--- a/dangerfile.js
+++ b/dangerfile.js
@@ -45,7 +45,9 @@ const getChangedMinifiedFiles = async () => {
// https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript
const formatBytes = (bytes, decimals = 2) => {
- if (bytes === 0) return '0 Bytes';
+ if (bytes === 0) {
+ return '0 Bytes';
+ }
const k = 1000;
const dm = decimals < 0 ? 0 : decimals;
diff --git a/plugins/normalize-whitespace/prism-normalize-whitespace.js b/plugins/normalize-whitespace/prism-normalize-whitespace.js
index 9701324..f551807 100644
--- a/plugins/normalize-whitespace/prism-normalize-whitespace.js
+++ b/plugins/normalize-whitespace/prism-normalize-whitespace.js
@@ -6,8 +6,9 @@
var assign = Object.assign || function (obj1, obj2) {
for (var name in obj2) {
- if (obj2.hasOwnProperty(name))
+ if (obj2.hasOwnProperty(name)) {
obj1[name] = obj2[name];
+ }
}
return obj1;
};
@@ -25,8 +26,9 @@
function tabLen(str) {
var res = 0;
for (var i = 0; i < str.length; ++i) {
- if (str.charCodeAt(i) == '\t'.charCodeAt(0))
+ if (str.charCodeAt(i) == '\t'.charCodeAt(0)) {
res += 3;
+ }
}
return str.length + res;
}
@@ -76,13 +78,15 @@
removeIndent: function (input) {
var indents = input.match(/^[^\S\n\r]*(?=\S)/gm);
- if (!indents || !indents[0].length)
+ if (!indents || !indents[0].length) {
return input;
+ }
indents.sort(function (a, b) { return a.length - b.length; });
- if (!indents[0].length)
+ if (!indents[0].length) {
return input;
+ }
return input.replace(RegExp('^' + indents[0], 'gm'), '');
},
@@ -94,8 +98,9 @@
var lines = input.split('\n');
for (var i = 0; i < lines.length; ++i) {
- if (tabLen(lines[i]) <= characters)
+ if (tabLen(lines[i]) <= characters) {
continue;
+ }
var line = lines[i].split(/(\s+)/g);
var len = 0;
diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js
index 4879af1..a3c743e 100644
--- a/tests/helper/test-case.js
+++ b/tests/helper/test-case.js
@@ -306,7 +306,9 @@ function translateIndexIgnoreSpaces(spacey, withoutSpaces, withoutSpaceIndex) {
let i = 0;
let j = 0;
while (i < spacey.length && j < withoutSpaces.length) {
- while (spacey[i] !== withoutSpaces[j]) i++;
+ while (spacey[i] !== withoutSpaces[j]) {
+ i++;
+ }
if (j === withoutSpaceIndex) {
return i;
}