Nx: Should not format the dist folder

Created on 7 Jan 2020  路  6Comments  路  Source: nrwl/nx

_Please make sure you have read the submission guidelines before posting an issue_

Prerequisites

Please answer the following questions for yourself before submitting an issue.
YOU MAY DELETE THE PREREQUISITES SECTION.

  • [x] I am running the latest version
  • [x] I checked the documentation (nx.dev) and found no answer
  • [x] I checked to make sure that this issue has not already been filed
  • [x] I'm reporting the issue to the correct repository (not related to React, Angular or any dependency)

Expected Behavior

yarn format or nx format command should not format the files in dist folder.

Please describe the behavior you are expecting

Current Behavior

With the latest update yarn format commands formats the dist folder. previously it did not happen.

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

# on the previous version
ng build --prod --vendor-chunk
# to update
yarn update
# to format
yarn format

Context

I just updated the nx workspace and the format command formatted the dist directory.

  @nrwl/angular : 8.10.1
  @nrwl/cli : 8.10.1
  @nrwl/cypress : 8.10.1
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 8.10.1
  @nrwl/linter : 8.10.1
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : 8.10.1
  @nrwl/schematics : Not Found
  @nrwl/tao : 8.10.1
  @nrwl/web : 8.10.1
  @nrwl/workspace : 8.10.1
  typescript : 3.5.3

A minimal reproduction scenario allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem.

Failure Logs

Please include any relevant log snippets or files here.

Other

Any other relevant information that will help us help you.

core bug

Most helpful comment

@debuggerpk do you have the prettierignore file and what is in it?

The prettierignore file should contain /dist.

All 6 comments

@debuggerpk do you have the prettierignore file and what is in it?

The prettierignore file should contain /dist.

my prettier ignore file has

**/*.html

but it was like this even before the update. also the ngrx selectors and reducers files are now being formatted differently.

I think in recent update, the --affected feature is broken for formatting.
Format command attempts to format every possible file in the workspace. prettierignore does help, but we didn't have anything in the prettierignore file before the update. So I wonder, this is a bug in recent update?

i think @cngarkar has correctly diagnosed the issue.

Same here, I've upgraded to latest nx (v8.12.0) and started seeing dist folder being processed by the formatter, is it that nx used to load the .gitignore config to prettier?

I've observed some inconsistency in the way some of my files were formatted and @cngarkar's comment about the affected feature makes me think it might be related to this issue as well. What I observed is that after upgrading and running the format command some of my files were formatted differently (which I thought was because prettier was updated too), I committed the changes, ran the format command again and some of the same files were re-formatted but it produced a different output, it is mainly around boolean expressions, for example:

First pass:

-      (this.popoverRef && !this.popoverRef.overlayElement.contains(clickTarget))
+      this.popoverRef && !this.popoverRef.overlayElement.contains(clickTarget)

Second pass:

-      this.popoverRef && !this.popoverRef.overlayElement.contains(clickTarget)
+      this.popoverRef &&
+      !this.popoverRef.overlayElement.contains(clickTarget)

For now I've downgraded to v8.9.0 which doesn't have these issues.

@debuggerpk do you have the prettierignore file and what is in it?

The prettierignore file should contain /dist.

That worked for me!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MichaelWarneke picture MichaelWarneke  路  3Comments

ZempTime picture ZempTime  路  3Comments

vimalraj-a picture vimalraj-a  路  3Comments

elliotmendiola picture elliotmendiola  路  3Comments

Koslun picture Koslun  路  3Comments