You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Eli Perelman 1553c70161 README updates for v5 8 years ago
..
README.md README updates for v5 8 years ago
index.js Upgrading to webpack-chain v3, add more tests for full presets 8 years ago
package.json Moving peerDeps of deps to devDeps 8 years ago
yarn.lock Upgrading to webpack-chain v3, add more tests for full presets 8 years ago

README.md

Neutrino ESLint Middleware

NPM version NPM downloads Join Slack

neutrino-middleware-eslint is Neutrino middleware for linting source code using ESLint and eslint-loader.

Requirements

  • Node.js v6.9+
  • Yarn or npm client
  • Neutrino v5

Installation

neutrino-middleware-eslint can be installed via the Yarn or npm clients.

Yarn

❯ yarn add neutrino-middleware-eslint

npm

❯ npm install --save neutrino-middleware-eslint

Usage

neutrino-middleware-eslint can be consumed from the Neutrino API, middleware, or presets. Require this package and plug it into Neutrino:

const eslint = require('neutrino-middleware-eslint');

// Usage shows default values
neutrino.use(eslint, {
  test: /\.(js|jsx)$/,
  include: [], /* Should specify either include or exclude */
  exclude: [], /* Should specify either include or exclude */
  eslint: {
    failOnError: process.env.NODE_ENV !== 'development',
     emitWarning: process.env.NODE_ENV !== 'development',
     emitError: process.env.NODE_ENV !== 'development',
     cwd: neutrino.options.root,
     useEslintrc: false,
     root: true,
     plugins: ['babel'],
     baseConfig: {},
     envs: ['es6'],
     parser: 'babel-eslint',
     parserOptions: {
       ecmaVersion: 2017,
       sourceType: 'module',
       ecmaFeatures: {
         objectLiteralDuplicateProperties: false,
         generators: true,
         impliedStrict: true
       }
     },
     settings: {},
     globals: ['process'],
    rules: {}
  }
});
  • test: Test which files should be linted.
  • include: An array of paths to include in linting. Maps to Webpack's Rule.include
  • exclude: An array of paths to exclude from linting. Maps to Webpack's Rule.exclude
  • eslint: An ESLint CLIEngine configuration object for configuring ESLint. Use this to configure rules, plugins, and other ESLint options.

Customization

neutrino-middleware-eslint creates some conventions to make overriding the configuration easier once you are ready to make changes.

Rules

The following is a list of rules and their identifiers which can be overridden:

  • lint: By default, lints JS and JSX files from included directories using ESLint. Contains a single loader named eslint.

Information

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 middleware.


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.

eslintrc Config

neutrino-middleware-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 presets uses. If you keep this information in neutrino.presets in package.json, this should be relatively straightforward. By providing all the presets used to Neutrino, you can ensure all the linting options used across all presets will be merged together for your development environment, without the need for copying, duplication, or loss of organization and separation.

Example: Create a .eslintrc.js file in the root of the project.

// .eslintrc.js
const Neutrino = require('neutrino');
const pkg = require('./package.json');
const api = new Neutrino();

pkg.neutrino.presets.map(preset => neutrino.use(preset));

module.exports = api.eslintrc();

Contributing

This preset is part of the neutrino-dev repository, a monorepo containing all resources for developing Neutrino and its core presets. Follow the contributing guide for details.