Comments (3)
This happens because prettier
itself prints nothing and returns with exit code 0 (success) when passed a file as a parameter that is matched by the .prettierignore
file.
This can be seen by running here:
mkdir test
cd test
npm init -y
echo "package.json" > .prettierignore
prettier package.json
# outputs nothing, goes straight to next prompt
mv .prettierignore .prettierignorebak
prettier package.json
# outputs this:
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
Since it returns empty without an error code, this condition is not caught by the if
here:
https://github.com/prettier/prettier-emacs/blob/master/prettier-js.el#L185
My elisp-fu is non-existent, but checking if prettier
's output isn't empty shouldn't be too hard, so I might try fixing it.
from prettier-emacs.
My immediate use case for .prettierignore
, which was avoiding formatting conflicts between npm
and prettier
on package.json
, has been resolved by prettier just special-casing for package.json
and package-lock.json
to match npm
's use of JSON.stringify(data, null, 2)
.
https://twitter.com/hsribei/status/1001560322082263040
I'll still see if I can make prettier-js-mode
not clobber other .prettierignore
d files in case that helps someone else.
from prettier-emacs.
Ok, nevermind. The whole issue is solved since December last year. It's always a good idea to keep your packages updated!
Now instead of returning an empty output for ignored files, prettier
just prints them back as-is, solving the problem.
from prettier-emacs.
Related Issues (20)
- How validate and format json HOT 1
- "No such file or directory" "prettier" Error HOT 1
- Using eslint_d to do the same as this package
- [question] "prettier-js is an available obsolete package."
- Disable formatting on save HOT 3
- prettier empties file HOT 1
- Could not apply prettier HOT 1
- diff error on OpenBSD
- prettier-js-mode reformats file even when file is in .prettierignore HOT 3
- "prettier errors: env: node: No such file or directory" HOT 6
- Highlighting "flickering" while applying formatting HOT 2
- Searching for program: No such file or directory, prettier HOT 2
- [warn] Ignored unknown option --stdin HOT 1
- Convenient way to disable per file HOT 1
- No files matching the pattern were found: "false". HOT 2
- Cannot find prettier anywhere HOT 2
- Prettier not formatting typescript file HOT 1
- do not respect .prettierignore
- Not working with prettier 3.0.1 HOT 2
- Handle cloned buffers and give error message when not visiting a file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettier-emacs.