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

feat(eslint): rename eslint.config.js to eslint.config.cjs to resolve them as CommonJS #29334

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Dec 12, 2024

This PR updates our generators to use eslint.config.cjs instead of eslint.config.js so that Node resolution will treat it as CommonJS. This solves an issue where having "type": "module" in package.json will result in an error when Node tries to resolve the config file as ESM.

Also allows us to clean up out Remix generators to not have to rename to eslint.config.cjs to solve the same issue.

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2024 2:26pm

@jaysoo jaysoo force-pushed the feat/eslint_config_cjs branch from 144e881 to 0fa0b93 Compare December 13, 2024 04:24
@jaysoo jaysoo force-pushed the feat/eslint_config_cjs branch from 0fa0b93 to 224a3ee Compare December 13, 2024 14:15
@jaysoo jaysoo force-pushed the feat/eslint_config_cjs branch from 224a3ee to 29bb7fe Compare December 13, 2024 14:45
@jaysoo jaysoo force-pushed the feat/eslint_config_cjs branch 4 times, most recently from 4506885 to b6aa8af Compare December 13, 2024 16:00
@jaysoo jaysoo force-pushed the feat/eslint_config_cjs branch from b6aa8af to 5d373e1 Compare December 13, 2024 18:23
@jaysoo jaysoo force-pushed the feat/eslint_config_cjs branch from 5d373e1 to 3126725 Compare December 13, 2024 19:28
@jaysoo jaysoo force-pushed the feat/eslint_config_cjs branch from 3126725 to 053838f Compare December 13, 2024 19:57
@jaysoo jaysoo marked this pull request as ready for review December 13, 2024 19:59
@jaysoo jaysoo requested review from a team and Coly010 as code owners December 13, 2024 19:59
@jaysoo jaysoo requested review from xiongemi and meeroslav December 13, 2024 19:59
Copy link

nx-cloud bot commented Dec 17, 2024

Your CI Pipeline Execution ↗ for commit 7713c79 is in progress ⏳

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 30m 53s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 1m View ↗
nx-cloud record -- nx format:check --base=0329c... ✅ Succeeded 32s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 25s View ↗
nx documentation --no-dte ✅ Succeeded 46s View ↗

☁️ Nx Cloud last updated this comment at 2024-12-18 14:56:39 UTC

@jaysoo jaysoo force-pushed the feat/eslint_config_cjs branch from f5c14e9 to 5606368 Compare December 17, 2024 18:50
@nrwl nrwl deleted a comment from nx-cloud bot Dec 17, 2024
Copy link
Collaborator

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

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

Mostly LGTM!

@@ -124,6 +124,10 @@ describe('ast-utils', () => {
]
}).map(config => ({
...config,
files: [
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't seem right? This will be setting files to only resolve cts and mts? Unless eslint is doing some magical merging behind the scenes?

Copy link
Member Author

Choose a reason for hiding this comment

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

This one specifically is when converting eslintrc to flat config when called from convertEslintJsonToFlatConfig. In those cases the .ts and .tsx extensions are already specified. I could add it to the ast utils as well just in case.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated it.

@jaysoo jaysoo force-pushed the feat/eslint_config_cjs branch from 5606368 to 7713c79 Compare December 18, 2024 14:19
@jaysoo jaysoo merged commit b9c0e3d into master Dec 18, 2024
6 checks passed
@jaysoo jaysoo deleted the feat/eslint_config_cjs branch December 18, 2024 21:34
ndcunningham pushed a commit that referenced this pull request Dec 20, 2024
… them as CommonJS (#29334)

This PR updates our generators to use `eslint.config.cjs` instead of
`eslint.config.js` so that Node resolution will treat it as CommonJS.
This solves an issue where having `"type": "module"` in `package.json`
will result in an error when Node tries to resolve the config file as
ESM.

Also allows us to clean up out Remix generators to not have to rename to
`eslint.config.cjs` to solve the same issue.

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants