-
Notifications
You must be signed in to change notification settings - Fork 60
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
Skip commented-out requires #45
Comments
I dig this idea. I took a quick look at strip-comments, and two things came to mind: (1) performance, but maybe it's not so bad; (2) strip-comments doesn't seem maintained anymore, not that it matters for the node-detective use case, but it removes comment-like things from strings (doesn't inspire confidence). Any other ideas? I'd be awesome to be able to skip files if we can. |
Not sure about other solutions. We can write our own solution that would do this on per-line iteration basis. Nothing fancy. |
I must be misunderstanding something; how does Detective report those as requires when it uses the AST? Also, I don't get that when I try it with |
@jmm, I think the OP is a bit misworded. The output is the same regardless of version (correctly |
@zertosh Ah, gotcha, thanks for the explanation. I knew about that test, but I didn't connect the dots because I misinterpreted "parses" in the OP. I was also thrown off by the inclusion of the legit
Do you think it'd make sense to do the fast check, then, if that was positive, strip the comments and try it again? |
This is a pretty bad bug, and is easily encountered: // eslint-disable-next-line require-jsdoc
function foo() {} /**
* Does foo.
* @example
* const foo = require('foo')
* foo()
*/
export default function foo() {} This issue appears to cause documentationjs/documentation#1090. |
The issue there is that detective doesn't support JSX or ES modules syntax. It should not be run on JSX or ES modules files in the first place. |
@goto-bus-stop no, the point I'm making in this issue here is that people often use JSDoc |
This issue is not about a bug but an optimization. Implementing the optimization would only hide the issue you're describing, not fix it. It would pop back up the moment someone uses a string that contains 'require', or uses a method named |
This is the repo description:
If this causing a false positive is not a bug, then I don't know what is… // eslint-disable-next-line require-jsdoc There is clearly no call to I'm happy to be corrected if I'm confused, or misdiagnosed something 😕 |
It doesn't detect that detective('// require("xyz")')
// → []
detective('require("xyz")')
// → ["xyz"] The The issue you're seeing is that a file containing JSX or ES modules is being passed to detective. If the file doesn't contain e; see #45 (comment) |
Bingo! That makes sense to me now, thanks :) I was thinking it was reporting the actual strings. |
Currently detective parses these as valid requires even though they are not.
maybe with https://github.com/jonschlinkert/strip-comments
The text was updated successfully, but these errors were encountered: