Skip to content

Nodelinter#

Nodelinter is an extensible static analysis tool for checking your n8n node files to ensure n8n recommended best practices are followed when developing new nodes.

This includes rules for: * Alphabetization of node parameters and options * Casing for display names and descriptions * Default values per parameter type * Required and optional key-value pairs

See the full linting list here for more details.

Installation and Usage#

Nodelinter is a dependency of the nodes-base package and available upon installing n8n.

You can run Nodelinter from the packages/nodes-base directory as follows:

1
npm run nodelinter -- --<options>

Keep in mind

Be sure to run Nodelinter and verify your code before submitting a pull request.

Options#

Option Description Example
--target Path of the file or directory to lint Lint a single file:
--target=nodes/Stripe/Stripe.node.ts

Lint all files in a directory:
--target=nodes/Stripe
--config Path of the custom config to use --config=/Users/john/Documents/myConfig.json
--patterns Lintable file patterns --patterns:.node.ts,Description.ts
--print Print output to JSON

A custom filename can optionally be specified.
--print=myLintOutput
--errors-only Enable error logs only
--warnings-only Enable warning logs only
--infos-only Enable info logs only

Custom config#

The Nodelinter default config can be overridden to, for example, change the areas and issues linted.

To do so create a JSON file containing the key values you want to override. For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
  "target": "/Users/john/n8n/packages/nodes-base/nodes/Notion/Notion.node.ts",
  "patterns": [".node.ts"],
  "sortMethod": "lineNumber",
  "lintings": {
    "PARAM_DESCRIPTION_MISSING_WHERE_OPTIONAL": {
      "enabled": false
    },
    "NAME_WITH_NO_CAMELCASE": {
      "enabled": false
    }
  }
}

Name this file nodelinter.config.json and place it anywhere in your nodes-base directory and it will be automatically detected. Alternatively, you can specify the custom config file and location using the --config option.

Lint exceptions#

You can create exceptions for individual lines of code from any or all linting rules as follows:

1
// nodelinter-ignore-next-line <LINTING_NAME> <LINTING_NAME>

If no specific linting name is provided that line will be excepted from all rules. For example:

Exception for one rule:

1
2
// nodelinter-ignore-next-line PARAM_DESCRIPTION_WITH_EXCESS_WHITESPACE
description: 'Time zone used in the response.    The default is the time zone of the calendar.',

Exception for all rules:

1
2
// nodelinter-ignore-next-line
description: 'Time zone used in the response.    The default is the time zone of the calendar.',