Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add meta doc urls #337

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/rules/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ ruleTester.run('_.first', rules['first'], {
],
invalid: [{
code: '_.first([0, 1, 3])',
errors: ['Consider using the native Array.prototype.slice()']
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule.alternative change shouldn't since it is outside the scope of the primary change. Also, to a lesser extent it no longer (two years later 😅) exists within this file either- and so this commit is the cause of the merge conflict

Copy link

@binury binury Apr 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(but -good news- the equivalent change you made was later added here)

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]']
}]
});

Expand Down