@hootool/eslint-config-react
v0.1.0
Published
React/H5/Web 专用 ESLint 规则配置 (ESLint v9 Flat Config, 继承 base)
Readme
@hootool/eslint-config-react
React/H5/Web 专用 ESLint 规则配置,继承 @hootool/eslint-config,基于 ESLint v9 Flat Config。
特性
在 base 基础上叠加:
eslint-plugin-react:React 官方推荐规则 + jsx-runtime 适配(React 17+ 无需import React)eslint-plugin-react-hooks:Hooks 规则(含 React Compiler 相关规则)eslint-plugin-jsx-a11y:无障碍(a11y)规则
安装
pnpm add -D @hootool/eslint-config-react eslint使用
// eslint.config.js
import reactConfig from '@hootool/eslint-config-react';
export default reactConfig;如需自定义:
// eslint.config.js
import reactConfig, { defineConfig } from '@hootool/eslint-config-react';
export default defineConfig(
...reactConfig,
{
rules: {
'react/prop-types': 'off',
},
},
);
defineConfig与globals由 base 包 re-export,可直接从本包导入。
主要规则
react-hooks/rules-of-hooks:errorreact-hooks/exhaustive-deps:warnreact/jsx-key:warnreact/no-array-index-key:warnreact/jsx-no-leaked-render:warnjsx-a11y/click-events-have-key-events:errorjsx-a11y/no-static-element-interactions:error
配置块结构
共 14 个配置块:base 9 块 + React recommended + jsx-runtime + react-hooks + jsx-a11y + 自定义规则。
