Skip to content

Conversation

@duailibe
Copy link
Collaborator

@duailibe duailibe commented May 15, 2019

Support folders in Prettier CLI, e.g. prettier --write . works

@kachkaev with the update of globby we were using, if nodeModulesDir doesn't exist, it crashes. Can you check if my update to the plugin resolution makes sense?

TODO:

  • add tests: assert it filters by extension, assert extensions provided by plugins are included
  • documentation
  • changelog

Closes #6085

@lydell

This comment has been minimized.

@duailibe

This comment has been minimized.

@lydell
Copy link
Member

lydell commented May 16, 2019

Nice!

  • So if you want to format all files Prettier is capable of handling in your project you can run just prettier --write .?
  • If you don't want Prettier to format .html files, you could add *.html to .prettierignore.
  • If you've taught Prettier how to handle other files/extensions in .prettierrc you have to list them manually. For example: prettier --write . .prettierrc "**/*.hehe". I guess this isn't super common.
.prettierrc
{
  "overrides": [
    {
      "files": ".prettierrc",
      "options": { "parser": "json" }
    },
    {
      "files": "*.hehe",
      "options": {
        "parser": "html"
      }
    }
  ]
}

@duailibe
Copy link
Collaborator Author

@lydell I'm not sure those were questions but the answers are:

  1. Yes! prettier --write **/** will still run in all files, regardless of their extensions
  2. Yes. I've thought about this and I think it's worth discussing after this PR lands. This is what config file doesn't work at the way other libraries do #2691 is asking
  3. Yes. That could also be fixed with the above (i.e. if we added a extensions: [] config)

@duailibe
Copy link
Collaborator Author

There's still something missing: match files by their filenames instead of their extensions. Luckily globby has an option for that.

I'll see how that goes tomorrow morning.

@duailibe duailibe added the status:wip Pull requests that are a work in progress and should not be merged label May 16, 2019
@duailibe
Copy link
Collaborator Author

Memory leak 😔

@kachkaev
Copy link
Member

Hi @duailibe 👋

I'm quite busy these days so won't be able to dive in, sorry for that. Perhaps @arcanis could help here? The situation when there is no node_modules is somewhat related to #5819, which he worked on.

@arcanis
Copy link
Contributor

arcanis commented May 16, 2019

Hey! Unfortunately I'm afraid I won't have much resources to spend on this anytime soon 😕

@duailibe
Copy link
Collaborator Author

duailibe commented May 16, 2019

@kachkaev Actually I'm more concerned about not erroring anymore, but that's okay :-)

@arcanis Don't worry about it!

@duailibe duailibe added this to the 2.0 milestone May 24, 2019
@duailibe
Copy link
Collaborator Author

So I ditched globby and wrote a little custom file finder. Obviously this is a breaking change I also included a change that this doesn't support negate patterns anymore, i.e. prettier --write foo/ !foo/bar/

We can continue to support it, but it was easier to drop and I judged this suits better in .prettierignore.

@duailibe
Copy link
Collaborator Author

@lydell what happens now is:

  • if you pass prettier --write 'foo/' it will only try to format supported files
  • if you pass prettier --write 'foo/**' it will try to format all files and will show that error on the unsupported files 🤷‍♂

@alexander-akait
Copy link
Member

@duailibe what is blocker? I think we should use same behavior as in eslint to better DX, i can investigate and put here information about how it is works in eslint

@duailibe
Copy link
Collaborator Author

duailibe commented Jun 7, 2019

@evilebottnawi not much.. we just need to iron everything out.

Also, this is a breaking change, so this will be in Prettier 2.0

@arcanis
Copy link
Contributor

arcanis commented Aug 19, 2019

Is there a way support for . in particular could be added without it being a breaking change, as a special case? Would you consider such a PR for a minor release?

@alexander-akait
Copy link
Member

/cc @lydell we can't move this to old 2.0, it is very important and it is breaking change, we should do this for 2.0

@lydell
Copy link
Member

lydell commented Nov 9, 2019

By “stretch” I meant “stretch goals.” If we have time we can do it. (Related: I have a new idea for the CLI/API that I’ll make an issue for soon.)

@alexander-akait
Copy link
Member

@lydell unfortunately we cannot stretch this issue because it is really a big change and important, i can take care

@lydell
Copy link
Member

lydell commented Nov 9, 2019

Of course we can wait doing this. Time’s up for making a breaking change. We literally can’t push 2.0 any longer into the future because supporting old Node.js undermines the whole project. So we can’t have 2.0 depend on this feature, because it is not super easy to do. But if you manage to do it before January that would of course be super awesome!

@alexander-akait
Copy link
Member

alexander-akait commented Nov 9, 2019

@lydell it is easy, i will send a PR at end of month ⭐

@sosukesuzuki
Copy link
Contributor

Can we release this in 2.0? postpone to 3.0?

@alexander-akait
Copy link
Member

@sosukesuzuki Yes we can, need continue work 😄 You can be champion

@sosukesuzuki
Copy link
Contributor

@evilebottnawi Okay, I'll work on this.

@alexander-akait
Copy link
Member

alexander-akait commented Feb 19, 2020

/cc @fisker Can you help with this? I think we need open a new PR, graceful for help

@fisker
Copy link
Member

fisker commented Feb 19, 2020

@evilebottnawi It seems I don't have too much time in next few days, and this seems a little tricky, may need more time.

Are we going to ship in v2?

@alexander-akait
Copy link
Member

@fisker yes, because it is will big breaking change and the next major version (3.0) will not be soon, so we should ship it for 2.0, don't worry, our release will not on this week

@fisker
Copy link
Member

fisker commented Feb 22, 2020

@evilebottnawi I'm sorry but I'm not be able to work on this, my wife is having a baby. Someone please take over.

@thorn0 thorn0 mentioned this pull request Feb 23, 2020
4 tasks
@thorn0
Copy link
Member

thorn0 commented Feb 24, 2020

@fisker Wow, that sounds like quite a long-term project. Please have a look at #7660 when you have a minute.

@thorn0
Copy link
Member

thorn0 commented Feb 25, 2020

Superseded by #7660

@thorn0 thorn0 closed this Feb 25, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

status:wip Pull requests that are a work in progress and should not be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support dot pattern for CLI

8 participants