Skip to content

Guide

Install

shell
npm i eslint-plugin-svg -D
shell
yarn add eslint-plugin-svg -D
shell
pnpm add eslint-plugin-svg -D

Basic Usage

Highly recommended to use eslint.config.mjs as config file.

eslint.config.mjs
ts
import 
pluginSVG
from 'eslint-plugin-svg'
/** * @type {import('eslint').Linter.Config[]} */ export default [ // Other configs... ...
pluginSVG
.
configs
.
recommended
,
]

The recommended config enables a subset of the rules that should be most useful to most users.

Advanced Usage

Override/add specific rules configurations.

See also: http://eslint.org/docs/user-guide/configuring.

eslint.config.mjs
ts
import 
pluginSVG
from 'eslint-plugin-svg'
import
parserSVG
from 'svg-eslint-parser'
/** * @type {import('eslint').Linter.Config[]} */ export default [ // other configs { // config name
name
: 'svg/rules',
// files to include
files
: ['**/*.svg'],
// use eslint-plugin-svg
plugins
: {
svg
:
pluginSVG
,
}, // use svg-eslint-parser
languageOptions
: {
parser
:
parserSVG
,
}, // rules to enable
rules
: {
'svg/no-deprecated': 'error', 'svg/no-empty-container': 'error', 'svg/no-empty-desc': 'error', 'svg/no-empty-text': 'error', 'svg/no-empty-title': 'error', }, }, ]