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

format:check parses file excluded via .nxignore / .gitignore #18568

Closed
2 of 4 tasks
pongells opened this issue Aug 10, 2023 · 2 comments · Fixed by #18670
Closed
2 of 4 tasks

format:check parses file excluded via .nxignore / .gitignore #18568

pongells opened this issue Aug 10, 2023 · 2 comments · Fixed by #18670
Labels
community This is a good first issue for contributing outdated scope: misc Misc issues type: bug

Comments

@pongells
Copy link
Contributor

Current Behavior

Running nx format:check parses all files, even the ones that are excluded via .gitignore / .nxignore.

Expected Behavior

Ignored files should not be parsed by format:check

GitHub Repo

No response

Steps to Reproduce

  1. in the repository root create a file called do_not_check.mjs with some random text inside
  2. add the file to .nxignore
  3. run nx forrmat:check

Nx Report

Node   : 18.16.1
   OS     : darwin-arm64
   yarn   : 3.6.1
   
   nx                 : 16.6.0
   @nx/js             : 16.6.0
   @nx/linter         : 16.6.0
   @nx/workspace      : 16.6.0
   @nx/cypress        : 16.6.0
   @nx/devkit         : 16.6.0
   @nx/eslint-plugin  : 16.6.0
   @nx/react          : 16.6.0
   @nx/rollup         : 16.6.0
   @nx/vite           : 16.6.0
   @nx/web            : 16.6.0
   typescript         : 5.1.6
   ---------------------------------------

Failure Logs

No response

Operating System

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

Additional Information

Format is not filtering out ignored files in the patterns array:

https://github.com/nrwl/nx/blob/master/packages/nx/src/command-line/format/format.ts#L91

It can be easily fixed by adding the following:

import {getIgnoreObject} from "../../utils/ignore";
...
const nonIgnoredPatterns = getIgnoreObject().filter(patterns);

I'd create a PR but I am not sure this is the best way to fix the issue. Let me know.

@AgentEnder AgentEnder added the scope: misc Misc issues label Aug 11, 2023
@FrozenPandaz
Copy link
Collaborator

Sure, please open a PR. 🙏

@FrozenPandaz FrozenPandaz added the community This is a good first issue for contributing label Aug 15, 2023
pongells pushed a commit to pongells/nx that referenced this issue Aug 17, 2023
`nx format` commands will now correctly ignore
patterns defined in `.gitignore` or `.nxignore`
@github-actions
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 Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community This is a good first issue for contributing outdated scope: misc Misc issues type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants