#Skip ESLint rule in specific part of the component

5 messages · Page 1 of 1 (latest)

strong rose
#

Warning: Image elements must have an alt prop, either with meaningful text, or an empty string for decorative images. jsx-a11y/alt-text

Can I skip/disable ESLint rule for this exact image in component?

<Image className="rounded-md" {...props} />
tidal dove
#

Yes, you can disable a specific eslint rule by editing your eslintrc.json file.

#

Copy the name of the category of the warning/error you want to disable (i.e. when you run npm run lint), like so:

{
"env": { "browser": true, "node": true, "es6": true },
"extends": ["eslint:recommended", "next", "next/core-web-vitals"],
"rules": {
"@next/next/no-img-element": "off",
"no-unused-vars": "off",
"react-hooks/exhaustive-deps": "off"
}
}

strong rose
#

This is what I was looking for
/* eslint-disable jsx-a11y/alt-text */

#

I did not want to disable it globally, just for that specific file