Skip to content

feature: add tooling config#42

Open
patinthehat wants to merge 3 commits intomicchickenburger:mainfrom
patinthehat:add-tooling-config
Open

feature: add tooling config#42
patinthehat wants to merge 3 commits intomicchickenburger:mainfrom
patinthehat:add-tooling-config

Conversation

@patinthehat
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

"paths": {
"*": ["types/*"]
"*": ["types/*"],
"@/*": ["./*"]
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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