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

use module aliases vs relative paths #3683

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DukeManh
Copy link
Contributor

@DukeManh DukeManh commented Oct 6, 2022

When the project grows deeper, more ../ are required in the relative import paths to import modules so this configs TS path aliases, that map to certain absolute paths.

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

Steps to test the PR

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@gitpod-io
Copy link

gitpod-io bot commented Oct 6, 2022

@RC-Lee
Copy link
Contributor

RC-Lee commented Oct 6, 2022

Search tests will fail while I'm updating ES

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement

Comment on lines +18 to +26
"paths": {
"@components/*": ["components/*"],
"@hooks/*": ["hooks/*"],
"@styles/*": ["styles/*"],
"@theme": ["theme/index"],
"@translations/*": ["translations/*"],
"@config": ["config"],
"@interfaces": ["interfaces/index"]
}
Copy link
Contributor

@Kevan-Y Kevan-Y Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit): I personally prefer using like @/components/* instead of @components/*. So it doesn't get confused if we have a external package like @components

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @Kevan-Y here. I also use the @/components/* for module aliases

@DukeManh
Copy link
Contributor Author

DukeManh commented Oct 6, 2022

We'd need to fix #3690 first to pass eslint.

@humphd
Copy link
Contributor

humphd commented Oct 31, 2022

@DukeManh do you want this in before tonight (end of Hacktoberfest)? If so, what does it need?

@DukeManh
Copy link
Contributor Author

DukeManh commented Nov 3, 2022

@humphd, I needed to add 'plugin:@typescript-eslint/recommended' for eslint to pass but then found out there is more work to do in #3690 if I make that change.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

The only nit-picky thing that might be considered, that some projects prefer the scoped package inports to be between the "traditional" library imports and the relative imports for readability reasons.

@manekenpix manekenpix force-pushed the master branch 16 times, most recently from a51adae to 94eec21 Compare December 3, 2022 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants