Skip to content
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

Enforce consistent use of aliases #28

Open
brc-dd opened this issue Oct 9, 2023 · 3 comments
Open

Enforce consistent use of aliases #28

brc-dd opened this issue Oct 9, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@brc-dd
Copy link
Member

brc-dd commented Oct 9, 2023

Currently in our codebase we have all sort of import patterns like:

import foo from '../composables/Foo' // change to 👇
import foo from '@/composables/Foo'  // keep this
import foo from './Foo'              // maybe keep this too ? (same directory import)

Should we add a rule to make this consistent? There should be plugins available, or I can write one if we can reach a consensus.

track #37 too

@brc-dd brc-dd added the enhancement New feature or request label Oct 9, 2023
@cuebit
Copy link
Member

cuebit commented Oct 9, 2023

I think relative paths follow a pattern of scope and aliases are used when sourcing from deeply nested modules (often 2+ levels) or outside of current scope.

Naturally, this will derail over time due to lack of upkeep. I generally don’t like lint rules that enforce path behaviour as they can differ between libraries and projects. That said, if there’s a pattern that can be unified for consistency and one that can be agreed upon, it makes total sense.

@brc-dd
Copy link
Member Author

brc-dd commented Oct 9, 2023

can differ between libraries and projects

Ah, yeah, good point. Sefirot doesn't use path aliases though. Otherwise this would have broken stuff long ago as we don't compile it.

I generally don’t like lint rules that enforce path behaviour

😅 Let's see what others think. I don't have any strong preference though. I'm fine with keeping whatever seems good at the time of writing. 👍

@kiaking
Copy link
Member

kiaking commented Oct 16, 2023

Yeah, general rule is that we use ./ for importing modules that are in the same scope like importing another component from a component.

I think ../ rarely happens, but I'm sure they are somewhere does that 👀

Maybe most solid option would be to always enforce @/ ? Sefirot can be optional I guess since it's a package 🤔 But... in that case we must either compile sefirot, or just disable this rule only on Sefirot.

I don't mind making it consistent if everybody else wants it too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants