All Projects → mantoni → Eslint_d.js

mantoni / Eslint_d.js

Licence: mit
Makes eslint the fastest linter on the planet

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Eslint d.js

Themecreator
https://mswift42.github.io/themecreator/ create themes for intellij, textmate, atom, emacs, vim and gnome terminal.
Stars: ✭ 303 (-50.73%)
Mutual labels:  emacs, sublime
Lsp Mode
Emacs client/library for the Language Server Protocol
Stars: ✭ 3,691 (+500.16%)
Mutual labels:  eslint, emacs
Import Js
A tool to simplify importing JS modules
Stars: ✭ 511 (-16.91%)
Mutual labels:  emacs, sublime
Diff Hl
Emacs package for highlighting uncommitted changes
Stars: ✭ 553 (-10.08%)
Mutual labels:  emacs
Translatorx
JetBrains 系列软件汉化包 关键字: Android Studio 3.5 汉化包 CLion 2019.3 汉化包 DataGrip 2019.3 汉化包 GoLand 2019.3 汉化包 IntelliJ IDEA 2019.3 汉化包 PhpStorm 2019.3 汉化包 PyCharm 2019.3 汉化包 Rider 2019.3 汉化包 RubyMine 2019.3 汉化包 WebStorm 2019.3 汉化包
Stars: ✭ 4,856 (+689.59%)
Mutual labels:  webstorm
Linter Eslint
ESLint plugin for Atom Linter
Stars: ✭ 583 (-5.2%)
Mutual labels:  eslint
Nyxt
Nyxt - the hacker's power-browser.
Stars: ✭ 7,038 (+1044.39%)
Mutual labels:  emacs
Telega.el
GNU Emacs telegram client (unofficial)
Stars: ✭ 551 (-10.41%)
Mutual labels:  emacs
Node Express Mongodb Jwt Rest Api Skeleton
This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API). Demo of frontend in VueJS here: https://github.com/davellanedam/vue-skeleton-mvp
Stars: ✭ 603 (-1.95%)
Mutual labels:  eslint
Javascript Airbnb
Перевод «JavaScript Style Guide» от Airbnb
Stars: ✭ 579 (-5.85%)
Mutual labels:  eslint
Editorconfig Emacs
EditorConfig plugin for Emacs
Stars: ✭ 577 (-6.18%)
Mutual labels:  emacs
Racket Mode
Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, and more.
Stars: ✭ 559 (-9.11%)
Mutual labels:  emacs
Nyan Mode
Nyan Cat for Emacs! Nyanyanyanyanyanyanyanyanyan!
Stars: ✭ 590 (-4.07%)
Mutual labels:  emacs
Esprint
Fast eslint runner
Stars: ✭ 556 (-9.59%)
Mutual labels:  eslint
Rjsx Mode
A JSX major mode for Emacs
Stars: ✭ 604 (-1.79%)
Mutual labels:  emacs
Olivetti
Emacs minor mode for a nice writing environment
Stars: ✭ 554 (-9.92%)
Mutual labels:  emacs
Magithub
**This project is being (mostly) migrated into Forge!** -- Magit-based interfaces to GitHub
Stars: ✭ 592 (-3.74%)
Mutual labels:  emacs
Sublimehaskell
A Sublime Text 3 plugin for Haskell. Features cabal building, error and warning highlighting, smart completion and ghc-mod integration.
Stars: ✭ 574 (-6.67%)
Mutual labels:  sublime
God Mode
Minor mode for God-like command entering
Stars: ✭ 570 (-7.32%)
Mutual labels:  emacs
Meghanada Emacs
A Better Java Development Environment for Emacs
Stars: ✭ 582 (-5.37%)
Mutual labels:  emacs

eslint_d

Build Status SemVer License

Makes eslint the fastest linter on the planet.

"But eslint is pretty fast already, right?"

Yes, it's really fast. But the node.js startup time and loading all the required modules slows down linting times for a single file to ~700 milliseconds. eslint_d reduces this overhead by running a server in the background. It brings the linting time down to ~160 milliseconds. If you want to lint from within your editor whenever you save a file, eslint_d is for you.

Install

This will install the eslint_d command globally:

$ npm install -g eslint_d

Usage

To start the server and lint a file, just run:

$ eslint_d file.js

On the initial call, the eslint_d server is launched and then the given file is linted. Subsequent invocations are super fast.

How does this work?

The first time you use eslint_d, a little server is started in the background and bound to a random port. The port number is stored along with a token in ~/.eslint_d. You can then run eslint_d commands the same way you would use eslint and it will delegate to the background server. It will load a separate instance of eslint for each working directory to make sure settings are kept local. If eslint is found in the current working directories node_modules folder, then this version of eslint is going to be used. Otherwise, the version of eslint that ships with eslint_d is used as a fallback.

To keep the memory footprint low, eslint_d keeps only the last 10 used instances in the internal nanolru cache.

What if eslint or a plugin is updated?

The cached version of eslint and the Node require cache for the current working directory are cleared whenever a change to one of these files is detected: package.json, package-lock.json, npm-shrinkwrap.json, yarn.lock and pnpm-lock.yaml. If changes are not automatically detected, remember to run eslint_d restart to bounce the background server.

Which versions of eslint are supported?

As of v7.2.0, you can use eslint_d with multiple projects depending on different versions of eslint. Supported versions are 4.0+, 5.0+, 6.0+ and 7.0+.

Commands

Control the server like this:

$ eslint_d <command>

Available commands:

  • start: start the server
  • stop: stop the server
  • status: print out whether the server is currently running
  • restart: restart the server
  • [options] file.js [file.js] [dir]: invoke eslint with the given options. The eslint engine will be created in the current directory. If the server is not yet running, it is started.

Type eslint_d --help to see the supported eslint options.

eslint_d will select a free port automatically and store the port number along with an access token in ~/.eslint_d.

Editor integration

Linting

  • Vim:

    • With syntastic:

      let g:syntastic_javascript_checkers = ['eslint']
      let g:syntastic_javascript_eslint_exec = 'eslint_d'
      
    • With ale:

      let g:ale_javascript_eslint_executable = 'eslint_d'
      let g:ale_javascript_eslint_use_global = 1
      
  • WebStorm: Configure your IDE to point to the eslint_d package instead of eslint. In the ESLint configuration dialog, under 'ESLint package', select your eslint_d package.

  • Emacs: Use flycheck with the javascript-eslint checker:

    (setq flycheck-javascript-eslint-executable "eslint_d")
    
  • Sublime: Check out SublimeLinter-contrib-eslint_d. ⚠️ Please help resolving issue #120.

  • Atom, VSCode: You will not gain any performance from this module as these editors already cache eslint instances for you.

If you're using eslint_d in any other editor, please let us know!

Automatic Fixing

eslint_d has an additional flag that eslint does not have, --fix-to-stdout which prints the fixed file to stdout. This allows editors to add before save hooks to automatically fix a file prior to saving. It must be used with --stdin.

  • Vim: Add this to your .vimrc to lint the current buffer or visual selection on <leader>f:

    " Autofix entire buffer with eslint_d:
    nnoremap <leader>f mF:%!eslint_d --stdin --fix-to-stdout<CR>`F
    " Autofix visual selection with eslint_d:
    vnoremap <leader>f :!eslint_d --stdin --fix-to-stdout<CR>gv
    
  • Emacs: See eslintd-fix

  • If the above doesn't autofix: This can happen with .vue files
    Change eslint_d --stdin --fix-to-stdout to eslint_d --stdin --fix-to-stdout --stdin-filename % (% = path to file you want to autofix)
    In Vim, the above mapping should be replaced with:

    nnoremap <leader>f mF:%!eslint_d --stdin --fix-to-stdout --stdin-filename %<CR>`F
    

Moar speed

If you're really into performance and want the lowest possible latency, talk to the eslint_d server with netcat. This will also eliminate the node.js startup time.

$ PORT=`cat ~/.eslint_d | cut -d" " -f1`
$ TOKEN=`cat ~/.eslint_d | cut -d" " -f2`
$ echo "$TOKEN $PWD file.js" | nc localhost $PORT

Or if you want to work with stdin:

$ echo "$TOKEN $PWD --stdin" | cat - file.js | nc localhost $PORT

This runs eslint in under 50ms!

Tip For additional speed, did you know that you can lint only files that have changed? This is a feature of normal eslint, but it also works from eslint_d. Run:

$ eslint_d . --cache

References

If you're interested in building something similar to this: Most of the logic was extracted to core_d, a library that manages the background server.

Compatibility

  • 10.0.0: eslint 4.0+, 5.0+, 6.0+ and 7.0+, node 10, 12 and 14 (using new ESLint API if available)
  • 9.0.0: eslint 4.0+, 5.0+, 6.0+ and 7.0+, node 10, 12 and 14 (using CLIEngine API)
  • 8.0.0: eslint 4.0+, 5.0+ and 6.0+, node 8, 10 and 12
  • 7.2.0: eslint 4.0+ and 5.0+, node 6, 8 and 10
  • 7.0.0: eslint 5.4+, node 6, 8 and 10
  • 6.0.0: eslint 5.0+, node 6+ (eslint dropped node 4)
  • 5.0.0: eslint 4.0+
  • 4.0.0: eslint 3.0+, node 4+ (eslint dropped node 0.10 and 0.12)
  • 3.0.0: eslint 2.2+
  • 1.0.0, 2.0.0: eslint 1.4+, node 4 (and probably older)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].