-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep eslint-config-react-app's dependencies up-to-date. #3217
Comments
This was a breaking change so we cannot just "support" it, and our documentation outlines the exact versions of the packages you need to install. Soon, I think we'll be able to actually depend on our current peer deps within our preset, but it's a newer (if available now?) eslint feature. |
What I'm suggesting is to make a concerted effort to keep peer dependencies up-to-date. I'm suggesting how to make the usage of this software more intuitive; providing a way to avoid the need to look up how to use it. |
I believe this is the issue we might want to track for that feature: eslint/eslint#6237 (comment) EDIT: Or this one: eslint/eslint#3458 |
I'm open to a PR that updates our peer dep range to accept both versions, but you'll need to fix the configuration as well to toggle what's being used based on the peer dep'd version. |
I think this is what you're suggesting? diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js
index adcdb86..727446d 100644
--- a/packages/eslint-config-react-app/index.js
+++ b/packages/eslint-config-react-app/index.js
@@ -277,7 +277,6 @@ module.exports = {
'jsx-a11y/aria-role': 'warn',
'jsx-a11y/aria-unsupported-elements': 'warn',
'jsx-a11y/heading-has-content': 'warn',
- 'jsx-a11y/href-no-hash': 'warn',
'jsx-a11y/iframe-has-title': 'warn',
'jsx-a11y/img-redundant-alt': 'warn',
'jsx-a11y/no-access-key': 'warn',
@@ -293,3 +292,23 @@ module.exports = {
'flowtype/use-flow-type': 'warn',
},
};
+
+try {
+ var a11y = require('eslint-plugin-jsx-a11y');
+} catch (e) {
+ // Ignore if the package isn't installed, let ESLint complain about that.
+}
+if (a11y) {
+ // Feature-detect availability of newly-added / later-deprecated rules, since
+ // we are maintaining backwards-compatibility for version 5 and ease-of-use
+ // for version 6.
+ if (a11y.rules['anchor-is-valid']) {
+ Object.assign(module.exports.rules, {
+ 'jsx-a11y/anchor-is-valid': 'warn',
+ });
+ } else if (a11y.rules['href-no-hash']) {
+ Object.assign(module.exports.rules, {
+ 'jsx-a11y/href-no-hash': 'warn',
+ });
+ }
+}
diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json
index a10ef67..c3f16bb 100644
--- a/packages/eslint-config-react-app/package.json
+++ b/packages/eslint-config-react-app/package.json
@@ -15,7 +15,7 @@
"eslint": "^4.1.1",
"eslint-plugin-flowtype": "^2.34.1",
"eslint-plugin-import": "^2.6.0",
- "eslint-plugin-jsx-a11y": "^5.1.1",
+ "eslint-plugin-jsx-a11y": "^5.1.1 || ^6.0.2",
"eslint-plugin-react": "^7.1.0"
}
} It seems to me like this should work, but I get "Error: Cannot find module 'eslint-plugin-jsx-a11y'". Maybe we need to imitate the way ESLint loads plugins? But in their |
Yup, that's what I had in mind in terms of compatibility with both versions. No ideas on the missing package though, node's module resolution should be picking it up -- odd. Does this work when you use |
I'm having issues with this now because we are using newest
on every build. |
It is not supported to use Airbnb config with CRA project without ejecting. In fact it's not supported to use any extra config at all until you eject. We'll bump the version eventually, but the use case you rely on has never been supported in the first place. |
It might not be supported, but it works fine as long there's no mismatch in major peer dependencies. |
Yeah. I’m just saying that while we understand it’s an inconvenience, it’s pretty much expected that versions will fall out of sync if you use it this way. So we’ll fix it within a month or two but it‘s not high on our list. |
I'll close as this won't be our priority. We try to update deps when we can, but supporting multiple majors is unlikely to happen. |
I just got bit by the exact same thing myself :(
Please reconsider updating to v6 of eslint-plugin-jsx-a11y |
We already updated it on the |
Of course you can't. Fully understandable :) But thanks for pointing me to @next, I'll see about using that for now. |
It's not usable yet (it only exists on GH, and |
Hey @gaearon, just to make sure I understood correctly: the Just asking because I'm maintaining eslint-plugin-react-app and this info might be useful. Thanks! |
Continuing on the issue brought up here: #2631
I think eslint-config-react-app would be easier to use if its peer dependencies were up-to-date with their packages' latest breaking changes. This just happened to me:
npm i -g eslint-config-react-app
npm i -g eslint-plugin-flowtype eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react babel-eslint
It'd be nice if the latest versions just worked, since I typically install the latest versions of packages. and I imagine other people do, too.
The text was updated successfully, but these errors were encountered: