-
-
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
Add a feature which warns if a path can be resolved to something less complex #784
Comments
If this gets a good response, i wouldn't mind implementing it myself. |
Duplicate of #776. |
#776 is about warning when excessive directory traversals are used in valid paths only. So you want a linting rule that forces use of webpack aliases when they are configured? I'm -1 on that rule mainly because I think webpack aliases are a horrible idea, but I won't block if other collabs think it would be useful. |
@ljharb I wouldn't say that it would be forcing webpack aliases. It's perfectly possible to have a webpack alias which is a longer path than the relative path. In this case the relative path should be preferred.
|
Is there any utility for this rule when not using webpack aliases? |
@ljharb not that i know of. Although i just started looking for one today. |
I'm a minus one on this as well. Sounds like a job for a Webpack-specific ESLint plugin. (which could totally use Thanks! |
@alasdairhurst You can force alias use by restricting all uses of Note: this won't handle enforcing using one alias over another to make the path shorter. E.g. |
For example, if have an import x from
'../../../x/y/z'
and it can be written more consisely:import x from 'z' (if you are in '/x/y')
there should be a rule letting me know. This should be auto-fixable as well.A better example for this could be when aliases are used and you have things like this all around your tests:
import * as authActions from '../../../../../src/components/pages/authentication/actions';
since the components dir is in my webpack config as an alias, it should warn me because i can write
import * as authActions from 'components/pages/authentication/actions';
instead.
The text was updated successfully, but these errors were encountered: