API、CLI 与扩展

Node linter

n8n's node linter, @n8n/eslint-plugin-community-nodes, statically analyzes ("lints") the source code of n8n nodes and credentials in community packages. The linter detects issues and automatically fixes them to help you follow best practices.

@n8n/eslint-plugin-community-nodes contains a collection of rules for node files (*.node.ts), credential files (*.credentials.ts), and the package.json of a community package.

Setup

If using the n8n node starter: Run npm install in the starter project to install all dependencies. Once the installation finishes, the linter is available to you.

If using VS Code, install the ESLint VS Code extension. For other IDEs, refer to their ESLint integrations.

Usage

You can use the linter in a community package or in the main n8n repository.

Linting

In a community package, the linter runs automatically after installing dependencies and before publishing the package to npm. In the main n8n repository, the linter runs automatically using GitHub Actions whenever you push to your pull request.

In both cases, VS Code lints in the background as you work on your project. Hover over a detected issue to see a full description of the linting and a link to further information.

You can also run the linter manually:

  • Run npm run lint to lint and view detected issues in your console.
  • Run npm run lint:fix to lint and automatically fix issues. The linter fixes violations of rules marked as automatically fixable.

Both commands can run in the root directory of your community package, or in /packages/nodes-base/ in the main repository.

Exceptions

Instead of fixing a rule violation, you can also make an exception for it, so the linter doesn't flag it.

To make a lint exception from VS Code: hover over the issue and click on Quick fix (or cmd+. in macOS) and select Disable {rule} for this line. Only disable rules for a line where you have good reason to. If you think the linter is incorrectly reporting an issue, please report it in the n8n repository.

To add a lint exception to a single file, add a code comment. Refer to the ESLint documentation for more guidance.

官方原文和授权

本页来自 N8N 英文官方网站固定快照,并转换成 xueai 静态页面。内容以 N8N 持续更新的官方页面为准。

来源、授权与修改

本站保留许可证、固定提交号、社区作者和修改说明,不代表 n8n 对本站背书。

查看许可证查看来源和修改说明