Commit f46938e9ae004e882979501e0ecdff5b0cf40947

Michael Schmidt 2021-04-17T22:35:25

ESLint: Added no-var rule (#2837)

diff --git a/.eslintrc.js b/.eslintrc.js
index 2552545..e01656d 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -4,6 +4,7 @@ module.exports = {
 	extends: 'eslint:recommended',
 	rules: {
 		// stylistic rules
+		'no-var': 'error',
 		'quotes': ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
 		'semi': 'warn',
 
@@ -48,6 +49,9 @@ module.exports = {
 			},
 			globals: {
 				'Prism': true
+			},
+			rules: {
+				'no-var': 'off'
 			}
 		},
 		{
@@ -70,6 +74,9 @@ module.exports = {
 			env: {
 				browser: true,
 				node: true
+			},
+			rules: {
+				'no-var': 'off'
 			}
 		},
 		{
@@ -88,6 +95,9 @@ module.exports = {
 				'$': true,
 				'$$': true,
 				'$u': true
+			},
+			rules: {
+				'no-var': 'off'
 			}
 		},
 		{
diff --git a/gulpfile.js/docs.js b/gulpfile.js/docs.js
index 0dcf919..7b23caf 100644
--- a/gulpfile.js/docs.js
+++ b/gulpfile.js/docs.js
@@ -25,8 +25,8 @@ function docsClean() {
 }
 
 function docsCreate(cb) {
-	var config = require(jsDoc.config);
-	var files = [jsDoc.readme].concat(jsDoc.files);
+	let config = require(jsDoc.config);
+	let files = [jsDoc.readme].concat(jsDoc.files);
 	src(files, { read: false }).pipe(jsdoc(config, cb));
 }
 
diff --git a/tests/aliases-test.js b/tests/aliases-test.js
index d62c61a..892cb50 100644
--- a/tests/aliases-test.js
+++ b/tests/aliases-test.js
@@ -27,7 +27,7 @@ for (const lang in languages) {
 
 		if (languages[lang].aliasTitles) {
 			it('- should have all alias titles registered as alias', function () {
-				var aliases = new Set(toArray(languages[lang].alias));
+				let aliases = new Set(toArray(languages[lang].alias));
 
 				Object.keys(languages[lang].aliasTitles).forEach(id => {
 					if (!aliases.has(id)) {
@@ -40,7 +40,7 @@ for (const lang in languages) {
 
 		it('- should known all aliases', function () {
 
-			var loadedLanguages = new Set(Object.keys(PrismLoader.createInstance(lang).languages));
+			let loadedLanguages = new Set(Object.keys(PrismLoader.createInstance(lang).languages));
 
 			// check that all aliases are defined
 			toArray(languages[lang].alias).forEach(alias => {
diff --git a/tests/helper/checks.js b/tests/helper/checks.js
index c667537..d1dba60 100644
--- a/tests/helper/checks.js
+++ b/tests/helper/checks.js
@@ -199,7 +199,7 @@ module.exports = (Prism) => {
 
 
 		root = root || Prism.languages;
-		var grammar = root[inside];
+		let grammar = root[inside];
 
 		if (typeof grammar !== 'object') {
 			throw new Error(`The grammar "${inside}" has to be an 'object' not '${typeof grammar}'.`);