@figma/eslint-plugin-figma-plugins

中文文档
1.0.0发布于 2025/12/19MITTypeScriptCommonJS近 30 天下载 12.3万

typescript-eslint rules for Figma plugin development

原始使用文档
文档目录12 节
  1. A quick look
  2. Installation
  3. Dependencies
  4. Install the ESLint plugin package
  5. Configure eslint
  6. Restart the ESLint server
  7. Usage
  8. Linting and autofixing
  9. VSCode
  10. Available Configurations
  11. Rules
  12. Contributing

eslint-plugin-figma-plugins

This repository defines typescript-eslint rules for Figma plugin development.

This tool helps you stay up to date with best practices and deprecations in the Figma Plugin API. You can use it to help identify, and in many cases automatically fix, issues in your plugin code. Like any ESLint plugin, it integrates with IDEs like VSCode to provide inline warnings and quick-fix functionality.

A quick look

An animation of VSCode quick fixes enabled by this plugin

Installation

Dependencies

This linter requires TypeScript, ESLint, typescript-eslint, and the Figma Plugin API type definitions. To install all of these, run:

npm install -D typescript eslint @figma/plugin-typings

For ESLint 8 with legacy config:

npm install -D eslint@8 @typescript-eslint/parser@8 @typescript-eslint/eslint-plugin@8

For ESLint 9 with flat config:

npm install -D eslint@9 @typescript-eslint/parser@8 @typescript-eslint/eslint-plugin@8  typescript-eslint@8

The default Figma plugin template uses older versions of these dependencies, so you may need to edit package.json manually to get more recent versions. We have tested flat config specifically with the following peer dependencies:

- `@typescript-eslint/eslint-plugin`: `8.48.1`
- `@typescript-eslint/parser`: `^8.48.1`
- `eslint`: `^9.39.1`
- `typescript-eslint`: `^8.48.1`

Install the ESLint plugin package

npm install -D @figma/eslint-plugin-figma-plugins

Configure eslint

Choose the configuration method based on your ESLint version:

ESLint 9+ (Flat Config)

Update your ESLint config to include the eslint-plugin-figma-plugins by creating an eslint.config.mjs file utilizing the new defineConfig() function (documentation is here: https://typescript-eslint.io/getting-started/#details)

Here's an example eslint.config.mjs that enables the recommended ruleset for this plugin, as well as the recommended rulesets from the @eslint/js and typescript-eslint packages:

import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import * as figmaPlugin from '@figma/eslint-plugin-figma-plugins';
import { defineConfig } from 'eslint/config'

export default defineConfig(
  js.configs.recommended,
  tseslint.configs.recommended,
  {
    files: ['**/*.ts'],
    languageOptions: {
      parser: tseslint.parser,
      parserOptions: {
        project: './tsconfig.json',
      },
    },
    plugins: {
      '@figma/figma-plugins': figmaPlugin,
    },
    rules: {
      ...figmaPlugin.flatConfigs.recommended.rules,
    },
  }
);

ESLint 8 (Legacy Config)

Configure typescript-eslint as normal using these instructions.

Next, update your ESLint config's extends array to include the plugin:@figma/figma-plugins/recommended ruleset. We also recommend the following rulesets:

  • eslint:recommended,
  • plugin:@typescript-eslint/recommended

To work with TypeScript code, ESLint also requires the following parser settings:

{
  ...
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: './tsconfig.json',
  },
  ...
}

Here's a full example of .eslintrc.js:

/* eslint-env node */
module.exports = {
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:@figma/figma-plugins/recommended',
  ],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: './tsconfig.json',
  },
  root: true
}

Restart the ESLint server

If you've run npm install and updated to a newer version of this package, remember to restart your IDE. In VSCode, you can restart the ESLint server independently by opening the command palette and choosing "Restart ESLint Server".

Usage

Linting and autofixing

You can lint your project using these rules by running

npx eslint ./path/to/source

Some rules provide autofixes, which you can run using --fix.

npx eslint --fix ./path/to/source

Autofixes are also available via some IDEs.

VSCode

To use ESLint with VSCode, see the ESLint VSCode extension. This extension will show rule violations inline, as well as provide opportunities to run autofixes directly in the IDE.

Available Configurations

This plugin provides two configurations:

  • recommended: Includes all rules - errors for breaking changes and warnings for advisories
  • recommended-problems-only: Only includes error-level rules for breaking changes, omitting warnings

For flat config, use:

  • figmaPlugin.flatConfigs.recommended
  • figmaPlugin.flatConfigs['recommended-problems-only']

For legacy config, use:

  • plugin:@figma/figma-plugins/recommended
  • plugin:@figma/figma-plugins/recommended-problems-only

Rules

💼 Configurations enabled in.
⚠️ Configurations set to warn in.
👍 Set in the recommended configuration.
🔦 Set in the recommended-problems-only configuration.
🔧 Automatically fixable by the --fix CLI option.

Name                                                        Description💼⚠️🔧
await-requires-asyncRequire functions that contain await to be async👍 🔦🔧
ban-deprecated-id-paramsBan use of deprecated string ID parameters👍 🔦🔧
ban-deprecated-sync-methodsBan use of deprecated synchronous methods👍 🔦🔧
ban-deprecated-sync-prop-gettersBan use of deprecated synchronous property getters👍 🔦🔧
ban-deprecated-sync-prop-settersBan use of deprecated synchronous property getters👍 🔦🔧
constrain-proportions-replaced-by-target-aspect-ratio-adviceWarns against using constrainProportions in favor of targetAspectRatio👍
dynamic-page-documentchange-event-adviceAdvice on using the documentchange event👍
dynamic-page-find-method-adviceAdvice on using the find*() family of methods👍

Contributing

Please see CONTRIBUTING.md

版本与发布记录

@figma/eslint-plugin-figma-plugins 共发布 9 个版本,首次发布于 2024/02/09;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.0.0latest2025/12/1910 个月前
0.16.12025/02/191.7 年前
0.16.02025/02/191.7 年前
0.15.02024/03/152 年前
0.14.02024/02/232 年前
0.13.02024/02/222 年前

关于 @figma/eslint-plugin-figma-plugins 的常见问题

@figma/eslint-plugin-figma-plugins 是什么?

typescript-eslint rules for Figma plugin development

如何安装 @figma/eslint-plugin-figma-plugins?

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

@figma/eslint-plugin-figma-plugins 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@figma/eslint-plugin-figma-plugins 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@figma/eslint-plugin-figma-plugins 可以商用吗?

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

@figma/eslint-plugin-figma-plugins 的下载量有多少?

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

@figma/eslint-plugin-figma-plugins 还在维护吗?

最新版本 1.0.0 发布于 2025/12/19(10 个月前);至今共发布 9 个版本,其中过去 12 个月发布了 1 个;首次发布于 2024/02/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。