An ESLint plugin that adds accessibility linting rules for styled-components, wrapping eslint-plugin-jsx-a11y to handle all seven methods styled-components uses to create components (styled.div, styled('div'), attrs, as prop, object syntax, etc.). Version 2.2.1 supports ESLint 3–9 and works with both legacy and flat configs. Unique in extending jsx-a11y to cover styled-components patterns without false negatives. Released under MIT, maintained by Brendan Morrell.
npm install eslint-plugin-styled-components-a11yVerified import paths — ran on the pinned version, not inferred.
Install the plugin and configure it with the recommended ruleset using either legacy .eslintrc or flat config.
Upgrade to v2.2.0+ which addresses styled-components v6 compatibility.
Replace 'styled-components-a11y/componentWithForwardedRef' with 'styled-components-a11y/no-arrow-function-in-jsx'.
Ensure ESLint v9 is installed if using flat config; for ESLint v8, continue using legacy .eslintrc.
Disable standalone jsx-a11y rules when using this plugin to avoid duplicate warnings.
Ensure the component using `as` is created via styled() to trigger linting rules.
Migrate to ESLint v9 to ensure continued compatibility.
Run npm install --save-dev eslint-plugin-styled-components-a11y eslint-plugin-jsx-a11y
Use import styledA11y from 'eslint-plugin-styled-components-a11y' then access styledA11y.flatConfigs.recommended
Check the correct rule name from the plugin's rule list (e.g., 'styled-components-a11y/no-onchange').