nodelinter
v0.1.19
Published
Linter for n8n nodes
Downloads
635
Keywords
Readme
Nodelinter is a static code analyzer for n8n node files, with ~70 linting rules for:
- default values based on param type,
- casing for display names and descriptions,
- alphabetization for params and options,
- required and optional key-value pairs,
- expected values for specific params,
- etc.
See full lintings list.
Operation
Run via npx:
npx nodelinter --target=/Users/john/n8n/packages/nodes-base/nodes/Stripe/Stripe.node.ts
Or run locally:
git clone https://github.com/n8n-io/nodelinter
cd nodelinter; npm i
npm run lint -- --target=/Users/john/n8n/packages/nodes-base/nodes/Stripe/Stripe.node.ts
Options
| Option | Effect |
| ----------------- | -------------------------------------------------- |
| --target
| Path of the file or directory to lint |
| --config
| Path of the custom config to use |
| --print
| Whether to print output to lintOutput.json
|
| --patterns
| Lintable file patterns |
| --errors-only
| Enable error logs only |
| --warnings-only
| Enable warning logs only |
| --infos-only
| Enable info logs only |
Examples:
# lint a single file
--target=./packages/nodes-base/nodes/Stripe/Stripe.node.ts
# lint all files in a dir
--target=./packages/nodes-base/nodes/Stripe
# use a custom config
--config=/Users/john/Documents/myConfig.json
# print logs to lintOutput.json
--print
# lint files ending with these patterns
--target=./src/input/MyNode --patterns:.node.ts,Description.ts
# lint files ending with this pattern
--target=./src/input/MyNode --patterns:.node.ts
# lint only rules with error classification
--target=./src/input/MyNode --errors-only
Custom config
You can override the Nodelinter default config with a custom config.
To do so, create a JSON file containing any keys to overwrite:
{
"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
}
}
}
And use the --config
option:
npx nodelinter --config=/Users/john/Documents/myConfig.json
For convenience, when running locally, if you place a custom config file named nodelinter.config.json
anywhere inside the nodelinter dir, the custom config file will be auto-detected.
Lint exceptions
Add // nodelinter-ignore-next-line LINTING_NAME
to except the next line from one or more specific lintings:
// 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.',
// nodelinter-ignore-next-line PARAM_DESCRIPTION_WITH_EXCESS_WHITESPACE PARAM_DESCRIPTION_UNTRIMMED
description: 'Time zone used in the response. The default is the time zone of the calendar. ',
Or add // nodelinter-ignore-next-line
to except the next line from all lintings:
// nodelinter-ignore-next-line
description: 'Time zone used in the response. The default is the time zone of the calendar.',
Author
© 2021 Iván Ovejero
License
Distributed under the MIT License.