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

.prettierignore location #14

Closed
osnoser1 opened this issue Feb 4, 2018 · 10 comments · Fixed by #58
Closed

.prettierignore location #14

osnoser1 opened this issue Feb 4, 2018 · 10 comments · Fixed by #58
Labels
enhancement New feature or request

Comments

@osnoser1
Copy link

osnoser1 commented Feb 4, 2018

Hi, i have this problem:

My directory structure is:

root
  .git
  web-app
    package.json
    .prettierignore

In that package.json i have the script "format:fix": "pretty-quick --staged", however it is not taking the .prettierignore file. I have to place the file in the root folder of the repo so that it works.

Is there a way to avoid copying that file to the root of the repo and take the one inside the web-app folder?

@azz azz added the enhancement New feature or request label Feb 4, 2018
@azz
Copy link
Member

azz commented Feb 4, 2018

Hi, not currently, we'll have to either:

  1. search both the git dir and the working dir for .prettierignore, or
  2. add an --ignore-path CLI option

@DaviGao
Copy link

DaviGao commented Apr 14, 2018

@azz when .prettierignore and --ignore-path can use in project ?

@IronSean
Copy link

IronSean commented Apr 26, 2018

I have an issue I'm unsure is the same: I can't get my .prettierignore.js file to function anywhere. webpack is running in the same directory as the .prettierignore.js file, both which are two directories into my root git directory.

EDIT: nevermind, confirmed I have the same issue, even when my command is running from /{somepath}/myRepo/src/Web the pretty-quick command runs from /{somepath}/myRepo/ and the .prettierignore (not .js) must be there. So I'll watch this issue for a fix.

However I can only get it to work with this:

package.json
**/package.json

Either line on its own doesn't work.

@sinedied
Copy link

@azz what about adding a --configDir option that would be used for all prettier config files?

I have the same issue here, and the working dir workaround does not work with commits from IDE, so I think the best way would be an option to manually set the path for pretty-quick, or to go up folders from the pretty-quick folder itself, since most likely the node_modules folder will be in the desired config folder.

@lkounadis
Copy link

I have the same issue as osnoser1, for now I will place in root directory, but it would be ideal to be able to set the ignore-path just as prettier allows

@azz
Copy link
Member

azz commented May 8, 2018

How does your editor pickup your config files if pretty-quick cannot find them? Are you using WebStorm?

@sinedied
Copy link

sinedied commented May 8, 2018

@azz Yes, I'm using WebStorm and it picks up the files correctly.

Just in case, the folder structure looks like this, nothing too weird I think:

/ (git root)
  frontend/ (frontend root, prettier config files are there)
  backend/
  other/

@azz
Copy link
Member

azz commented May 8, 2018

Just checked the code, we only need --ignore-path as a CLI option as the config is loaded per-file:

https://github.com/azz/pretty-quick/blob/de790a757ecbc08b460ac3f4b20e780f63986bea/src/formatFiles.js#L8

So pretty-quick --staged --ignore-path=frontend/.prettierignore.

An issue with this is WebStorm might not know how to find your .prettierignore file.

@mbrowne
Copy link

mbrowne commented Sep 21, 2018

@IronSean I don't think a file named .prettierignore.js is valid. It has to be .prettierignore. (Although it would be nice if a JS module worked...would be a good way to configure multiple projects with the same ignore settings, since you can import other modules in JS files.)

@jantimon
Copy link
Collaborator

jantimon commented Jan 15, 2019

I created #58 in order to pickup the .prettierignore file from the current working directory too.

jantimon added a commit to jantimon/pretty-quick that referenced this issue Jan 15, 2019
jantimon added a commit to jantimon/pretty-quick that referenced this issue Jan 15, 2019
jantimon added a commit to jantimon/pretty-quick that referenced this issue Jan 15, 2019
@azz azz closed this as completed in #58 Jan 16, 2019
azz pushed a commit that referenced this issue Jan 16, 2019
This pull request tries to fix #14 with a zero config approach.

If the `process.cwd()` is not the same as the git root it will also try to load the .prettierignore file from there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants