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

Angular Library generator creates wrong eslint config with eslint.config.cjs at project root #28214

Closed
1 of 4 tasks
LWC241 opened this issue Oct 1, 2024 · 1 comment · Fixed by #28672
Closed
1 of 4 tasks
Assignees

Comments

@LWC241
Copy link

LWC241 commented Oct 1, 2024

Current Behavior

I am using "type": "module" in my package.json and have an eslint.config.cjs instead of eslint.config.js file at the root of my project.

When I try to create a library with the @nx/angular:library generator, the generator correctly finds the config file, but generates only a barebones eslint.config.js file in the new library:

Screenshot 2024-10-01 at 11 11 54

Expected Behavior

The generator should generate an eslint.config.cjs file and use the longer base config that it would generate with an eslint.config.js file at project root.

GitHub Repo

No response

Steps to Reproduce

  1. Generate a new NX Angular workspace
  2. Change the name of eslint.config.js to eslint.config.cjs
  3. Generate a new library with @nx/angular:library

Nx Report

NX   Report complete - copy this into the issue template

Node           : 20.15.1
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.7.0

nx                 : 19.8.2
@nx/js             : 19.8.2
@nx/jest           : 19.8.2
@nx/linter         : 19.8.2
@nx/eslint         : 19.8.2
@nx/workspace      : 19.8.2
@nx/angular        : 19.8.2
@nx/devkit         : 19.8.2
@nx/eslint-plugin  : 19.8.2
@nrwl/tao          : 19.8.2
@nx/web            : 19.8.2
@nx/webpack        : 19.8.2
typescript         : 5.4.5
---------------------------------------
Community plugins:
@ngrx/effects            : 18.0.1
@ngrx/operators          : 18.0.1
@ngrx/router-store       : 18.0.1
@ngrx/store              : 18.0.1
@ngrx/store-devtools     : 18.0.1
@testing-library/angular : 16.0.0
ng2-charts               : 3.1.2

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

I have looked into the code a bit and believe this may be an issue with the addLintingGenerator, as it will always generate an eslint.config.js file. There also is already a constant eslintFlatConfigFilenames, but it is not used when checking if the additional code should be added to the newly generated config file.

I would also be happy to try to make a PR for this.

@LWC241 LWC241 changed the title Angular Library generator creates wrong eslint config with eslint.config.cjs Angular Library generator creates wrong eslint config with eslint.config.cjs at project root Oct 1, 2024
jaysoo pushed a commit that referenced this issue Oct 31, 2024
…ors #28214 (#28672)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- 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 -->
When the workspace has `eslint.config.cjs` at the root, generation of
new lint projects currently does not check for it correctly


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Ensure utils continue to work as expected when `eslint.config.cjs` is
detected at the workspaceRoot

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

Fixes #28214
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

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

Successfully merging a pull request may close this issue.

2 participants