Skip to content

use module aliases vs relative paths#3683

Open
DukeManh wants to merge 1 commit into
Seneca-CDOT:masterfrom
DukeManh:module-alias
Open

use module aliases vs relative paths#3683
DukeManh wants to merge 1 commit into
Seneca-CDOT:masterfrom
DukeManh:module-alias

Conversation

@DukeManh

@DukeManh DukeManh commented Oct 6, 2022

Copy link
Copy Markdown
Contributor

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

gitpod-io Bot commented Oct 6, 2022

Copy link
Copy Markdown

@RC-Lee

RC-Lee commented Oct 6, 2022

Copy link
Copy Markdown
Contributor

Search tests will fail while I'm updating ES

@humphd humphd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice improvement

Comment thread src/web/app/tsconfig.json
Comment on lines +18 to +26
"paths": {
"@components/*": ["components/*"],
"@hooks/*": ["hooks/*"],
"@styles/*": ["styles/*"],
"@theme": ["theme/index"],
"@translations/*": ["translations/*"],
"@config": ["config"],
"@interfaces": ["interfaces/index"]
}

@Kevan-Y Kevan-Y Oct 6, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

DukeManh commented Oct 6, 2022

Copy link
Copy Markdown
Contributor Author

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

@humphd

humphd commented Oct 31, 2022

Copy link
Copy Markdown
Contributor

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

@DukeManh

DukeManh commented Nov 3, 2022

Copy link
Copy Markdown
Contributor Author

@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.

@ghost ghost left a comment

Copy link
Copy Markdown

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.

5 participants