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

Comments

Projects
None yet
8 participants
@osnoser1
Copy link

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 label Feb 4, 2018

@azz

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link

commented Apr 14, 2018

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

@IronSean

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Apr 30, 2018

@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

This comment has been minimized.

Copy link

commented Apr 30, 2018

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

This comment has been minimized.

Copy link
Owner

commented May 8, 2018

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

@sinedied

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Owner

commented May 8, 2018

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

const options = resolveConfig.sync(file, { config, editorconfig: true });

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

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

@mbrowne

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Collaborator

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 in #58 Jan 16, 2019

azz added a commit that referenced this issue Jan 16, 2019

fix: also use .prettierignore from current working directory (#14) (#58)
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
You can’t perform that action at this time.