From 9ee57515aebdc3ac1251b6f3652b163b9659072a Mon Sep 17 00:00:00 2001 From: Stephen Wade Date: Thu, 4 Mar 2021 21:26:27 -0500 Subject: [PATCH 1/8] Chore: Replace lodash.find with Array.prototype.find --- Makefile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.js b/Makefile.js index 840a51a86d7..fbfe864af8e 100644 --- a/Makefile.js +++ b/Makefile.js @@ -200,7 +200,7 @@ function generateRuleIndexPage() { recommended: rule.meta.docs.recommended || false, fixable: !!rule.meta.fixable }, - category = lodash.find(categoriesData.categories, { name: rule.meta.docs.category }); + category = categoriesData.categories.find(c => c.name === rule.meta.docs.category); if (!category.rules) { category.rules = []; From 675b4caff14f0db984b202d724e8dd5dbe415bdf Mon Sep 17 00:00:00 2001 From: Stephen Wade Date: Thu, 4 Mar 2021 21:36:10 -0500 Subject: [PATCH 2/8] Chore: Replace lodash.forEach with Array.prototype.forEach --- Makefile.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile.js b/Makefile.js index fbfe864af8e..6cffb770c64 100644 --- a/Makefile.js +++ b/Makefile.js @@ -13,8 +13,7 @@ require("shelljs/make"); -const lodash = require("lodash"), - checker = require("npm-license"), +const checker = require("npm-license"), ReleaseOps = require("eslint-release"), dateformat = require("dateformat"), fs = require("fs"), @@ -487,7 +486,7 @@ target.lint = function([fix = false] = []) { } echo("Validating JSON Files"); - lodash.forEach(JSON_FILES, validateJsonFile); + JSON_FILES.forEach(validateJsonFile); echo("Validating Markdown Files"); lastReturn = lintMarkdown(MARKDOWN_FILES_ARRAY); From ae74cb62f3b3dfb88ff4b96b6d8f3cde50187785 Mon Sep 17 00:00:00 2001 From: Stephen Wade Date: Thu, 4 Mar 2021 21:53:09 -0500 Subject: [PATCH 3/8] Chore: Replace lodash.map with Array.prototype.map --- lib/cli-engine/formatters/html.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cli-engine/formatters/html.js b/lib/cli-engine/formatters/html.js index 69f7395550f..5d4b7e56060 100644 --- a/lib/cli-engine/formatters/html.js +++ b/lib/cli-engine/formatters/html.js @@ -72,7 +72,7 @@ function renderMessages(messages, parentIndex, rulesMeta) { * @param {Object} message Message. * @returns {string} HTML (table row) describing a message. */ - return lodash.map(messages, message => { + return messages.map(message => { const lineNumber = message.line || 0; const columnNumber = message.column || 0; let ruleUrl; @@ -103,7 +103,7 @@ function renderMessages(messages, parentIndex, rulesMeta) { * @returns {string} HTML string describing the results. */ function renderResults(results, rulesMeta) { - return lodash.map(results, (result, index) => resultTemplate({ + return results.map((result, index) => resultTemplate({ index, color: renderColor(result.errorCount, result.warningCount), filePath: result.filePath, From 7ab18b98d0172420069554db5d8dd9007065b4d8 Mon Sep 17 00:00:00 2001 From: Stephen Wade Date: Thu, 4 Mar 2021 22:03:25 -0500 Subject: [PATCH 4/8] Chore: Replace lodash.isNil with Boolean negation --- lib/rule-tester/rule-tester.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rule-tester/rule-tester.js b/lib/rule-tester/rule-tester.js index 905f3418121..23b78fba279 100644 --- a/lib/rule-tester/rule-tester.js +++ b/lib/rule-tester/rule-tester.js @@ -427,12 +427,12 @@ class RuleTester { scenarioErrors = [], linter = this.linter; - if (lodash.isNil(test) || typeof test !== "object") { + if (!test || typeof test !== "object") { throw new TypeError(`Test Scenarios for rule ${ruleName} : Could not find test scenario object`); } requiredScenarios.forEach(scenarioType => { - if (lodash.isNil(test[scenarioType])) { + if (!test[scenarioType]) { scenarioErrors.push(`Could not find any ${scenarioType} test scenarios`); } }); From 5669cd30e258d5bb0ce3df7b6fc539ceaf874b5f Mon Sep 17 00:00:00 2001 From: Stephen Wade Date: Thu, 4 Mar 2021 22:13:55 -0500 Subject: [PATCH 5/8] Chore: Replace lodash.endsWith with String.prototype.endsWith --- lib/rules/eol-last.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rules/eol-last.js b/lib/rules/eol-last.js index fbba6c8f5e8..89c76acb202 100644 --- a/lib/rules/eol-last.js +++ b/lib/rules/eol-last.js @@ -54,7 +54,7 @@ module.exports = { }, LF = "\n", CRLF = `\r${LF}`, - endsWithNewline = lodash.endsWith(src, LF); + endsWithNewline = src.endsWith(LF); /* * Empty source is always valid: No content in file so we don't From 0b8735fed78a4835a6f661cee739532af9cd1b0b Mon Sep 17 00:00:00 2001 From: Stephen Wade Date: Thu, 4 Mar 2021 22:25:09 -0500 Subject: [PATCH 6/8] Chore: Replace lodash.includes with Array.prototype.includes --- lib/rules/lines-around-comment.js | 7 +++---- lib/rules/max-lines.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/rules/lines-around-comment.js b/lib/rules/lines-around-comment.js index 5e1b83cdd5d..6806e793cd1 100644 --- a/lib/rules/lines-around-comment.js +++ b/lib/rules/lines-around-comment.js @@ -8,8 +8,7 @@ // Requirements //------------------------------------------------------------------------------ -const lodash = require("lodash"), - astUtils = require("./utils/ast-utils"); +const astUtils = require("./utils/ast-utils"); //------------------------------------------------------------------------------ // Helpers @@ -347,7 +346,7 @@ module.exports = { const nextTokenOrComment = sourceCode.getTokenAfter(token, { includeComments: true }); // check for newline before - if (!exceptionStartAllowed && before && !lodash.includes(commentAndEmptyLines, prevLineNum) && + if (!exceptionStartAllowed && before && !commentAndEmptyLines.includes(prevLineNum) && !(astUtils.isCommentToken(previousTokenOrComment) && astUtils.isTokenOnSameLine(previousTokenOrComment, token))) { const lineStart = token.range[0] - token.loc.start.column; const range = [lineStart, lineStart]; @@ -362,7 +361,7 @@ module.exports = { } // check for newline after - if (!exceptionEndAllowed && after && !lodash.includes(commentAndEmptyLines, nextLineNum) && + if (!exceptionEndAllowed && after && !commentAndEmptyLines.includes(nextLineNum) && !(astUtils.isCommentToken(nextTokenOrComment) && astUtils.isTokenOnSameLine(token, nextTokenOrComment))) { context.report({ node: token, diff --git a/lib/rules/max-lines.js b/lib/rules/max-lines.js index 0c7e761fa61..ceb014aff71 100644 --- a/lib/rules/max-lines.js +++ b/lib/rules/max-lines.js @@ -151,7 +151,7 @@ module.exports = { ); lines = lines.filter( - l => !lodash.includes(commentLines, l.lineNumber) + l => !commentLines.includes(l.lineNumber) ); } From 6d9bf6e48b944c104222c34206e050e19d988a09 Mon Sep 17 00:00:00 2001 From: Stephen Wade Date: Thu, 4 Mar 2021 22:34:49 -0500 Subject: [PATCH 7/8] Chore: Replace lodash.some(o, fn) with Object.values(o).some(fn) --- lib/rules/object-curly-newline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rules/object-curly-newline.js b/lib/rules/object-curly-newline.js index 616d59851d6..c5c098e1301 100644 --- a/lib/rules/object-curly-newline.js +++ b/lib/rules/object-curly-newline.js @@ -82,7 +82,7 @@ function normalizeOptionValue(value) { function normalizeOptions(options) { const isNodeSpecificOption = lodash.overSome([lodash.isPlainObject, lodash.isString]); - if (lodash.isPlainObject(options) && lodash.some(options, isNodeSpecificOption)) { + if (lodash.isPlainObject(options) && Object.values(options).some(isNodeSpecificOption)) { return { ObjectExpression: normalizeOptionValue(options.ObjectExpression), ObjectPattern: normalizeOptionValue(options.ObjectPattern), From 02ea2613bb215b6b8716f5122340285afd185411 Mon Sep 17 00:00:00 2001 From: Stephen Wade Date: Thu, 4 Mar 2021 22:49:35 -0500 Subject: [PATCH 8/8] Chore: Replace lodash.isEmpty(o) with Object.keys(o).length === 0 --- lib/shared/runtime-info.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/shared/runtime-info.js b/lib/shared/runtime-info.js index feed005330e..3f16c9152e3 100644 --- a/lib/shared/runtime-info.js +++ b/lib/shared/runtime-info.js @@ -11,7 +11,6 @@ const path = require("path"); const spawn = require("cross-spawn"); -const { isEmpty } = require("lodash"); const log = require("../shared/logging"); const packageJson = require("../../package.json"); @@ -107,7 +106,7 @@ function environment() { * Checking globally returns an empty JSON object, while local checks * include the name and version of the local project. */ - if (isEmpty(parsedStdout) || !(parsedStdout.dependencies && parsedStdout.dependencies.eslint)) { + if (Object.keys(parsedStdout).length === 0 || !(parsedStdout.dependencies && parsedStdout.dependencies.eslint)) { return "Not found"; }