Comments (14)
Seems like that works:
function! neoformat#formatters#javascript#prettiereslint() abort
return {
\ 'exe': 'prettier-eslint',
\ 'args': ['--stdin'],
\ 'stdin': 1,
\ }
endfunction
from neoformat.
When eslint --fix
encounters an error, it outputs a non-zero status code, which means Neoformat won't update the buffer with the changed data.
from neoformat.
Okay, I have added eslint --fix
to the dev branch.
Can you check that it works accordingly?
Thanks!
from neoformat.
It's not working because eslint cannot find its configuration file. It cannot use a tempfile, it needs the path to the actual file. Or if you want to use a temp file, make the temp file in the same directory as the original file, this will allow eslint to find the configuration file.
The configuration file is a dotfile that is stored with the original js file.
from neoformat.
Also, eslint --fix
formats even with errors. You mentioned that it did not as a caveat in the commit message.
from neoformat.
Another option is to let neoformat look for the config file and supply it to eslint with the --config
option. You'd probably have to implement the complicated rules they use to find the right configuration file, though: http://eslint.org/docs/user-guide/configuring#configuration-file-formats
from neoformat.
Just tried the dev
branch, but even with
let g:neoformat_enabled_javascript = ['prettier', 'eslint']
NeoFormat just ignores the eslint
formatter and only runs the prettier
one. There's no output regarding eslint
with debug on either. Any idea why that might happen?
from neoformat.
Also, prettier is first so it will be run first and since it succeeds, eslint will not be run.
from neoformat.
OK, but shouldn't it at least give some output of trying to run eslint? I'm going to build a formatter based on https://www.npmjs.com/package/prettier-eslint-cli now, that should also get around the config file problem.
from neoformat.
thanks @manveru that works. I would still wait out for just eslint --fix since prettier has a strong opinion about how code that is linted OK should be formatted which I don't like, and it adds a considerable overhead for CPU that eslint already takes :(
from neoformat.
Yeah, I totally understand, just thought it might help other people like me that need both combined anyway. On my machine at least, I don't notice any performance issues, saving (which is when I run the formatter) is almost instant. It might depend on the rules you specify for eslint?
from neoformat.
After reading about this issue, I made a ESLint fork to support fixing code from stdin, allowing it to be used as a neoformat formatter. It worked great for me so far. This may not be a long term solution but it may interest those who want to use ESLint as a formatter without Prettier. I'm open to suggestions!
from neoformat.
I'm using the prettier-eslint solution.
But stdin option doesn't seem to ignore files in .eslintignore.
Does anyone know the workaround for that?
from neoformat.
Going to close as it has been a long time and I'm not sure if this is relevant anymore.
from neoformat.
Related Issues (20)
- `.swiftformat` config not detected
- clang-format used when formatter fails in some filetypes
- [Solved] fprettify makes nvim buffer empty HOT 1
- C# clang-format with Microsoft style broken HOT 1
- truncating files HOT 1
- Pyi files
- Clang-format doesn't use the style config file closest to the file's location
- Formatting F# buffer replaces it with error message
- g:neoformat_only_msg_on_error not working correctly
- Topiary support HOT 1
- Monorepo project root determination
- Adding `eslint_d` as valid formatter for another filetype, like "Vue" HOT 3
- .clang-format file is ignored when style is specified to file
- Configuration on neovim use lua HOT 1
- Add dprint as a formatter HOT 2
- Add ruff formatter for Python HOT 3
- Format only changed lines
- clang-format not work
- Please start tagging releases or remove the old tags
- formatters prettierd, eslint_d failed
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 neoformat.