Neutrino Airbnb Base Preset
projects with Airbnb's base ESLint config, following the
- Zero upfront configuration necessary to start linting your project
- Modern Babel knowledge supporting ES modules, JSX (when used with React preset), Web and Node.js apps
- Highly visible during development, fails compilation when building for production
- Easily extensible to customize your project as needed
Note: If you are building a React project, you should probably use
- Node.js 10+
- Yarn v1.2.1+, or npm v5.4+
- Neutrino 9 and one of the Neutrino build presets
- webpack 4
- ESLint 6
The fastest way to get started is by using the
tool. See the
Create new project
docs for more details.
Don’t want to use the CLI helper? No worries, we have you covered with the manual installation.
First follow the manual installation instructions for your chosen build preset.
@neutrinojs/airbnb-base can be installed via the Yarn or npm clients. Inside
your project, make sure
eslint are development
dependencies. You will also be using another Neutrino preset for building your
application source code.
❯ yarn add --dev @neutrinojs/airbnb-base eslint
❯ npm install --save-dev @neutrinojs/airbnb-base eslint
After that, edit your project's
.neutrinorc.js to add the preset for linting
before your build preset. For example, when building your project using
const airbnbBase = ;const web = ;moduleexports =options:root: __dirnameuse:;
Start the app, then check your console for any linting errors. If everything is successful, you should see no errors in the console. ESLint errors visible during development are reported, but will still continue to build and serve your project. ESLint errors during build will not build the project, and will cause the command to fail.
❯ yarn startERROR in ./src/index.jsModule Error :error: Missing semicolon at src/index.js:35:51:33 |34 |> 35 | const MOUNT_NODE = document.getElementById| ^36 |37 |38 |1 error found.1 error potentially fixable with the `--fix` option.
❯ npm startERROR in ./src/index.jsModule Error :error: Missing semicolon at src/index.js:35:51:33 |34 |> 35 | const MOUNT_NODE = document.getElementById| ^36 |37 |38 |1 error found.1 error potentially fixable with the `--fix` option.
@neutrinojs/airbnb-base follows the standard
project layout specified by Neutrino.
This means that by default all project source code should live in a directory
src in the root of the project.
@neutrinojs/airbnb-base will cause errors to fail your build when
NODE_ENV is not
'development'. If you want to ease introduction of this
linting preset to your project, consider only adding it to your
during development until all linting errors have been resolved.
❯ yarn buildERROR in ./src/index.jsModule Error :error: Missing semicolon at src/index.js:35:51:33 |34 |> 35 | const MOUNT_NODE = document.getElementById| ^36 |37 |38 |1 error found.1 error potentially fixable with the `--fix` option.
Example: ease linting into project by only enabling when
const airbnbBase = ;const web = ;moduleexports =options:root: __dirnameuse: processenvNODE_ENV === 'development' ? : false;
This preset uses the same middleware options as @neutrinojs/eslint. If you wish to customize what is included, excluded, or any ESLint options, you can provide an options object with the middleware and this will be merged with our internal defaults for this preset.
Example: Extend from a custom configuration (it will be applied after Airbnb) and turn off semicolons from being required.
const airbnbBase = ;moduleexports =options:root: __dirnameuse:;
Exposing generated lint configuration via
@neutrinojs/eslint, from which this preset inherits, provides an
output handler for generating the ESLint configuration in a format suitable for
use in an
.eslintrc.js file. This allows the ESLint CLI to be used outside of
building the project, and for IDEs and text editors to provide linting
.eslintrc.js file in the root of the project, containing:
// .eslintrc.jsconst neutrino = ;moduleexports = ;
.eslintrc.js configuration will be automatically used when running the
ESLint CLI. For convenience a
lint script alias can be added to your
package.json, allowing linting to be run via
yarn lint or
npm run lint:
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 the
configuration. Instead you will need to create an
file that controls which files should be excluded from linting.
Using your own
If instead you would prefer to use your own non-generated
true. This will cause
@neutrinojs/airbnb-base to only
set the loader-specific configuration defaults, and leave all other linting
configuration to be managed by the standalone
for more details.
To override the lint configuration, start with the documentation on
@neutrinojs/airbnb-base creates some conventions to make overriding the
configuration easier once you are ready to make changes.
The following is a list of rules and their identifiers which can be overridden:
||By default, lints JS and JSX files from the