neutrino icon indicating copy to clipboard operation
neutrino copied to clipboard

airbnb & standardjs presets cause warning if react is not used

Open davidje13 opened this issue 4 years ago • 2 comments

  • What version of Neutrino are you using? 9.4.0
  • Are you trying to use any presets? If so, which ones, and what versions? library + (airbnb or standardjs)
  • Are you using the Yarn client or the npm client? What version? npm 6.14.7
  • What version of Node.js are you using? 14.8.0
  • What operating system are you using? macOS 10.14.6
  • What did you do?

The minimal config:

const library = require('@neutrinojs/library');
const airbnb = require('@neutrinojs/airbnb');

module.exports = {
  options: { root: __dirname },
  use: [airbnb(), library({ name: 'foo' })],
};

package.json

  "scripts": {
    "build": "webpack --mode production"
  }

Produces a warning when npm run build is executed:

Warning: React version was set to "detect" in eslint-plugin-react settings,
but the "react" package is not installed. Assuming latest React version for linting.

This is because both the airbnb and standardjs packages bring in eslint-plugin-react, but this should not be used in projects which do not contain React: https://github.com/yannickcr/eslint-plugin-react/issues/1955#issuecomment-667553828

I'm not sure what the correct fix is here; maybe it's possible to programmatically disable this eslint plugin unless React is being used? Having to provide 2 separate copies of the packages (one with react and one without) doesn't seem like a great solution. The only other option I can think of is to leave it to the user to install the package if it is relevant to them.

It might be nice if the react version could be set to "none" in the eslint-plugin-react settings, but I don't know if they would be willing to add that feature since they've already said it simply shouldn't be installed in non-react projects.

davidje13 avatar Sep 19 '20 10:09 davidje13

@davidje13 Hi! The upstream AirBnB preset itself is designed to be React specific -- they have a base version without that, that Neutrino also offers: https://neutrinojs.org/packages/airbnb-base/

So if using AirBnB the solution is to use @neutrinojs/airbnb-base not @neutrinojs/airbnb. If using the Standard JS preset, then yeah I agree there isn't a great option at the moment.

To be honest the demand for the Standard JS preset is so low (and the style quite at odds with both AirBnB and prettier, that I could never recommend it), that I've been thinking of just removing the Neutrino preset for it and letting users add it manually using the @neutrinojs/eslint base preset if needed (it's only half a dozen lines in a NeutrinoJS).

edmorley avatar Oct 12 '20 08:10 edmorley

Fair enough. I only encountered this while testing my JS->TS lint rule rewriter with StandardJS, but I wouldn't use StandardJS in my own projects anyway.

davidje13 avatar Oct 12 '20 17:10 davidje13