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

feature: add tooling config #42

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

patinthehat
Copy link
Contributor

This PR adds a more robust tooling configuration:

  • opinionated prettier configuration
  • adds npm script format for running prettier folowed by eslint for optimal formatting
  • changes the typescript target to ESNext (it's 2024, commonJS is so 2023)
  • adds @ as a typescript path reference to allow for absolute imports within source files
  • demonstrates the use of import * from @/... in one typescript file to start

@@ -1,6 +1,6 @@
{
"compilerOptions": {
"module": "commonjs",
Copy link
Owner

Choose a reason for hiding this comment

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

As we talked about earlier, I don't think we can change this without first verifying its impact on older browsers. I'm not sure if/how esbuild will transpile esnext modules for the browser.

options: {
tabWidth: 2,
},
},
Copy link
Owner

Choose a reason for hiding this comment

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

Is the yaml override necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not necessary since 2 is the default. Nice catch 👍

},
];

module.exports = {
Copy link
Owner

Choose a reason for hiding this comment

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

When you ran prettier, where any of the source files significantly changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't - it's bad practice to commit formatting changes along with a PR that introduces actual changes; applying formatting would be a future PR.

@@ -13,7 +13,8 @@
"rootDir": "./",
"baseUrl": ".",
"paths": {
"*": ["types/*"]
"*": ["types/*"],
"@/*": ["./*"]
Copy link
Owner

Choose a reason for hiding this comment

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

Does this work for nested source files with relative imports from sibling or cousin directories?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works in any ts or js files in the source tree.

},
];

module.exports = {
Copy link
Owner

Choose a reason for hiding this comment

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

Are these settings consistent with the airbnb styles enforced by eslint? (Is there an airbnb plugin for prettier? [Are there plugins for prettier? 😅])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know, honestly. However, the format npm script runs eslint after prettier, so the airbnb rules would be enforced afaik. And yes, prettier does have plugins 😄

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

Successfully merging this pull request may close these issues.

2 participants