ESLint: Added no-var rule (#2837)
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
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}'.`);