@fullstory/eslint-plugin-annotate-react

中文文档
0.0.10发布于 2023/08/01MIT零依赖近 30 天下载 2371

An ESLint plugin for annotating React components.

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. Maintaining this plugin
  4. Supported Rules
  5. @fullstory/annotate-react/data-component
  6. Release

@fullstory/eslint-plugin-annotate-react

An ESLint plugin for adding 'data-attribute' to React components. The purpose of this plugin is to automatically make css selectors. Here is an example:

const MyComponent = () => (
  <div />
);

This plugin will autofix and add the data-component prop to the div:

const MyComponent = () => (
  <div data-component="MyComponent" />
);

This plugin is intended to not be too opinionated. In general the approach is to suggest to the developer to add 'data-component' when there is an obvious approach, but in questionable cases, the plugin will tend towards being quiet. Click to learn more about the covered cases.

Note: This plugin cannot guarantee that the data-component prop will actually make it to the DOM node if the top level element is another React component. For it to work effectively, make sure you are properly forwarding props with the JSX spread syntax.

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install @fullstory/eslint-plugin-annotate-react:

npm install @fullstory/eslint-plugin-annotate-react --save-dev

Usage

Add @fullstory/eslint-plugin-annotate-react to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["@fullstory/annotate-react"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "@fullstory/annotate-react/data-component": "error"
  }
}

Maintaining this plugin

Tests can be ran using

npm run test

Supported Rules

@fullstory/annotate-react/data-component

...

Release

Run this command to bump the version, push the tag, and create the release on GitHub:

npx np <patch | minor | major> --no-publish --no-tests

版本与发布记录

@fullstory/eslint-plugin-annotate-react 共发布 11 个版本,首次发布于 2022/07/27;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.10latest2023/08/013 年前
0.0.112023/08/013 年前
0.0.92023/07/193 年前
0.0.82023/07/193 年前
0.0.72022/12/103 年前
0.0.62022/09/204 年前

关于 @fullstory/eslint-plugin-annotate-react 的常见问题

@fullstory/eslint-plugin-annotate-react 是什么?

An ESLint plugin for annotating React components.

如何安装 @fullstory/eslint-plugin-annotate-react?

在项目目录运行 npm install @fullstory/eslint-plugin-annotate-react,或使用 pnpm add / yarn add / bun add。

@fullstory/eslint-plugin-annotate-react 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fullstory__eslint-plugin-annotate-react 是否存在。

@fullstory/eslint-plugin-annotate-react 可以商用吗?

@fullstory/eslint-plugin-annotate-react 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fullstory/eslint-plugin-annotate-react 的下载量有多少?

根据 npm 官方下载统计,@fullstory/eslint-plugin-annotate-react 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,371 次,日均约 79 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fullstory/eslint-plugin-annotate-react 还在维护吗?

最新版本 0.0.10 发布于 2023/08/01(3 年前);至今共发布 11 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/07/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。