-
Notifications
You must be signed in to change notification settings - Fork 734
ESLint - Require capture and custom message #3220
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
Conversation
@@ -85,8 +87,45 @@ module.exports = { | |||
} | |||
} | |||
|
|||
function reportDirectRequire(node, rule) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you use the utils as we've discussed? Did it not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the utils we saw do a little more than I need. They aggregate the components and variables from everywhere and all I need to do is just prohibit the usage of a library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not sound like a good enough reason to duplicate the code.
Using the util should remove a lot of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could use the utils some how but the code will be much uglier. It aggregates all the imports and returns an object. Checking the imports after that is kind of ugly because I will need to go over all the keys of the object and check if its in the rules. I guess I could do that but its not clear. I guess thats why it wasn't used in the import declaration before. I'm also not sure it will exactly do what I need and will not capture other cases as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will changing the usage in the ImportDeclaration
will be much different than in the VariableDeclarator
? Because you've already used it there.
@@ -85,8 +87,45 @@ module.exports = { | |||
} | |||
} | |||
|
|||
function reportDirectRequire(node, rule) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will changing the usage in the ImportDeclaration
will be much different than in the VariableDeclarator
? Because you've already used it there.
Description
Changelog
ESLint - Added require capture to the no-direct-import rule and custom message functionality.
Additional info
MADS-4434