Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

airbnb & standardjs presets cause warning if react is not used #1622

Closed
davidje13 opened this issue Sep 19, 2020 · 2 comments
Closed

airbnb & standardjs presets cause warning if react is not used #1622

davidje13 opened this issue Sep 19, 2020 · 2 comments

Comments

@davidje13
Copy link
Contributor

  • 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: jsx-eslint/eslint-plugin-react#1955 (comment)

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.

@edmorley
Copy link
Member

@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).

@davidje13
Copy link
Contributor Author

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.

@edmorley edmorley closed this as completed Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants