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

fix(devkit): add missing parameter to prettier getFileInfo #9577

Conversation

danjor
Copy link
Contributor

@danjor danjor commented Mar 29, 2022

Current Behavior

When settings "ignorePath": "./.prettierignore" inside .prettierrc file, this is ignored when running nx generator as the second parameter of prettier.getFileInfo is missing, so formatFiles always format all the files and ignore is always false.

Expected Behavior

When setting "ignorePath": "./.prettierignore" inside .prettierrc file, this configuration should be taken into account when running nx generator as the second parameter of prettier.getFileInfo, so formatFiles formatFiles that are not ignored based on the config.

Related Issue(s)

Fixes #9576

@vercel
Copy link

vercel bot commented Mar 29, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nrwl/nx-dev/9gZL5Aw9ScS813StbkgwUvFwoK2m
✅ Preview: Canceled

[Deployment for bb6f1ea canceled]

@danjor danjor force-pushed the fix/fix-format-files-to-allow-ignoring-files-from-prettierrc branch from 0ee76ab to 8ff0358 Compare March 29, 2022 08:26
@danjor danjor force-pushed the fix/fix-format-files-to-allow-ignoring-files-from-prettierrc branch from 8ff0358 to 959dfcc Compare March 29, 2022 08:40
@@ -32,7 +32,7 @@ export async function formatFiles(tree: Tree): Promise<void> {
await Promise.all(
Array.from(files).map(async (file) => {
const systemPath = path.join(tree.root, file.path);
let options: Prettier.Options = {
let options: any = {
Copy link
Member

Choose a reason for hiding this comment

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

There's probably a different type we can use here. Can you try Prettier.FileInfoOptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error: packages/devkit/src/generators/format-files.ts:36:9 - error TS2322: Type '{ filepath: string; }' is not assignable to type 'FileInfoOptions'.
  Object literal may only specify known properties, and 'filepath' does not exist in type 'FileInfoOptions'.

36         filepath: systemPath,

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes. Try Prettier.Options & Prettier.FileInfoOptions

@danjor danjor force-pushed the fix/fix-format-files-to-allow-ignoring-files-from-prettierrc branch from 25ee660 to 11f6cf3 Compare March 29, 2022 13:45
@AgentEnder AgentEnder changed the title fix(core):add missing parameter to prettier getFileInfo fix(devkit): add missing parameter to prettier getFileInfo Mar 29, 2022
@danjor danjor force-pushed the fix/fix-format-files-to-allow-ignoring-files-from-prettierrc branch from 11f6cf3 to bb6f1ea Compare March 29, 2022 14:06
@AgentEnder AgentEnder merged commit c2c3cf5 into nrwl:master Mar 29, 2022
sidmonta pushed a commit to sidmonta/nx that referenced this pull request Apr 2, 2022
Co-authored-by: Jordan CALVI <jordan.calvi.external@atos.net>
@github-actions
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 Mar 18, 2023
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.

Nx formatFiles does not call prettier getFileInfo with FileInfoOptions
2 participants