ESLint: Added brace-style rule (#2865)
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
diff --git a/.eslintrc.js b/.eslintrc.js
index b85aded..4aafc6f 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -4,6 +4,7 @@ module.exports = {
extends: 'eslint:recommended',
rules: {
// stylistic rules
+ 'brace-style': ['warn', '1tbs', { allowSingleLine: true }],
'no-var': 'error',
'quotes': ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
'semi': 'warn',
diff --git a/assets/code.js b/assets/code.js
index 53ac6f8..6ea8979 100644
--- a/assets/code.js
+++ b/assets/code.js
@@ -28,8 +28,7 @@ $$('[data-src][data-type="text/html"]').forEach(function(element) {
parent.removeChild(script);
document.head.appendChild(script);
});
- }
- catch (e) { /* noop */ }
+ } catch (e) { /* noop */ }
}
});
});
diff --git a/assets/download.js b/assets/download.js
index 66c4ddf..b86b426 100644
--- a/assets/download.js
+++ b/assets/download.js
@@ -333,8 +333,7 @@ function getFilesSizes() {
}
});
}(category, id));
- }
- else {
+ } else {
update(category, id);
}
});
diff --git a/components/prism-core.js b/components/prism-core.js
index 4d2e7f5..15c9678 100644
--- a/components/prism-core.js
+++ b/components/prism-core.js
@@ -432,8 +432,7 @@ var _ = {
if (propertyType === 'Object' && !visited[objId(property)]) {
visited[objId(property)] = true;
DFS(property, callback, null, visited);
- }
- else if (propertyType === 'Array' && !visited[objId(property)]) {
+ } else if (propertyType === 'Array' && !visited[objId(property)]) {
visited[objId(property)] = true;
DFS(property, callback, i, visited);
}
@@ -589,8 +588,7 @@ var _ = {
code: env.code,
immediateClose: true
}));
- }
- else {
+ } else {
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
}
},
diff --git a/docs/Prism.hooks.html b/docs/Prism.hooks.html
index 851bd8d..49fa666 100644
--- a/docs/Prism.hooks.html
+++ b/docs/Prism.hooks.html
@@ -73,7 +73,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line677">line 677</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line675">line 675</a>
</li></ul></dd>
@@ -152,7 +152,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line692">line 692</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line690">line 690</a>
</li></ul></dd>
@@ -314,7 +314,7 @@ Hooks are usually directly run by a highlight function but you can also run hook
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line709">line 709</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line707">line 707</a>
</li></ul></dd>
diff --git a/docs/Prism.html b/docs/Prism.html
index 89b73d0..325c6b5 100644
--- a/docs/Prism.html
+++ b/docs/Prism.html
@@ -263,7 +263,7 @@ Prism.manual = true;
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line618">line 618</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line616">line 616</a>
</li></ul></dd>
@@ -480,7 +480,7 @@ and the language definitions to use, and returns a string with the HTML produced
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line459">line 459</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line458">line 458</a>
</li></ul></dd>
@@ -676,7 +676,7 @@ each one of them.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line478">line 478</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line477">line 477</a>
</li></ul></dd>
@@ -911,7 +911,7 @@ each one of them.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line524">line 524</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line523">line 523</a>
</li></ul></dd>
@@ -1157,7 +1157,7 @@ Mostly useful when <code>async</code> is <code>true</code>, since in that case,
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line654">line 654</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line652">line 652</a>
</li></ul></dd>
diff --git a/docs/Token.html b/docs/Token.html
index d327828..427442b 100644
--- a/docs/Token.html
+++ b/docs/Token.html
@@ -80,7 +80,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line743">line 743</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line741">line 741</a>
</li></ul></dd>
@@ -364,7 +364,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line770">line 770</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line768">line 768</a>
</li></ul></dd>
@@ -447,7 +447,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line762">line 762</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line760">line 760</a>
</li></ul></dd>
@@ -524,7 +524,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line753">line 753</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line751">line 751</a>
</li></ul></dd>
diff --git a/docs/global.html b/docs/global.html
index 4dc4720..0a4ffd8 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -143,7 +143,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line1197">line 1197</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line1195">line 1195</a>
</li></ul></dd>
@@ -274,7 +274,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line1176">line 1176</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line1174">line 1174</a>
</li></ul></dd>
@@ -559,7 +559,7 @@ each another.</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line1205">line 1205</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line1203">line 1203</a>
</li></ul></dd>
@@ -713,7 +713,7 @@ each another.</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line1215">line 1215</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line1213">line 1213</a>
</li></ul></dd>
@@ -859,7 +859,7 @@ each another.</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line775">line 775</a>
+ <a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line773">line 773</a>
</li></ul></dd>
diff --git a/docs/prism-core.js.html b/docs/prism-core.js.html
index bf2b13e..cf7f233 100644
--- a/docs/prism-core.js.html
+++ b/docs/prism-core.js.html
@@ -485,8 +485,7 @@ var _ = {
if (propertyType === 'Object' && !visited[objId(property)]) {
visited[objId(property)] = true;
DFS(property, callback, null, visited);
- }
- else if (propertyType === 'Array' && !visited[objId(property)]) {
+ } else if (propertyType === 'Array' && !visited[objId(property)]) {
visited[objId(property)] = true;
DFS(property, callback, i, visited);
}
@@ -642,8 +641,7 @@ var _ = {
code: env.code,
immediateClose: true
}));
- }
- else {
+ } else {
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
}
},
diff --git a/plugins/autolinker/prism-autolinker.js b/plugins/autolinker/prism-autolinker.js
index a5e4e8e..7658779 100644
--- a/plugins/autolinker/prism-autolinker.js
+++ b/plugins/autolinker/prism-autolinker.js
@@ -32,8 +32,7 @@ Prism.plugins.autolinker = {
}
if (type == 'attr-value') {
Prism.languages.insertBefore('inside', 'punctuation', { 'url-link': url }, def);
- }
- else {
+ } else {
def.inside['url-link'] = url;
}
@@ -57,8 +56,7 @@ Prism.hooks.add('wrap', function(env) {
if (env.type == 'email-link' && href.indexOf('mailto:') != 0) {
href = 'mailto:' + href;
- }
- else if (env.type == 'md-link') {
+ } else if (env.type == 'md-link') {
// Markdown
var match = env.content.match(linkMd);
diff --git a/plugins/data-uri-highlight/prism-data-uri-highlight.js b/plugins/data-uri-highlight/prism-data-uri-highlight.js
index 196cd81..ea1f4b3 100644
--- a/plugins/data-uri-highlight/prism-data-uri-highlight.js
+++ b/plugins/data-uri-highlight/prism-data-uri-highlight.js
@@ -57,8 +57,7 @@
Prism.languages.insertBefore('inside', def.inside['url-link'] ? 'url-link' : 'punctuation', {
'data-uri': dataURI
}, def);
- }
- else {
+ } else {
if (def.inside['url-link']) {
Prism.languages.insertBefore('inside', 'url-link', {
'data-uri': dataURI
diff --git a/plugins/jsonp-highlight/prism-jsonp-highlight.js b/plugins/jsonp-highlight/prism-jsonp-highlight.js
index 97c3cd2..ff35800 100644
--- a/plugins/jsonp-highlight/prism-jsonp-highlight.js
+++ b/plugins/jsonp-highlight/prism-jsonp-highlight.js
@@ -48,8 +48,7 @@
return item.adapter;
}
}
- }
- else if (typeof adapter === 'string') {
+ } else if (typeof adapter === 'string') {
// eslint-disable-next-line no-redeclare
for (var i = 0, item; item = adapters[i++];) {
if (item.name === adapter) {
@@ -83,8 +82,7 @@
if (rsp && rsp.meta && rsp.data) {
if (rsp.meta.status && rsp.meta.status >= 400) {
return 'Error: ' + (rsp.data.message || rsp.meta.status);
- }
- else if (typeof (rsp.data.content) === 'string') {
+ } else if (typeof (rsp.data.content) === 'string') {
return typeof (atob) === 'function'
? atob(rsp.data.content.replace(/\s/g, ''))
: 'Your browser cannot decode base64';
diff --git a/plugins/wpd/prism-wpd.js b/plugins/wpd/prism-wpd.js
index 5d9ef01..2fc318c 100644
--- a/plugins/wpd/prism-wpd.js
+++ b/plugins/wpd/prism-wpd.js
@@ -6,13 +6,10 @@ if (typeof Prism === 'undefined') {
if (Prism.languages.css) {
// check whether the selector is an advanced pattern before extending it
- if (Prism.languages.css.selector.pattern)
- {
+ if (Prism.languages.css.selector.pattern) {
Prism.languages.css.selector.inside['pseudo-class'] = /:[\w-]+/;
Prism.languages.css.selector.inside['pseudo-element'] = /::[\w-]+/;
- }
- else
- {
+ } else {
Prism.languages.css.selector = {
pattern: Prism.languages.css.selector,
inside: {
@@ -70,37 +67,30 @@ Prism.hooks.add('wrap', function(env) {
if (env.type == 'property') {
href += 'properties/';
- }
- else if (env.type == 'rule') {
+ } else if (env.type == 'rule') {
href += 'atrules/';
content = content.substring(1);
- }
- else if (env.type == 'pseudo-class') {
+ } else if (env.type == 'pseudo-class') {
href += 'selectors/pseudo-classes/';
content = content.substring(1);
- }
- else if (env.type == 'pseudo-element') {
+ } else if (env.type == 'pseudo-element') {
href += 'selectors/pseudo-elements/';
content = content.substring(2);
}
- }
- else if (env.language == 'markup') {
+ } else if (env.language == 'markup') {
if (env.type == 'tag-id') {
// Check language
language = getLanguage(env.content) || language;
if (language) {
href += language + '/elements/';
- }
- else {
+ } else {
return; // Abort
}
- }
- else if (env.type == 'attr-name') {
+ } else if (env.type == 'attr-name') {
if (language) {
href += language + '/attributes/';
- }
- else {
+ } else {
return; // Abort
}
}
@@ -119,11 +109,9 @@ function getLanguage(tag) {
if (Tags.HTML[tagL]) {
return 'html';
- }
- else if (Tags.SVG[tag]) {
+ } else if (Tags.SVG[tag]) {
return 'svg';
- }
- else if (Tags.MathML[tag]) {
+ } else if (Tags.MathML[tag]) {
return 'mathml';
}
diff --git a/prism.js b/prism.js
index e5024af..6c324eb 100644
--- a/prism.js
+++ b/prism.js
@@ -437,8 +437,7 @@ var _ = {
if (propertyType === 'Object' && !visited[objId(property)]) {
visited[objId(property)] = true;
DFS(property, callback, null, visited);
- }
- else if (propertyType === 'Array' && !visited[objId(property)]) {
+ } else if (propertyType === 'Array' && !visited[objId(property)]) {
visited[objId(property)] = true;
DFS(property, callback, i, visited);
}
@@ -594,8 +593,7 @@ var _ = {
code: env.code,
immediateClose: true
}));
- }
- else {
+ } else {
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
}
},