| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 81c5382 commit 57198f2
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,8 +23,8 @@ const bindingModules = cryptoModules.concat(['tls_wrap']); | |||
| 23 | 23 | module.exports = function(context) { | |
| 24 | 24 | const missingCheckNodes = []; | |
| 25 | 25 | const requireNodes = []; | |
| 26 | - var commonModuleNode = null; | ||
| 27 | - var hasSkipCall = false; | ||
| 26 | + let commonModuleNode = null; | ||
| 27 | + let hasSkipCall = false; | ||
| 28 | 28 | ||
| 29 | 29 | function testCryptoUsage(node) { | |
| 30 | 30 | if (utils.isRequired(node, requireModules) || | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,8 @@ const msg = 'Please add a skipIfEslintMissing() call to allow this test to ' + | |||
| 14 | 14 | ||
| 15 | 15 | module.exports = function(context) { | |
| 16 | 16 | const missingCheckNodes = []; | |
| 17 | - var commonModuleNode = null; | ||
| 18 | - var hasEslintCheck = false; | ||
| 17 | + let commonModuleNode = null; | ||
| 18 | + let hasEslintCheck = false; | ||
| 19 | 19 | ||
| 20 | 20 | function testEslintUsage(context, node) { | |
| 21 | 21 | if (utils.isRequired(node, ['../../tools/node_modules/eslint'])) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,8 +15,8 @@ const msg = 'Please add a skipIfInspectorDisabled() call to allow this ' + | |||
| 15 | 15 | ||
| 16 | 16 | module.exports = function(context) { | |
| 17 | 17 | const missingCheckNodes = []; | |
| 18 | - var commonModuleNode = null; | ||
| 19 | - var hasInspectorCheck = false; | ||
| 18 | + let commonModuleNode = null; | ||
| 19 | + let hasInspectorCheck = false; | ||
| 20 | 20 | ||
| 21 | 21 | function testInspectorUsage(context, node) { | |
| 22 | 22 | if (utils.isRequired(node, ['inspector'])) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,8 @@ | |||
| 11 | 11 | module.exports = function(context) { | |
| 12 | 12 | const sourceCode = context.getSourceCode(); | |
| 13 | 13 | const regexpStack = []; | |
| 14 | - var regexpBuffer = []; | ||
| 15 | - var inRegExp = false; | ||
| 14 | + let regexpBuffer = []; | ||
| 15 | + let inRegExp = false; | ||
| 16 | 16 | ||
| 17 | 17 | function report(node, startOffset) { | |
| 18 | 18 | const indexOfDot = sourceCode.getIndexFromLoc(node.loc.start) + startOffset; | |
@@ -25,13 +25,13 @@ module.exports = function(context) { | |||
| 25 | 25 | ||
| 26 | 26 | const allowedModifiers = ['+', '*', '?', '{']; | |
| 27 | 27 | function checkRegExp(nodes) { | |
| 28 | - var escaping = false; | ||
| 29 | - var inCharClass = false; | ||
| 30 | - for (var n = 0; n < nodes.length; ++n) { | ||
| 28 | + let escaping = false; | ||
| 29 | + let inCharClass = false; | ||
| 30 | + for (let n = 0; n < nodes.length; ++n) { | ||
| 31 | 31 | const pair = nodes[n]; | |
| 32 | 32 | const node = pair[0]; | |
| 33 | 33 | const str = pair[1]; | |
| 34 | - for (var i = 0; i < str.length; ++i) { | ||
| 34 | + for (let i = 0; i < str.length; ++i) { | ||
| 35 | 35 | switch (str[i]) { | |
| 36 | 36 | case '[': | |
| 37 | 37 | if (!escaping) | |
@@ -96,7 +96,7 @@ module.exports = function(context) { | |||
| 96 | 96 | node.quasis.length); | |
| 97 | 97 | if (inRegExp && | |
| 98 | 98 | (isTemplate || (typeof node.value === 'string' && node.value.length))) { | |
| 99 | - var p = node.parent; | ||
| 99 | + let p = node.parent; | ||
| 100 | 100 | while (p && p.type === 'BinaryExpression') { | |
| 101 | 101 | p = p.parent; | |
| 102 | 102 | } | |
@@ -105,7 +105,7 @@ module.exports = function(context) { | |||
| 105 | 105 | p.callee.name === 'RegExp') { | |
| 106 | 106 | if (isTemplate) { | |
| 107 | 107 | const quasis = node.quasis; | |
| 108 | - for (var i = 0; i < quasis.length; ++i) { | ||
| 108 | + for (let i = 0; i < quasis.length; ++i) { | ||
| 109 | 109 | const el = quasis[i]; | |
| 110 | 110 | if (el.type === 'TemplateElement' && el.value && el.value.cooked) | |
| 111 | 111 | regexpBuffer.push([el, el.value.cooked]); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,7 @@ const utils = require('./rules-utils.js'); | |||
| 10 | 10 | module.exports = { | |
| 11 | 11 | create(context) { | |
| 12 | 12 | const sourceCode = context.getSourceCode(); | |
| 13 | - var assertImported = false; | ||
| 13 | + let assertImported = false; | ||
| 14 | 14 | ||
| 15 | 15 | function hasSameTokens(nodeA, nodeB) { | |
| 16 | 16 | const aTokens = sourceCode.getTokens(nodeA); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ const path = require('path'); | |||
| 12 | 12 | ||
| 13 | 13 | module.exports = function(context) { | |
| 14 | 14 | // trim required module names | |
| 15 | - var requiredModules = context.options; | ||
| 15 | + const requiredModules = context.options; | ||
| 16 | 16 | const isESM = context.parserOptions.sourceType === 'module'; | |
| 17 | 17 | ||
| 18 | 18 | const foundModules = []; | |
@@ -46,7 +46,7 @@ module.exports = function(context) { | |||
| 46 | 46 | * @returns {undefined|String} required module name or undefined | |
| 47 | 47 | */ | |
| 48 | 48 | function getRequiredModuleName(str) { | |
| 49 | - var value = path.basename(str); | ||
| 49 | + const value = path.basename(str); | ||
| 50 | 50 | ||
| 51 | 51 | // Check if value is in required modules array | |
| 52 | 52 | return requiredModules.indexOf(value) !== -1 ? value : undefined; | |
@@ -70,7 +70,7 @@ module.exports = function(context) { | |||
| 70 | 70 | const rules = { | |
| 71 | 71 | 'Program:exit'(node) { | |
| 72 | 72 | if (foundModules.length < requiredModules.length) { | |
| 73 | - var missingModules = requiredModules.filter( | ||
| 73 | + const missingModules = requiredModules.filter( | ||
| 74 | 74 | (module) => foundModules.indexOf(module) === -1 | |
| 75 | 75 | ); | |
| 76 | 76 | missingModules.forEach((moduleName) => { | |
@@ -86,15 +86,15 @@ module.exports = function(context) { | |||
| 86 | 86 | ||
| 87 | 87 | if (isESM) { | |
| 88 | 88 | rules.ImportDeclaration = (node) => { | |
| 89 | - var requiredModuleName = getRequiredModuleName(node.source.value); | ||
| 89 | + const requiredModuleName = getRequiredModuleName(node.source.value); | ||
| 90 | 90 | if (requiredModuleName) { | |
| 91 | 91 | foundModules.push(requiredModuleName); | |
| 92 | 92 | } | |
| 93 | 93 | }; | |
| 94 | 94 | } else { | |
| 95 | 95 | rules.CallExpression = (node) => { | |
| 96 | 96 | if (isRequireCall(node)) { | |
| 97 | - var requiredModuleName = getRequiredModuleNameFromCall(node); | ||
| 97 | + const requiredModuleName = getRequiredModuleNameFromCall(node); | ||
| 98 | 98 | ||
| 99 | 99 | if (requiredModuleName) { | |
| 100 | 100 | foundModules.push(requiredModuleName); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,7 @@ module.exports.isRequired = function(node, modules) { | |||
| 24 | 24 | * Return true if common module is required | |
| 25 | 25 | * in AST Node under inspection | |
| 26 | 26 | */ | |
| 27 | - var commonModuleRegExp = new RegExp(/^(\.\.\/)*common(\.js)?$/); | ||
| 27 | + const commonModuleRegExp = new RegExp(/^(\.\.\/)*common(\.js)?$/); | ||
| 28 | 28 | module.exports.isCommonModule = function(node) { | |
| 29 | 29 | return node.callee.name === 'require' && | |
| 30 | 30 | node.arguments.length !== 0 && | |
@@ -63,7 +63,7 @@ module.exports.usesCommonProperty = function(node, properties) { | |||
| 63 | 63 | * and the block also has a call to skip. | |
| 64 | 64 | */ | |
| 65 | 65 | module.exports.inSkipBlock = function(node) { | |
| 66 | - var hasSkipBlock = false; | ||
| 66 | + let hasSkipBlock = false; | ||
| 67 | 67 | if (node.test && | |
| 68 | 68 | node.test.type === 'UnaryExpression' && | |
| 69 | 69 | node.test.operator === '!') { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,24 +25,24 @@ if (process.argv.indexOf('-F') !== -1) | |||
| 25 | 25 | const cli = new CLIEngine(cliOptions); | |
| 26 | 26 | ||
| 27 | 27 | if (cluster.isMaster) { | |
| 28 | - var numCPUs = 1; | ||
| 28 | + let numCPUs = 1; | ||
| 29 | 29 | const paths = []; | |
| 30 | - var files = null; | ||
| 31 | - var totalPaths = 0; | ||
| 32 | - var failures = 0; | ||
| 33 | - var successes = 0; | ||
| 34 | - var lastLineLen = 0; | ||
| 35 | - var curPath = 'Starting ...'; | ||
| 36 | - var showProgress = true; | ||
| 30 | + let files = null; | ||
| 31 | + let totalPaths = 0; | ||
| 32 | + let failures = 0; | ||
| 33 | + let successes = 0; | ||
| 34 | + let lastLineLen = 0; | ||
| 35 | + let curPath = 'Starting ...'; | ||
| 36 | + let showProgress = true; | ||
| 37 | 37 | const globOptions = { | |
| 38 | 38 | nodir: true | |
| 39 | 39 | }; | |
| 40 | 40 | const workerConfig = {}; | |
| 41 | - var startTime; | ||
| 42 | - var formatter; | ||
| 43 | - var outFn; | ||
| 44 | - var fd; | ||
| 45 | - var i; | ||
| 41 | + let startTime; | ||
| 42 | + let formatter; | ||
| 43 | + let outFn; | ||
| 44 | + let fd; | ||
| 45 | + let i; | ||
| 46 | 46 | ||
| 47 | 47 | // Check if spreading work among all cores/cpus | |
| 48 | 48 | if (process.argv.indexOf('-J') !== -1) | |
@@ -169,7 +169,7 @@ if (cluster.isMaster) { | |||
| 169 | 169 | // We either just started or we have no more files to lint for the current | |
| 170 | 170 | // path. Find the next path that has some files to be linted. | |
| 171 | 171 | while (paths.length) { | |
| 172 | - var dir = paths.shift(); | ||
| 172 | + let dir = paths.shift(); | ||
| 173 | 173 | curPath = dir; | |
| 174 | 174 | const patterns = cli.resolveFileGlobPatterns([dir]); | |
| 175 | 175 | dir = path.resolve(patterns[0]); | |
@@ -188,7 +188,7 @@ if (cluster.isMaster) { | |||
| 188 | 188 | // workers busy most of the time instead of only a minority doing most of | |
| 189 | 189 | // the work. | |
| 190 | 190 | const sliceLen = Math.min(maxWorkload, Math.ceil(files.length / numCPUs)); | |
| 191 | - var slice; | ||
| 191 | + let slice; | ||
| 192 | 192 | if (sliceLen === files.length) { | |
| 193 | 193 | // Micro-optimization to avoid splicing to an empty array | |
| 194 | 194 | slice = files; | |
@@ -212,10 +212,10 @@ if (cluster.isMaster) { | |||
| 212 | 212 | const secs = `${elapsed % 60}`.padStart(2, '0'); | |
| 213 | 213 | const passed = `${successes}`.padStart(6); | |
| 214 | 214 | const failed = `${failures}`.padStart(6); | |
| 215 | - var pct = Math.ceil(((totalPaths - paths.length) / totalPaths) * 100); | ||
| 216 | - pct = `${pct}`.padStart(3); | ||
| 215 | + let pct = `${Math.ceil(((totalPaths - paths.length) / totalPaths) * 100)}`; | ||
| 216 | + pct = pct.padStart(3); | ||
| 217 | 217 | ||
| 218 | - var line = `[${mins}:${secs}|%${pct}|+${passed}|-${failed}]: ${curPath}`; | ||
| 218 | + let line = `[${mins}:${secs}|%${pct}|+${passed}|-${failed}]: ${curPath}`; | ||
| 219 | 219 | ||
| 220 | 220 | // Truncate line like cpplint does in case it gets too long | |
| 221 | 221 | if (line.length > 75) | |
@@ -229,7 +229,7 @@ if (cluster.isMaster) { | |||
| 229 | 229 | } else { | |
| 230 | 230 | // Worker | |
| 231 | 231 | ||
| 232 | - var config = {}; | ||
| 232 | + let config = {}; | ||
| 233 | 233 | process.on('message', (files) => { | |
| 234 | 234 | if (files instanceof Array) { | |
| 235 | 235 | // Lint some files | |
@@ -246,7 +246,7 @@ if (cluster.isMaster) { | |||
| 246 | 246 | // Silence warnings for files with no errors while keeping the "ok" | |
| 247 | 247 | // status | |
| 248 | 248 | if (report.warningCount > 0) { | |
| 249 | - for (var i = 0; i < results.length; ++i) { | ||
| 249 | + for (let i = 0; i < results.length; ++i) { | ||
| 250 | 250 | const result = results[i]; | |
| 251 | 251 | if (result.errorCount === 0 && result.warningCount > 0) { | |
| 252 | 252 | result.warningCount = 0; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments