pretty-quick
pretty-quick copied to clipboard
How to ignore node_modules from pretty-quick
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?
Have you tried adding /node_modules/
to your .gitignore
?
@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
@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.
@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
@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
?
Error doing the second step: @azz - diff: unrecognized option
--name-only'`
Sorry I edited my post. Missing the git
.
@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 ?
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
You probably are interested in prettiering only staged files. You can do that by passing --staged flag:
pretty-quick --staged
A minimal but runnable online reproduction is required.