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

How to ignore node_modules from pretty-quick #50

Open
hansiemithun opened this issue Nov 16, 2018 · 11 comments
Open

How to ignore node_modules from pretty-quick #50

hansiemithun opened this issue Nov 16, 2018 · 11 comments
Labels
question Further information is requested

Comments

@hansiemithun
Copy link

Tried creating .prettierignore file having node_modules defined inside it

Have config setup rule like this below:
`"lint": "pretty-quick & eslint "src/**/*.{js,jsx}" --quiet --fix"

Giving error as:

SyntaxError: Nested mappings are not allowed in compact mappings (8:9)
  6 | artifact: 'file://dcs.tar.gz'
  7 | deploymentStrategy: default
> 8 | config: artifact:
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 9 |
    | ^
    at e (/Users/mithha/Documents/dcs/ui/ui-plugins/dcs/node_modules/prettier/parser-yaml.js:1:323)
    at Object.parse (/Users/mithha/Documents/dcs/ui/ui-plugins/dcs/node_modules/prettier/parser-yaml.js:1:156977)
    at Object.parse$2 [as parse] (/Users/mithha/Documents/dcs/ui/ui-plugins/dcs/node_modules/prettier/index.js:7138:19)
    at coreFormat (/Users/mithha/Documents/dcs/ui/ui-plugins/dcs/node_modules/prettier/index.js:10398:23)
    at format (/Users/mithha/Documents/dcs/ui/ui-plugins/dcs/node_modules/prettier/index.js:10570:16)
    at formatWithCursor (/Users/mithha/Documents/dcs/ui/ui-plugins/dcs/node_modules/prettier/index.js:10582:12)
    at /Users/mithha/Documents/dcs/ui/ui-plugins/dcs/node_modules/prettier/index.js:34924:15
    at format (/Users/mithha/Documents/dcs/ui/ui-plugins/dcs/node_modules/prettier/index.js:34943:12)
    at exports.default (/Users/mithha/Documents/dcs/ui/ui-plugins/dcs/node_modules/pretty-quick/dist/formatFiles.js:18:41)
    at exports.default (/Users/mithha/Documents/dcs/ui/ui-plugins/dcs/node_modules/pretty-quick/dist/index.js:54:29)
✨  Done in 4.19s.

Also tried configuring like this:

"lint": "pretty-quick --ignore-path=.prettierignore & eslint \"src/**/*.{js,jsx}\" --quiet --fix"

But no luck :( Can anyone help?

@aleclarson
Copy link

Have you tried adding /node_modules/ to your .gitignore?

@mledom
Copy link

mledom commented Dec 28, 2018

@hansiemithun did you ever figure out what the issue was? I'm having the same issue and I can't figure out how ignore node_modules specifically node_modules/prettier/index.js

@kevinsar
Copy link

@aleclarson @hansiemithun did adding the directory to the .prettierignore file work? Or you can possibly try adding the flag --stage to only target staged files on commits. Those seem to work for me.

@hansiemithun
Copy link
Author

@mledom, @kevinsar - the .prettierignore did not work for me, I am doing the same. Staging necessary files. Not able to find a solution so far

@azz
Copy link
Member

azz commented Feb 21, 2019

@hansiemithun this is strange because pretty-quick gets files from git, which should never list node_modules (assuming node_modules is in .gitignore).

Could you run:

$ git ls-files --others --exclude-standard

and

$ git diff --name-only --diff-filter=ACMRTUB $(git merge-base HEAD master)

to check if they output any node_modules?

@hansiemithun
Copy link
Author

Error doing the second step: @azz - diff: unrecognized option --name-only'`

@azz
Copy link
Member

azz commented Feb 21, 2019

Sorry I edited my post. Missing the git.

@azz azz added the question Further information is requested label Mar 22, 2019
@hallya
Copy link

hallya commented Oct 8, 2019

@azz I have the same problem, node_modules is not print by any your commands. It is supposed to mean that my config is ok ?

@KenStipek
Copy link

I was able to get this to work by adding /node_modules to my .prettierignore, but I first had delete the pre-commit hook I had set up and reinstall it by reinstalling husky.
Documented in the hook:

You can reinstall it using 'npm install husky --save-dev' or delete this hook

@jellyfish-tom
Copy link

jellyfish-tom commented Feb 15, 2021

You probably are interested in prettiering only staged files. You can do that by passing --staged flag:

pretty-quick --staged

@JounQin
Copy link
Member

JounQin commented Jan 16, 2024

A minimal but runnable online reproduction is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

9 participants