React-router: New version of eslint-config-airbnb gives error on <Link to="/path">

Created on 7 Oct 2017  路  2Comments  路  Source: ReactTraining/react-router

[email protected]

eslint-config-airbnb@^16.0.0
eslint@^4.8.0
eslint-plugin-jsx-a11y@^6.0.2
eslint-plugin-import@^2.7.0
eslint-plugin-react@^7.4.0

When I use <Link to="/path"> I get the following linting error:

[eslint] The href attribute is required on an anchor. Provide a valid, navigable address as the href value. (jsx-a11y/anchor-is-valid)
https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md

Most helpful comment

From the linked page, you need to configure the rule. Specifically, this line implies that you should add to to the specialLink:

For the components option, these strings determine which JSX elements (always including ) should be checked for the props designated in the specialLink options (always including href).

Alternatively, you could just not include <Link> in the components and be confident knowing that React Router always renders an anchor with an href.

All 2 comments

FYI, https://github.com/airbnb/javascript/pull/1648 addresses the problem for eslint-config-airbnb. So if you're using this config (OP was), there should be no need for overriding this in the config once > 16.1.0 gets released :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArthurRougier picture ArthurRougier  路  3Comments

Waquo picture Waquo  路  3Comments

maier-stefan picture maier-stefan  路  3Comments

stnwk picture stnwk  路  3Comments

winkler1 picture winkler1  路  3Comments