Javascript: npm@3 warn missing eslint-plugin-react a non react project

Created on 22 Feb 2016  ·  37Comments  ·  Source: airbnb/javascript

Seems like eslint-plugin-react was moved to peer dependency, and now I'm getting

├── UNMET PEER DEPENDENCY eslint-plugin-react@^4.0.0

I'm using eslint-config-airbnb/base, for a non react project.

How can I get rid of this warning _without_ installing eslint-plugin-react?
Is there any plan for splitting /base to a separate package?

question

Most helpful comment

All 37 comments

At the moment, you don't. In order to do that, and not lose the benefit of having it as a peer dep for those using react (like Airbnb), we'd have to make two separate packages "core" and "react", and set up the deps that way.

That would be quite complex - you can just ignore that warning, though?

I'll have to ignore it...
But it will cost my sanity.

Thanks for the fast reply!

Given the two options, I'd rather have people in your scenario get the warning rather than people who are using it for react _not_ getting the warning.

I'll leave this open for the time being, because this definitely isn't ideal.

Same issue here, but the warning prevents my CI service (Codeship) from deploying my application, so I'll have to add the dependency even if not used.

@jguepin why would you need dev deps (like a linter config) when deploying to production?

@ljharb you're right, it was the default behavior but I should change that :)

:( I'm also getting this warning too

@ljharb There's still an issue with it, and it's not just about ignoring the warning...

npm shrinkwrap will fail for any projects without the react plugin.. It doesn't make sense to install the react plugin in a non react project :/

If we do split the base into a separate package (which is probably the cleanest solution to this problem), I'd likely want to make a scoped package under @airbnb. Is anyone still using npm v1.x (which doesn't support scoped packages) such that this would be a problem?

I don't believe that anyone is using npm v1.x

npm v1?! Uh.. Node 0.10 uses npm v2.x, isn't it?

No, node v0.10 comes with v1.4.29.

(fwiw until recently, Airbnb was on node 0.10 and npm 1.x, so this isn't a far-fetched scenario)

Indeed. The stable version is now 5.7 and the LTS is 4.3, so I think we can easily remove the support for 0.10 for the next version of the config.
node 0.12, which was the most used version is using npm 2

Both 0.10 and 0.12 retain official support through the end of the year and April 2017 respectively - and 0.10 was used _far far_ more than 0.12 ever was (very few people ever used it, because they were waiting for the io.js issue to settle).

It's relatively trivial to update npm to 2.x on node 0.10, so I'll probably not worry about it, but it's a legit concern and it's worth bringing up.

The official recommended version for front-end is node v5, don't know if it can help us to move forward

@josmardias i assume you mean for your company, as there's no "official recommended version" for _everyone_ :-)

I misinterpreted this paragraph, sorry, my bad.

Node.js v5 is an intermediate feature release line that is best suited for users who have an easier time upgrading their Node.js installations, such as developers using the technology for front-end toolchains.

https://nodejs.org/en/blog/community/node-v5/#introduction-to-node-js-v5

Actually it states that should be easy to upgrade on the front-end, not that it's recommended.

I suggested solution in sibling issue #588, but will duplicate it here:

I'm suggesting to eslint-config-airbnb in three packages:

  • /base will become eslint-config-airbnb with removed /legacy inside
  • /legacy will become eslint-config-airbnb-legacy
  • eslint will become eslint-config-airbnb-react, extended by eslint-config-airbnb with eslint-plugin-react in deps. (not sure eslint will pickup eslint-plugin-react from here, but it should)

so every consumer will get proper amount of rules and deps

eslint-config-airbnb will always contain React, since it will always reflect what Airbnb uses.

@ljharb thats fine, then just add eslint-plugin-react to deps.

But please make reactjs-agnostic config for pure nodejs consumers and name it like eslint-config-airbnb-base.

My case is that i'm developing pure commonjs modules and i would like to use airbnb config, but i dont need react specific rules and i believe i'm not alone

That is indeed the idea

Also discussed with a proposal here - https://github.com/airbnb/javascript/pull/455#issuecomment-128103763

@ljharb thats great, not quite sure how that will work with eslint naming convention but if it will work out pls go ahead

@ljharb any news on this issue?

@iamstarkov scoped packages don't work well with shrinkwrap, and we'd rather not airbnb--prefix a bunch of public packages, so I'm still trying to decide what the best approach is.

It looks like v7.0.0 added _another_ peerDependency of eslint-plugin-jsx-a11y.

This isn't mentioned in the README.md, but I'm assuming that this is _also_ only necessary if you are in a React project so it is another useless thing that has to be installed for non-React projects.

Any word on when the separate package that doesn't have all the React stuff is going to be published?

@Arcanemagus the readme is now updated, but yes, your assumption is correct.

No update since https://github.com/airbnb/javascript/issues/751#issuecomment-203081106.

Ah, sorry, was still on the v7.0.0 tag when I checked the README.

I'm a bit confused by this... the OP said that he's using "eslint-config-airbnb/base", which the docs say does not lint react, but you're saying (and this has been my experience as well) that it requires the react plugin?

@brendanvinson dependencies are only granular at the package level. Per https://github.com/airbnb/javascript/issues/751#issuecomment-186954858, since part of the package lints react, any part of the package requires the react linting plugins.

Changing from [email protected] to [email protected] started to show 'use strict' is unnecessary inside of modules as lint error

As soon as I'm not currently using ES6 modules, I fixed it with

  "parserOptions": {
    "sourceType": null
  },

on .eslintrc

Then you probably need legacy config for es5

@josmardias you want "sourceType": "script" i believe - but yes, the legacy config is likely what you want.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

okaybenji picture okaybenji  ·  30Comments

CWSpear picture CWSpear  ·  167Comments

molily picture molily  ·  37Comments

Arnavion picture Arnavion  ·  36Comments

codejamninja picture codejamninja  ·  27Comments