Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Makes eslint the fastest linter on the planet.
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.
This will install the eslint_d
command globally:
$ npm install -g eslint_d
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.
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.
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
and
yarn.lock
. If changes are not automatically detected, remember to run
eslint_d restart
to bounce the background server.
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+ and 6.0+.
Control the server like this:
$ eslint_d <command>
Available commands:
start
: start the serverstop
: stop the serverstatus
: print out whether the server is currently runningrestart
: 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
.
Sublime: Check out SublimeLinter-contrib-eslint_d.
Vim: Install the syntastic plugin, then make sure this is in your
.vimrc
:
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_javascript_eslint_exec = 'eslint_d'
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.
Atom: You will not gain any performance from this module as it already avoids starting a new node instance and uses the API directly (see this AtomLinter issue).
Emacs: Use flycheck with the
javascript-eslint
checker:
(setq flycheck-javascript-eslint-executable "eslint_d")
If you're using eslint_d
in any other editor, please let us know!
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 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
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.
8.0.0
: eslint 4.0+, 5.0+ and 6.0+, node 8, 10 and 127.2.0
: eslint 4.0+ and 5.0+, node 6, 8 and 107.0.0
: eslint 5.4+, node 6, 8 and 106.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)MIT
8.1.1
Security patches.
2f0c21e
npm audit v6.8.x
fixture912818c
npm audit v6.0.x
fixture72ad6f5
npm audit v5.16.x
fixture706250e
npm audit v5.0.x
fixturec609c3a
npm audit v4.19.x
fixture4983414
npm audit v4.0.x
fixtureffb150a
npm audit6e0434e
Bump acorn from 7.1.0 to 7.1.1 in /test/fixture/v6.8.x (dependabot[bot])30f87d3
Bump acorn from 6.1.1 to 6.4.1 in /test/fixture/v6.0.x (dependabot[bot])414a697
Bump acorn from 6.4.0 to 6.4.1 in /test/fixture/v5.16.x (dependabot[bot])6e2fc82
Bump acorn from 6.1.1 to 6.4.1 in /test/fixture/v5.0.x (dependabot[bot])06a6144
Bump acorn from 6.1.1 to 6.4.1 (dependabot[bot])Released by Maximilian Antoni on 2020-03-21.
FAQs
Speed up eslint to accelerate your development workflow
The npm package eslint_d receives a total of 34,900 weekly downloads. As such, eslint_d popularity was classified as popular.
We found that eslint_d demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.