diff --git a/lib/rules/all.js b/lib/rules/all.js index 39efb8b..82d5a55 100644 --- a/lib/rules/all.js +++ b/lib/rules/all.js @@ -21,8 +21,14 @@ function getAssignmentLeftHandSide(node) { for (const rule in rules) { const alternative = rules[rule].alternative; const ruleName = rules[rule].ruleName || kebabCase(rule); + const docs_url = rules[rule].docs_url || `https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore/blob/master/README.md#_${ruleName}` const forbiddenImports = { [`lodash/${rule}`]: 1, [`lodash-es/${rule}`]: 1, [`lodash.${rule.toLowerCase()}`]: 1 }; module.exports[ruleName] = { + meta: { + docs: { + url: docs_url, + }, + }, create(context) { return { CallExpression(node) { diff --git a/tests/lib/rules/all.js b/tests/lib/rules/all.js index d2a93cb..39f9242 100644 --- a/tests/lib/rules/all.js +++ b/tests/lib/rules/all.js @@ -108,10 +108,10 @@ ruleTester.run('_.first', rules['first'], { ], invalid: [{ code: '_.first([0, 1, 3])', - errors: ['Consider using the native Array.prototype.slice()'] + errors: ['Consider using the native Array.prototype.slice() or arr[0]'] }, { code: '_.first([0, 1, 3], 2)', - errors: ['Consider using the native Array.prototype.slice()'] + errors: ['Consider using the native Array.prototype.slice() or arr[0]'] }] });