reactjs - 用于 typescript 的 eslint-plugin-jsx-a11y

标签 reactjs typescript accessibility eslint

我正在尝试为我的 typescript react 项目设置,当我工作时,如果我正在做一些无法访问的事情,它会给我警告/错误。我的编辑器已经给我列出错误,但我尝试设置 eslint-plugin-jsx-a11y,但我无法让它工作。
这是我的 package.json 中的 eslint 部分

  "eslintConfig": {
    parser: '@typescript-eslint/parser',
    "extends": [
      "react-app",
      "react-app/jest",
      "shared-config",
      "plugin:jsx-a11y/recommended"
    ],
    "rules": {
      "additional-rule": "warn"
    },
    "overrides": [
      {
        "files": [
          "**/*.ts?(x)"
        ],
        "rules": {
          "additional-typescript-only-rule": "warn"
        }
      }
    ]
  },
不知道我错过了什么。谢谢

最佳答案

你的意思是不能让它工作?
从它的外观来看,我猜你错过了 plugins每个 eslint 使用任何给定插件所需的 key docs .eslint-plugin-jsx-a11y文档甚至在 usage 中提到了这一点部分。extends键仅应用规则集,而 plugins key 使某些规则可用,请参阅更长的解释 here .

"eslintConfig": {
  "parser": '@typescript-eslint/parser',
  "extends": [
    "react-app",
    "react-app/jest",
    "shared-config",
    "plugin:jsx-a11y/recommended"
  ],
  "plugins": [
    "jsx-a11y"
  ],
  "rules": {
    "additional-rule": "warn"
  },
  "overrides": [
    {
      "files": [
        "**/*.ts?(x)"
      ],
      "rules": {
        "additional-typescript-only-rule": "warn"
      }
    }
  ]
}

If this doesn't work please elaborate on what isn't working or what errors you get.

关于reactjs - 用于 typescript 的 eslint-plugin-jsx-a11y,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68697230/

相关文章:

javascript - 如何在 typescript 中正确评论/记录 map 对象

html - 文章页面中的 H1 - 站点标题或文章标题?

javascript - Flash 与 Javascript

javascript - react : how to re-render component every x seconds?

javascript - 三个js : How could we import a loader into a React application?

javascript - React "lifting state up"哲学 : How to avoid ending up with one big parent component containing all the code?

reactjs - typescript - 如何结合联合和交集类型

typescript - 类型 X 不是 'constructor function type' (TS2507)

iphone - 将画外音的焦点设置在 uitableview 中的特定表格单元格上(UIAccessibility)

javascript - 一个函数处理多个按钮