From bc14377041703a55c3653933dcd236fdb580acfc Mon Sep 17 00:00:00 2001 From: Houssein Djirdeh Date: Tue, 1 Jun 2021 00:10:52 -0700 Subject: [PATCH] ESLint Config: Adds `alt` text rule for Image (#25462) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Tim Neutkens --- packages/eslint-config-next/index.js | 9 ++++++++- packages/eslint-config-next/package.json | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-next/index.js b/packages/eslint-config-next/index.js index 8665d56e431c8..88865fd93b028 100644 --- a/packages/eslint-config-next/index.js +++ b/packages/eslint-config-next/index.js @@ -12,10 +12,17 @@ module.exports = { 'plugin:react-hooks/recommended', 'plugin:@next/next/recommended', ], - plugins: ['import', 'react'], + plugins: ['import', 'react', 'jsx-a11y'], rules: { 'import/no-anonymous-default-export': 'warn', 'react/react-in-jsx-scope': 'off', + 'jsx-a11y/alt-text': [ + 'warn', + { + elements: ['img'], + img: ['Image'], + }, + ], }, parser: './parser.js', parserOptions: { diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 6cb76a007f975..a3bd1e790f3b1 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -14,6 +14,7 @@ "@typescript-eslint/parser": "^4.20.0", "eslint-import-resolver-node": "^0.3.4", "eslint-plugin-import": "^2.22.1", + "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.23.1", "eslint-plugin-react-hooks": "^4.2.0" },