Coder Social home page Coder Social logo

prettier-eslint_d's Introduction

prettier-eslint_d

Format your JavaScript files with prettier and eslint, fast

Status

prettier-eslint_d allows you to use Prettier and Eslint together, and use them fast. It spawns them as daemons, so any subsequent calls will be as fast as possible. Great for integrating into editors like Emacs and Vim!

⚠️ EXPERIMENTAL - Use at your own risk.

Installation

First, add an Eslint config to your project. prettier-eslint_d assumes you have an .eslintrc or .eslintrc.json in your project.

Install it via yarn or npm:

yarn add --dev prettier-eslint_d

You can then use prettier-eslint_d in the same way you may be using prettier:

# Fix one file
yarn run prettier-eslint_d --write path/to/file.js

# Fix many files
yarn run prettier-eslint_d --write 'scripts/**/*.js'

# Fix via stdin/stdout (great for editors)
cat path/to/script.js | ./node_modules/.bni/prettier-eslint_d --stdin

For more options, see node_modules/.bin/prettier-eslint_d --help.

Adding scripts

Your setup may vary, but I recommend having check and fix commands in a project. You can add these to your package.json:

/* package.json */
{
  "scripts": {
    "prettier:check": "prettier-eslint --list-different 'src/**/*.js'",
    "prettier:fix": "prettier-eslint --write 'src/**/*.js'"
  }
}

Add yarn run prettier:check in your CI script to ensure that files checked in are formatted properly. You can run yarn run prettier:fix to fix up all files.

Spacemacs installation

See: https://gist.github.com/rstacruz/a2361d000a88e49472c4419116edaccf

Also see

This project integrates the following other projects:

Related discussions:

Thanks

prettier-eslint_d © 2018+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz

 

prettier-eslint_d's People

Contributors

rstacruz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

prettier-eslint_d's Issues

Sometimes calling prettier-eslint_d with --stdin flag yeilds blank output

I'm working on a function for emacs to use the suggested for editors command cat path/to/script.js | ./node_modules/.bni/prettier-eslint_d --stdin and have found that occasionally the command returns blank output. What I've incorporated into emacs then tees the output to the file and re-loads it, but sometimes the file is replaced with blank since the output of the command is blank as well.

TODO list

Dumping a todo list here:

  • --eslint-config-path support
  • Support for w0rp/ale
  • Instructions for (neo)vim

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.