Using pretty-quick for beautification purpose
Prettier configuration and Eslint rules are affecting the node_modules. So, want to skip it.
Hence, 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.
Prettier's CLI ignores node_modules by default.
Use . prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
While this doesnt work for OP's example, one option is to add the prettier-ignore comment to the start of each line to be ignored, using the /* */ comment style, eg.
Prettier's CLI ignores node_modules by default.
We must only do the changes for staged files by passing --staged
to the existing command as shown below is the only solution i came up for now to move on.
"lint": "pretty-quick --staged & eslint "src/**/*.{js,jsx}" --quiet --fix"
According the npm package description, prettier ignores the files you wrote a path in .prettierrc
, .prettierignore
, and .editorconfig
.
You're gonna check it out below if you wanna know more.
https://www.npmjs.com/package/pretty-quick#configuration-and-ignore-files
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With