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
Turn off import/no-absolute-path #1535
Comments
I'll move this to the eslint-config-standard repo. |
Thank you, @HoraceShmorace. Actually, this is the repository where rules are discussed. This seems like it would be a popular enough use case to consider disabling this rule. I personally would not like to go through that documentation. But I would like the issue confirmed. |
I too would prefer this rule is removed from standard. What is the problem with absolute paths anyway? They are valid. In my web projects, this rule prevents me importing npm-installed ES modules like this: import something from '/node_modules/something/index.mjs' Instead, the rule forces me to use messy and brittle relative paths (which need fixing if the source file changes directory): import something from '../../../../../node_modules/something/index.mjs' It is common for absolute paths to be used in web projects (for example |
I agree that this is a bit prescriptive, but this doesn't seem like a common issue so it seems like a perfect use case for using a disable comment as explained here: https://standardjs.com/#how-do-i-disable-a-rule How many others have run into this issue? |
I just realized that this rule is applying for browser imports too. Given that, I feel more strongly that this should be disabled now. We wouldn't want to prevent referring to a module file by absolute paths. That's totally fine in a browser context. |
What about an option to choose a context instead of disabling this rule completely? This rule maybe helpful in Node.js context but certainly not in browser context.
From: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md |
Reasonable suggestion, but we don't want to add options like this to |
This comment was marked as abuse.
This comment was marked as abuse.
@AbducteeZero you comment doesn't add anything of value at all, and instead just insults the people working on this project. Clearly there was grounds for adding the rule when it was added, and now more information have come to light and it it seems like removing it is the best path forward.... |
This comment was marked as abuse.
This comment was marked as abuse.
i think this is a valid issue affecting lots of devels and needs to be resolved . for this reason i think ill migrate off standard |
What about adding some config, where you can specify to skip this rule for a specific path tamplate, like |
What version of this package are you using?
14.3.1
What problem do you want to solve?
This rule can't be used with projects that involve AWS Lambda Functions that reference custom code in Lambda Layers. Layer code MUST be imported relative to the root (
'/opt/[layer path]'
), which is an absolute path.I've finally gotten our teams to use Standard for almost every project, zero customizations. Now I'm getting pushback because of this issue. We could disable that rule inline, but if you have to turn a rule off 20 times, then is it a worthwhile rule?
I'm sure someone will suggest that we just figure out the relative path (even though AWS's official docs say to use the absolute path), but then we'll be making assumptions about the current and (more importantly) future state of a filesystem we have no control over, and could likely change, breaking our services.
What do you think is the correct solution to this problem?
Turn this rule off. If it can't be a best practice everywhere, then it's not worthwhile.
Are you willing to submit a pull request to implement this change?
Sure
The text was updated successfully, but these errors were encountered: