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

Docs: Quickstart guide should be clear on type: module not being a requirement #9094

Open
2 tasks done
moltco opened this issue May 14, 2024 · 6 comments
Open
2 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue documentation Documentation ("docs") that needs adding/updating

Comments

@moltco
Copy link

moltco commented May 14, 2024

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

Improve the getting-started/Quickstart guide to mention that package.json must have "type":"module" otherwise the example will fail with import statement not being supported

Affected URL(s)

https://typescript-eslint.io/getting-started/

@moltco moltco added documentation Documentation ("docs") that needs adding/updating triage Waiting for maintainers to take a look labels May 14, 2024
@bradzacher
Copy link
Member

The reason we didn't specify this is because we treated it as assumed knowledge for using NodeJS.
I.e. if you want to use ESM you need to have type: module in your package.json - as has been the way with ESM support in NodeJS since its release.

My question here would be - do we need to tell people the constraints of NodeJS? Or are we okay to assume that people know "if you don't use ESM then you must translate this to CJS".

cc @typescript-eslint/triage-team thoughts?


With the release of eslint 8.57.0 we could update this guide to use .mjs (prior to minor 57 - it was not supported by eslint).

@auvred
Copy link
Member

auvred commented May 15, 2024

Personally I'm +1 on recommending using .mjs config file with small note that it requires ESLint >= 8.57.0.

Also see the related conversation on Discord: https://discord.com/channels/1026804805894672454/1207049165079846962/1213212499713728553

@kirkwaiblinger
Copy link
Member

+1 on calling out explicitly, and mentioning .mjs option.

@molt2020
Copy link

molt2020 commented May 15, 2024

I think it's important to mention +add external references.

A lot of people are just setting up the dev environment and may not be familiar with intricacies of the various stack options. Most how-to's start with do yarn add my-package so it's fair to point out anything that a noob will need.

Aim for bullet proof instructions for idiot users like me! 🙂

@JoshuaKGoldberg
Copy link
Member

Yeah, we need to be very careful to note that it's not a requirement to use a module type.

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels May 15, 2024
@JoshuaKGoldberg JoshuaKGoldberg changed the title Docs: quickstart guide to include requiement to have "type":"module" in package.json Docs: Quickstart guide should be clear on type: module not being a requirement May 15, 2024
@ericmorand
Copy link

@bradzacher this is not true:

I.e. if you want to use ESM you need to have type: module in your package.json

I understand that you mention the .mjs extension later in your post, but for the sake of correctness, I think you should update your comment to "I.e. if you want to execute a file ending by .js as ESM, one of the solution is to have type: module in your package.json".

A lot (and I mean a looooot) of people are convinced that the module declaration is mandatory to execute ESM modules. I think it is our duty to make it clear, as often as possible, that it is not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting prs Go ahead, send a pull request that resolves this issue documentation Documentation ("docs") that needs adding/updating
Projects
None yet
Development

No branches or pull requests

7 participants