meteor / eslint-plugin-meteor

🧐 Meteor specific linting rules for ESLint
https://medium.com/@dferber90/8f229ebc7942
MIT License
118 stars 20 forks source link

Rule Proposal: Require absolute Imports #784

Closed carlo-quinonez closed 3 years ago

carlo-quinonez commented 3 years ago

Since Meteor imports absolute references from the project root, they're easier to deal with and scan. In my meteor projects, the imports end up a mix of absolute and relative paths. It's hard to fight this because generally absolute paths in imports are a TERRIBLE idea, but it's just another great example of how Meteor turn problems on their heads sometimes.

import module from '../../../api/database';
// vs
import module from '/imports/api/database';

Open to a PR?

dferber90 commented 3 years ago

Thanks for your suggestion and for asking upfront. This rule doesn't sound like it would be related to eslint-plugin-meteor as it doesn't concern Meteor itself. It might be better suited somewhere else. You might be able to use no-relative-parent-imports from eslint-plugin-import.

Sidenote I haven't used Meteor in quite a while, but Next.js has a similar feature. I usually end up with a mix of absolute and relative imports as well, but I don't see it as a problem. Absolute imports are great when you are referring to another logical module, and relative is great when multiple things form one logical unit and are colocated. It's a bit hard for me to judge as I'm not actively using Meteor anymore, but from my similar experience with Next.js I'd probably not want a rule like that.

I'll close this issue, let me know in case there's something I misunderstood. I really appreciate you offering to contribute!