-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
could import/no-extraneous-dependencies
get a path regex for dev deps?
#470
Comments
Yeah, something like that would be really helpful. I started with all my tests in I noticed lately that @jfmengels do I remember you mentioning that ESLint proper will allow file-path-regex-based config soon? It would be ideal to have first-party support for this. |
That has been discussed in eslint/eslint#3611 and eslint/eslint#5040. I get the feeling that that is definitely the direction that ESLint wants to go, but I would not go as far as It's definitely something to look forward to, as it would remove a lot of configuration problems.
Not sure what you mean with this, as this way of configuring would leave all the work to the user. Rules would be disabled or enabled differently where needed, and plugins won't have to do anything to support that. |
Right, yeah, in this case I meant ESLint proper is the first party, and we're the third party.
But yeah, if that's not soon... what if the flag values could be true/false/regex (string for YAML/json) and if regex, i.e. //.eslintrc.js or shared config
exports.rules = {
'import/no-extraneous-dependencies': [2, { devDependencies: /test|spec/ }],
} I'm think I'm just restating what you've suggested, in the interest of checking consensus. This would be simpler to implement than what I previously suggested a la |
That sounds great, and would help people using jest as well. Ideally the |
Could theoretically truncate to just the part after the CWD but in general, absolute paths tend to help avoid weird editor-linter integration issues and it's not obvious to me that Or is it? Am I off here? It would be more precise, certainly, but again, lots of issues with pathing when running inside of Sublime/Atom. |
Personally, I'd only want the top-level "test" directory exempted - in my repos, tests are never colocated with implementation, and thus I wouldn't want someone to make a "test" directory inside production code and suddenly have test-related linter rules applied. I'm not sure what issues you're thinking of - Sublime, at least, can use the project root, and |
I agree, I'd only want the top one as well, and it would be ideal to be that precise. And with some massaging, the Sublime issues can be resolved. I'm just playing it out on account of old scars from dealing with nonsense around the CWD. The absolute path to the file is well-known regardless of how/where/why/when the rule is being run. Sans-CWD would be the only way for |
Pivot: would a glob be better than regex? |
Frankly, I don't think this is something that we should take care of, as this is really related to configuring ESLint. The AVA and the Mocha plugins have managed to avoid this kind of setting until now. I think that putting an extra I'd at least contact the ESLint maintainers on the issue or on Gitter and ask them how far along it is before trying to implement this. |
@jfmengels that's what I do now, but that's not something I can specify in a shared config :-/ and because rule overrides aren't delta-based, but rather complete replacements, someone would have to dive into |
@jfmengels I think AVA and Mocha have an easier time detecting test files on account of having global identifiers to key off of (i.e. And dev deps transcend tests. I use a bunch of them in my I agree that it would be ideal that ESLint handle it, but a regex- or glob-flavored |
Some Mocha rules check the use of
Yeah, I get the pain of that. I don't know if this was discussed in the ESLint issue, but I hope that the recommended configurations from plugins and configs can specify globs. That should definitely be possible. Anyway, go ahead and do this if you want, I just hope that not many other rules will get similar requests. |
In the case when you wish to have your .spec.js file alongside implementation then to pass in an ignore regex would be useful. Otherwise it would be back to a separate test folder with an override .eslintrc |
Currently, the airbnb config only allows deps, and that means that everyone has to manually do something like https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/test/.eslintrc#L8-L10 for their tests.
It would be ideal if in the shared config, we could specify that folders named "test" or "spec", for example, could have dev deps, but nothing else. I think that would cover the majority use case and remove the need for most devs to have to override this rule.
The text was updated successfully, but these errors were encountered: