SVG specific rules for react
Installation
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-react-svg
:
$ npm install eslint-plugin-react-svg --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-react-svg
globally.
Configuration
Using the preset
"extends":
Using manual configuration
Add react-svg
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
Enable JSX support
Then configure the rules you want to use under the rules section.
Supported Rules
- react-svg/no-unused-ids-in-svg: Forbid ids not referenced in the svg
- react-svg/no-unused-empty-tag-in-svg: Forbids empty elements that doesn't render anything
- react-svg/no-metadata-in-svg: Forbids metadata like "title" / "desc"