-
-
Notifications
You must be signed in to change notification settings - Fork 30
False-positive for require-meta-docs-url
rule
#81
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
Comments
In general, it's nontrivial to detect whether a file contains a rule. I'd be open to improving the heuristic that we use, but the most robust way to avoid these errors would be to use glob configuration to only run |
I think you could just add a check that the export is an object literal, which rules have to be. That would solve my problem, as all the false-positive files export a function, not object. |
Rules can also be functions if they're created using the deprecated format. (Despite being deprecated, that format still seems to be somewhat common -- for example, all of Node's rules seem to use it.) |
I don't think this plugin should care about deprecated features. Actually, there should be a rule here that disallows deprecated features. Node is also not using this plugin. |
I'm aware that Node isn't using this plugin. I was just pointing it out as an example off the top of my head of a project that uses the deprecated rule format, as evidence for the claim that the deprecated format is still somewhat common. I think it would be reasonable to have a rule that disallows the deprecated rule format. Note that in some sense the |
That's not evidence that it's common. It's just evidence that at least one project is using the deprecated format.
Not if you use a helper utility in every rule to identify whether it's actually a (non-deprecated) proper rule file. For example, in
Would be better to actually fix the issue than to recommend a boilerplaty config workaround. Even if you insist on supporting the deprecated format, which IMHO makes no sense for a plugin meant to enforce plugin best practices, you could still detect a rule function vs a utility function by checking whether the first parameter name is |
Unfortunately, I don't have time to survey a very large sample of third-party ESLint rules to conclusively determine whether the deprecated format is common, so we're stuck with anecdotal evidence at this point. From what I've seen, the deprecated format is still relatively common to an extend that I wouldn't want the plugin to completely ignore files with rules in the deprecated format. (Even if the plugin's goal is to enforce best practices, it doesn't seem like it useful to simply ignore files containing deprecated rules, since this would effectively prevent people from noticing that they're not using best practices.)
To be clear, I was referring to the idea of having a rule that warns when it encounters the deprecated rule format. Naturally, a rule like this would need to be able to detect deprecated rule files, leading to the potential for false positives like the one you've reported in this issue.
Broadly speaking, I disagree that using I think something like the |
I'm getting:
For these files which are not rules: https://github.com/sindresorhus/eslint-plugin-unicorn/tree/master/rules/utils
Just remove https://github.com/sindresorhus/eslint-plugin-unicorn/blob/a7b1bdb8749d615ffdd05c87c7df3b971925abd8/package.json#L77-L84 and run
npm test
there to reproduce.The text was updated successfully, but these errors were encountered: