Commit 158011e45af1090da50e8f33c15042e9e3b290e9

Michael Schmidt 2021-04-18T15:55:05

ESLint: Added wrap-iife rule (#2867)

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' &amp;&amp; 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]));
 }