Nodelinter#
Nodelinter is an extensible static analysis tool for checking your Doc² node files to ensure Doc² 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 activating Workflow².
You can run Nodelinter from the packages/nodes-base
directory as follows:
1 |
|
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 |
|
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 |
|
If no specific linting name is provided that line will be excepted from all rules. For example:
Exception for one rule:
1 2 |
|
Exception for all rules:
1 2 |
|