neutrinojs / neutrino

Create and build modern JavaScript projects with zero initial configuration.
https://neutrinojs.org
Mozilla Public License 2.0
3.94k stars 213 forks source link

ConfigurationError: Lint presets must be defined prior to any other presets in .neutrinorc.js. #1546

Closed kychanbi closed 4 years ago

kychanbi commented 4 years ago

following the doc on https://neutrinojs.org/packages/eslint/ configured to use my own .eslintrc.js still getting weeie

yarn start yarn run v1.22.4 $ webpack-dev-server --mode development --open

An error occurred when loading the Neutrino configuration.

ConfigurationError: Lint presets must be defined prior to any other presets in .neutrinorc.js.

 //.eslintrc.js
module.exports = {
    // Configure as you would normally when not using Neutrino:
    // https://eslint.org/docs/user-guide/configuring
    root: true,
    extends: 'eslint-config-airbnb',
    parser: 'babel-eslint',
    settings: {
        // ...
    },
    rules: {
        "quotes": [1, "double", { "avoidEscape": true }],
        "indent": [1, "tab"],
        "camelcase":[0 ] ,
        "no-tabs": [1, { allowIndentationTabs: true }],
        "react/jsx-indent":[1,"tab"],
        "jsx-wrap-multilines": [0, {
            "declaration": "parens",
            "assignment": "parens",
            "return": "parens",
            "arrow": "parens",
            "condition": "ignore",
            "logical": "ignore",
            "prop": "ignore"
        }]
    },
};
//neutrinorc.js
const airbnb = require('@neutrinojs/airbnb');
const reactComponents = require('@neutrinojs/react-components');
const jest = require('@neutrinojs/jest');
const eslint = require('@neutrinojs/eslint');

module.exports = {
  options: {
    root: __dirname,
  },
  use: [
    airbnb(),
    reactComponents(),
    jest(),
    eslint({
      eslint: {
        // Use own `.eslintrc.*` file for configuration instead.
        useEslintrc: true,
      },
    }),
  ],
};
edmorley commented 4 years ago

@kychanbi Hi! Sorry for the delayed reply.

The @neutrinojs/airbnb preset includes @neutrinojs/eslint, so @neutrinojs/eslint does not need to be added in addition to it.

To configure @neutrinojs/airbnb pass any options to airbnb() directly.

For example:

//neutrinorc.js

//...

module.exports = {
  //...
  use: [
    airbnb({
      eslint: {
        // Use own `.eslintrc.*` file for configuration instead.
        useEslintrc: true,
      },
    }),
    reactComponents(),
    jest(),
  ],
};

See: https://neutrinojs.org/packages/airbnb/#middleware-options

If there's any way we can make the docs clearer, please do say :-)