Conventions and quality
Development and Maintenance – Conventions and Quality
Maintaining a healthy codebase requires consistent styling, strict linting, and reliable build processes. This section details the conventions and quality controls employed by the n8n-nodes-docuwriter-ai project to ensure clarity, consistency, and compatibility.
ESLint: Enforcing Code Standards 🕵️♀️
ESLint analyzes TypeScript sources under nodes/ and credentials/ to catch errors and enforce style rules:
-
Configuration
- Uses
eslintcore with the@typescript-eslintparser and plugin. - Includes
eslint-plugin-n8n-nodes-baseto align with n8n’s node development guidelines.
- Uses
-
npm Scripts
npm run lint # Run ESLint checks npm run lintfix # Auto-fix ESLint issuesThese scripts lint all
.tsfiles innodes/andcredentials/. -
CI Integration
- The
prepublishOnlyhook runs bothbuildandlintto prevent publishing if lint errors exist.
- The
Prettier: Automatic Formatting 🎨
Prettier provides a uniform code style to reduce bike-shedding:
-
Formatting Script
npm run format # Apply Prettier to nodes and credentialsTargets
nodes/andcredentials/directories, ensuring code blocks, imports, and spacing stay consistent . -
Combination with ESLint
- Teams first apply Prettier, then run ESLint to catch semantic errors.
- Editors can be configured to format on save.
TypeScript Configuration
Strong typing and modern JavaScript features are enabled via tsconfig.json:
{
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"outDir": "dist",
"rootDir": ".",
"declaration": true,
"strict": true,
"esModuleInterop": true
},
"include": ["credentials/**/*","nodes/**/*"],
"exclude": ["dist/**/*","node_modules/**/*"]
}
- Output
- Compiled files are placed in
dist/for n8n consumption. - Declaration files assist IDEs and downstream consumers .
- Compiled files are placed in
Icon Management: Copying SVG Assets 📁
Custom node icons (SVG files) must accompany compiled code for n8n’s UI:
-
Build-Time Copy
npm run copy:icons # copyfiles "nodes/**/*.svg" distLeverages the
copyfilespackage to mirror all.svgicons fromnodes/intodist/, preserving folder structure . -
Script Workflow
- Transpile:
tsccompiles.ts→.jsintodist/. - Copy Icons:
copyfilesmoves SVGs into matchingdist/paths. - Publish:
dist/contains everything n8n needs: code, credentials, and icons.
- Transpile:
Package Manager and Publishing
The project embraces pnpm for fast, reproducible installs:
"engines": {
"node": ">=18.10",
"pnpm": ">=7.18"
},
"packageManager": "[email protected]",
- Scripts Overview
| Script | Description |
|---|---|
build |
Compile TS and copy icons |
copy:icons |
Copy all .svg icons to dist/ |
dev |
Watch-mode TypeScript compilation |
format |
Run Prettier formatting |
lint |
Run ESLint checks |
lintfix |
ESLint with --fix |
prepublishOnly |
Ensure build + lint pass before publishing |
All files published are restricted to the dist/ folder, simplifying n8n’s module loading and reducing bundle size .
By combining ESLint, Prettier, strict TypeScript settings, and automated icon handling, the n8n-nodes-docuwriter-ai project upholds high code quality, consistent styling, and smooth integration into n8n workflows.
Updated