ESLint: Added wrap-iife rule (#2867)
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
diff --git a/.eslintrc.js b/.eslintrc.js
index e01656d..b85aded 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -7,6 +7,7 @@ module.exports = {
'no-var': 'error',
'quotes': ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
'semi': 'warn',
+ 'wrap-iife': 'warn',
// I turned this rule off because we use `hasOwnProperty` in a lot of places
// TODO: Think about re-enabling this rule
diff --git a/assets/code.js b/assets/code.js
index 23c600e..53ac6f8 100644
--- a/assets/code.js
+++ b/assets/code.js
@@ -34,7 +34,7 @@ $$('[data-src][data-type="text/html"]').forEach(function(element) {
});
});
-})();
+}());
/**
* Table of contents
@@ -98,7 +98,7 @@ if (toc.children.length > 0) {
});
}
-})();
+}());
/**
* Linkify h2
@@ -116,7 +116,7 @@ if (toc.children.length > 0) {
inside: h2
});
});
-})();
+}());
// calc()
(function(){
@@ -140,7 +140,7 @@ if (toc.children.length > 0) {
calculatePadding();
}
}
-})();
+}());
// setTheme is intentionally global,
// so it can be accessed from download.js
@@ -207,7 +207,7 @@ for (var id in themes) {
}
setTheme(current);
-})();
+}());
(function(){
@@ -266,4 +266,4 @@ Prism && Prism.hooks.add('complete', function (env) {
});
});
-})();
+}());
diff --git a/assets/download.js b/assets/download.js
index 2b4f2c1..66c4ddf 100644
--- a/assets/download.js
+++ b/assets/download.js
@@ -120,7 +120,7 @@ for (var category in components) {
update(category);
};
- })(category, all)
+ }(category, all))
}
},
'Select/unselect all'
@@ -236,7 +236,7 @@ for (var category in components) {
update(category, id);
};
- })(id, category, all)
+ }(id, category, all))
}
},
all.meta.link? {
@@ -535,7 +535,7 @@ function generateCode(){
$('#download-' + type + ' .download-button').onclick = function () {
saveAs(new Blob([text], { type: 'application/octet-stream;charset=utf-8' }), fileName);
};
- })(type);
+ }(type));
}
});
}
@@ -623,4 +623,4 @@ function getVersion() {
});
}
-})();
+}());
diff --git a/components/prism-abnf.js b/components/prism-abnf.js
index 74b3439..8ad6a68 100644
--- a/components/prism-abnf.js
+++ b/components/prism-abnf.js
@@ -51,4 +51,4 @@
'punctuation': /[()\[\]]/
};
-})(Prism);
+}(Prism));
diff --git a/components/prism-apex.js b/components/prism-apex.js
index ae7b25e..51c16c1 100644
--- a/components/prism-apex.js
+++ b/components/prism-apex.js
@@ -62,4 +62,4 @@
'punctuation': /[()\[\]{};,.]/
};
-})(Prism);
+}(Prism));
diff --git a/components/prism-bash.js b/components/prism-bash.js
index 9487408..80a0449 100644
--- a/components/prism-bash.js
+++ b/components/prism-bash.js
@@ -224,4 +224,4 @@
}
Prism.languages.shell = Prism.languages.bash;
-})(Prism);
+}(Prism));
diff --git a/components/prism-core.js b/components/prism-core.js
index a394de6..4d2e7f5 100644
--- a/components/prism-core.js
+++ b/components/prism-core.js
@@ -1160,7 +1160,7 @@ if (!_.manual) {
return _;
-})(_self);
+}(_self));
if (typeof module !== 'undefined' && module.exports) {
module.exports = Prism;
diff --git a/components/prism-css-extras.js b/components/prism-css-extras.js
index 409817c..a975e0b 100644
--- a/components/prism-css-extras.js
+++ b/components/prism-css-extras.js
@@ -113,4 +113,4 @@
'number': number
});
-})(Prism);
+}(Prism));
diff --git a/components/prism-django.js b/components/prism-django.js
index 460999f..cbb156d 100644
--- a/components/prism-django.js
+++ b/components/prism-django.js
@@ -57,4 +57,4 @@
markupTemplating.tokenizePlaceholders(env, 'jinja2');
});
-})(Prism);
+}(Prism));
diff --git a/components/prism-factor.js b/components/prism-factor.js
index 9f0810c..efc33b4 100644
--- a/components/prism-factor.js
+++ b/components/prism-factor.js
@@ -400,4 +400,4 @@
Prism.languages.factor = factor;
-})(Prism);
+}(Prism));
diff --git a/components/prism-latex.js b/components/prism-latex.js
index 68a45b6..2884501 100644
--- a/components/prism-latex.js
+++ b/components/prism-latex.js
@@ -61,4 +61,4 @@
Prism.languages.tex = Prism.languages.latex;
Prism.languages.context = Prism.languages.latex;
-})(Prism);
+}(Prism));
diff --git a/components/prism-naniscript.js b/components/prism-naniscript.js
index 7d797d9..9284cc8 100644
--- a/components/prism-naniscript.js
+++ b/components/prism-naniscript.js
@@ -167,4 +167,4 @@
}
}
-})(Prism);
+}(Prism));
diff --git a/components/prism-promql.js b/components/prism-promql.js
index 39761cf..f65c857 100644
--- a/components/prism-promql.js
+++ b/components/prism-promql.js
@@ -96,4 +96,4 @@
'operator': /[\^*/%+-]|==|!=|<=|<|>=|>|\b(?:and|unless|or)\b/i,
'punctuation': /[{};()`,.[\]]/,
};
-})(Prism);
+}(Prism));
diff --git a/components/prism-scheme.js b/components/prism-scheme.js
index a035d98..73195d7 100644
--- a/components/prism-scheme.js
+++ b/components/prism-scheme.js
@@ -118,4 +118,4 @@
return grammar[key];
}
-})(Prism);
+}(Prism));
diff --git a/components/prism-v.js b/components/prism-v.js
index 8a7cfde..4933340 100644
--- a/components/prism-v.js
+++ b/components/prism-v.js
@@ -76,4 +76,4 @@
}
}
});
-})(Prism);
\ No newline at end of file
+}(Prism));
\ No newline at end of file
diff --git a/docs/prism-core.js.html b/docs/prism-core.js.html
index b98ec14..bf2b13e 100644
--- a/docs/prism-core.js.html
+++ b/docs/prism-core.js.html
@@ -1213,7 +1213,7 @@ if (!_.manual) {
return _;
-})(_self);
+}(_self));
if (typeof module !== 'undefined' && module.exports) {
module.exports = Prism;
diff --git a/plugins/autolinker/prism-autolinker.js b/plugins/autolinker/prism-autolinker.js
index 62cd1e1..a5e4e8e 100644
--- a/plugins/autolinker/prism-autolinker.js
+++ b/plugins/autolinker/prism-autolinker.js
@@ -75,4 +75,4 @@ Prism.hooks.add('wrap', function(env) {
}
});
-})();
+}());
diff --git a/plugins/copy-to-clipboard/prism-copy-to-clipboard.js b/plugins/copy-to-clipboard/prism-copy-to-clipboard.js
index 4721a2f..73bd06e 100644
--- a/plugins/copy-to-clipboard/prism-copy-to-clipboard.js
+++ b/plugins/copy-to-clipboard/prism-copy-to-clipboard.js
@@ -157,4 +157,4 @@
linkCopy.setAttribute('data-copy-state', state);
}
});
-})();
+}());
diff --git a/plugins/custom-class/prism-custom-class.js b/plugins/custom-class/prism-custom-class.js
index 44b4ccf..a9a2326 100644
--- a/plugins/custom-class/prism-custom-class.js
+++ b/plugins/custom-class/prism-custom-class.js
@@ -89,4 +89,4 @@
});
});
-})();
+}());
diff --git a/plugins/download-button/prism-download-button.js b/plugins/download-button/prism-download-button.js
index b47030e..8a5bd90 100644
--- a/plugins/download-button/prism-download-button.js
+++ b/plugins/download-button/prism-download-button.js
@@ -17,4 +17,4 @@
return a;
});
-})();
+}());
diff --git a/plugins/file-highlight/prism-file-highlight.js b/plugins/file-highlight/prism-file-highlight.js
index 78c0def..59e5924 100644
--- a/plugins/file-highlight/prism-file-highlight.js
+++ b/plugins/file-highlight/prism-file-highlight.js
@@ -142,4 +142,4 @@
Prism.plugins.fileHighlight.highlight.apply(this, arguments);
};
-})();
+}());
diff --git a/plugins/highlight-keywords/prism-highlight-keywords.js b/plugins/highlight-keywords/prism-highlight-keywords.js
index 8743094..cb6b722 100644
--- a/plugins/highlight-keywords/prism-highlight-keywords.js
+++ b/plugins/highlight-keywords/prism-highlight-keywords.js
@@ -11,4 +11,4 @@ Prism.hooks.add('wrap', function(env) {
env.classes.push('keyword-' + env.content);
});
-})();
+}());
diff --git a/plugins/jsonp-highlight/prism-jsonp-highlight.js b/plugins/jsonp-highlight/prism-jsonp-highlight.js
index 605ee33..97c3cd2 100644
--- a/plugins/jsonp-highlight/prism-jsonp-highlight.js
+++ b/plugins/jsonp-highlight/prism-jsonp-highlight.js
@@ -275,4 +275,4 @@
}
};
-})();
+}());
diff --git a/plugins/line-highlight/prism-line-highlight.js b/plugins/line-highlight/prism-line-highlight.js
index 652bfeb..102fa73 100644
--- a/plugins/line-highlight/prism-line-highlight.js
+++ b/plugins/line-highlight/prism-line-highlight.js
@@ -328,4 +328,4 @@
actions.forEach(callFunction);
});
-})();
+}());
diff --git a/plugins/show-invisibles/prism-show-invisibles.js b/plugins/show-invisibles/prism-show-invisibles.js
index 152064e..e1f97f9 100644
--- a/plugins/show-invisibles/prism-show-invisibles.js
+++ b/plugins/show-invisibles/prism-show-invisibles.js
@@ -80,4 +80,4 @@
Prism.hooks.add('before-highlight', function (env) {
addInvisibles(env.grammar);
});
-})();
+}());
diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js
index 649f74d..264f592 100644
--- a/plugins/show-language/prism-show-language.js
+++ b/plugins/show-language/prism-show-language.js
@@ -270,4 +270,4 @@
return element;
});
-})();
+}());
diff --git a/plugins/toolbar/prism-toolbar.js b/plugins/toolbar/prism-toolbar.js
index 98ba900..b6c1f02 100644
--- a/plugins/toolbar/prism-toolbar.js
+++ b/plugins/toolbar/prism-toolbar.js
@@ -176,4 +176,4 @@
* Register the toolbar with Prism.
*/
Prism.hooks.add('complete', hook);
-})();
+}());
diff --git a/plugins/wpd/prism-wpd.js b/plugins/wpd/prism-wpd.js
index 140e18c..5d9ef01 100644
--- a/plugins/wpd/prism-wpd.js
+++ b/plugins/wpd/prism-wpd.js
@@ -163,4 +163,4 @@ function getLanguage(tag) {
return null;
}
-})();
+}());
diff --git a/prism.js b/prism.js
index d5ff4ef..e5024af 100644
--- a/prism.js
+++ b/prism.js
@@ -1165,7 +1165,7 @@ if (!_.manual) {
return _;
-})(_self);
+}(_self));
if (typeof module !== 'undefined' && module.exports) {
module.exports = Prism;
@@ -1771,4 +1771,4 @@ Prism.languages.js = Prism.languages.javascript;
Prism.plugins.fileHighlight.highlight.apply(this, arguments);
};
-})();
+}());
diff --git a/tests/run.js b/tests/run.js
index d3e38e6..6c88f87 100644
--- a/tests/run.js
+++ b/tests/run.js
@@ -37,5 +37,5 @@ for (const language in testSuite) {
});
}
});
- })(language, testSuite[language]);
+ }(language, testSuite[language]));
}