Git Product home page Git Product logo

Comments (14)

manveru avatar manveru commented on July 28, 2024 3

Seems like that works:

function! neoformat#formatters#javascript#prettiereslint() abort
    return {
        \ 'exe': 'prettier-eslint',
        \ 'args': ['--stdin'],
        \ 'stdin': 1,
        \ }
endfunction

from neoformat.

sbdchd avatar sbdchd commented on July 28, 2024 2

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.

sbdchd avatar sbdchd commented on July 28, 2024

Okay, I have added eslint --fix to the dev branch.

Can you check that it works accordingly?

Thanks!

from neoformat.

nhooyr avatar nhooyr commented on July 28, 2024

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.

nhooyr avatar nhooyr commented on July 28, 2024

Also, eslint --fix formats even with errors. You mentioned that it did not as a caveat in the commit message.

from neoformat.

fwip avatar fwip commented on July 28, 2024

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.

manveru avatar manveru commented on July 28, 2024

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.

nhooyr avatar nhooyr commented on July 28, 2024

@manveru #51 (comment)

Also, prettier is first so it will be run first and since it succeeds, eslint will not be run.

from neoformat.

manveru avatar manveru commented on July 28, 2024

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.

jondot avatar jondot commented on July 28, 2024

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.

manveru avatar manveru commented on July 28, 2024

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.

BenoitZugmeyer avatar BenoitZugmeyer commented on July 28, 2024

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.

daikikohara avatar daikikohara commented on July 28, 2024

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.

nhooyr avatar nhooyr commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.