Neutrino ESLint Middleware
@neutrinojs/eslint is Neutrino middleware for linting source code using ESLint and eslint-loader.
- Node.js v6 LTS, v8, v9
- Yarn v1.2.1+, or npm v5.4+
- Neutrino v8
@neutrinojs/eslint can be installed via the Yarn or npm clients.
❯ yarn add @neutrinojs/eslint
❯ npm install --save @neutrinojs/eslint
@neutrinojs/eslint can be consumed from the Neutrino API, middleware, or presets. Require this package
and plug it into Neutrino:
// Using function middleware formatconst eslint = ;// Usage shows default valuesneutrino;
test: Test which files should be linted.
include: An array of paths to include in linting. Maps to webpack's
exclude: An array of paths to exclude from linting. Maps to webpack's
eslint: An ESLint CLIEngine configuration object for configuring ESLint. Use this to configure rules, plugins, and other ESLint options.
@neutrinojs/eslint creates some conventions to make overriding the configuration easier once you are ready to
The following is a list of rules and their identifiers which can be overridden:
|Name||Description||Environments and Commands|
||By default, lints JS and JSX files from included directories using ESLint. Contains a single loader named
By default this middleware will show errors and warnings in the console during development, and will cause a failure when creating a build bundle.
If you want your preset or middleware to also extend from another ESLint configuration or preset that you have made
a dependency, you must use
baseConfig.extends rather than just
extends. This is a limitation of ESLint, not this
This middleware only configures a target environment for
es6, leaving other build middleware free to add their own
target environments. If your middleware puts restrictions on which environments it is capable of running, please
document that clearly in your middleware.
This is the recommended way to perform a one-off lint in a Neutrino project.
You can also have Neutrino invoke ESLint for you if you wish to perform a one-time lint. This avoids needing to install
ESLint manually, creating a
.eslintrc.js file, or having to manage includes and ignores. As long as the ESLint
middleware is loaded, you have access to a command to run ESLint from the command line.
This middleware registers a command named
lint which programmatically calls ESLint and prints the results to
❯ neutrino lint
❯ neutrino lint --fix
If you cannot or do not wish to use Neutrino to execute one-off linting, you can still use ESLint manually.
@neutrinojs/eslint also provides a method for getting the ESLint configuration suitable for use in an eslintrc
file. Typically this is used for providing hints or fix solutions to the development environment, e.g. IDEs and text
editors. Doing this requires creating an instance of the Neutrino API and providing the
middleware it uses. If you keep all this information in a
.neutrinorc.js, this should be relatively straightforward. By
providing all the middleware used to Neutrino, you can ensure all the linting options used across all middleware will be
merged together for your development environment, without the need for copying, duplication, or loss of organization and
This middleware registers another command named
eslintrc which returns an ESLint configuration object suitable for
consumption by the ESLint CLI. Use the Neutrino API's
call method to invoke this command:
Example: Create a .eslintrc.js file in the root of the project, using
// .eslintrc.jsconst Neutrino = ;// Specify middleware to Neutrino prior to calling eslintrc.// Even if using .neutrinorc.js, you must specify it when using// the APImoduleexports =;
Example: Create a .eslintrc.js file in the root of the project, using specified middleware.
// .eslintrc.jsconst Neutrino = ;moduleexports =;
If you are able, only use a
.eslintrc.js file for editor hints, and use the Neutrino
lint command for one-off linting
or fixes. Loading ESLint configuration from
.eslintrc.js that is not
.neutrinorc.js or uses configuration that
.neutrinorc.js could lead to unintended consequences such as linting not failing or passing when expected,
or working differently when running different commands. Closely evaluate whether you actually need to make these rule
Projects may face a problem when their editor or IDE lints all files and highlights errors that were normally excluded
from source, i.e. Neutrino's
exclude options. This is because the ESLint CLI does not have a way to
specify included and excluded files from configuration. If you still wish to use ESLint's CLI for linting, consider
setting CLI flags or using an
eslintignore to choose which files to
include or exclude from linting.
Unfortunately ESLint does not provide the possibility to configure ignored paths from Neutrino configuration and exclude them
from linting. Projects authors should define this manually in their project root directory in a
.eslintignore file. This
is one of the main reasons to prefer using the
lint CLI command with this middleware, as it avoids a lot of manual
configuration and boilerplate.
ESLint will exclude built files and any files in the root directory (e.g. custom Neutrino configuration) but
test folders will be still checked.
node_modules are ignored by default in ESLint. More information can be found
in the ESLint user guide.