diff --git a/Makefile.js b/Makefile.js index 840a51a86d7..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"), @@ -200,7 +199,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 = []; @@ -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); 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, 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`); } }); 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 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) ); } 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), 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"; }