Node.js Plugin
Rules for code that runs in Node.js and other server runtimes that include Node.js-like APIs.
This plugin is provided in a standalone @flint.fyi/plugin-node npm package.
npm install @flint.fyi/plugin-nodepnpm install @flint.fyi/plugin-nodeyarn install @flint.fyi/plugin-nodePresets
Section titled “Presets”Flint’s Markdown plugin provides the following presets:
| Preset | Recommended | Description |
|---|---|---|
logical | ✅ Always | Common rules for finding bugs and enforcing good logical practices in Markdown files. |
stylistic | ✅ Always | Common rules for consistent styling and best stylistic practices in Markdown files. |
stylisticStrict | ☑️ When Ready | Additional rules for consistent styling and best stylistic practices in Markdown files. |
If you are just getting started with linting, Flint recommends using the logical and stylistic presets:
import { node } from "@flint.fyi/node";import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: ts.files.all, rules: [node.presets.logical, node.presets.stylistic], }, ],});If you are experienced with both Markdown and linting, Flint recommends additionally using the stylisticStrict preset:
import { node } from "@flint.fyi/node";import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: ts.files.all, rules: [node.presets.logical, node.presets.stylisticStrict], }, ],});logical
Section titled “logical”Rules that find bugs and enforce good Node.js and general server-side best practices for most-to-all JavaScript and TypeScript files.
import { defineConfig, node } from "flint";
export default defineConfig({ use: [ { files: node.files.all, rules: node.presets.logical, }, ],});stylistic
Section titled “stylistic”Rules that enforce consistent styling and best stylistic practices for most-to-all JavaScript and TypeScript files dealing with Node.js APIs.
import { node } from "@flint.fyi/node";import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: ts.files.all, rules: node.presets.stylistic, }, ],});stylisticStrict
Section titled “stylisticStrict”Additional stylistic rules that enforce best practices which are not always straightforward to implement. These rules are recommended for projects where a majority of developers are experienced with both Node.js and using a linter.
import { node } from "@flint.fyi/node";import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: ts.files.all, rules: node.presets.stylisticStrict, }, ],});This preset’s rules are a superset of those in stylistic.
Implemented: 6 of 18 (33.3%)
| Flint Rule | Preset |
|---|---|
assertStrictPrefer strict assertion mode from Node.js for better error messages and behavior. | Logical |
bufferAllocatorsPrefer modern Buffer allocation methods over the deprecated Buffer constructor. | Logical |
exportsAssignmentsPrevent assignment to the exports variable in CommonJS modules. | Logical |
hashbangs | Logical |
nodeProtocols | Logical |
processExists | Logical |
unpublishedBins | Logical |
unpublishedImports | Logical |
unsupportedGlobals | Logical |
unsupportedNodeAPIs | Logical |
unsupportedSyntax | Logical |
eventClassesPrefer EventTarget over EventEmitter for cross-platform compatibility. | Logical (Strict) |
importFileExtensions | None |
assertStylesPrefer assert.ok() over assert() for explicit intent and better readability. | Stylistic |
blobReadingMethodsPrefer direct Blob reading methods over wrapping in Response for simpler code. | Stylistic |
consoleSpaces | Stylistic (Strict) |
filePathsFromImportMeta | Stylistic (Strict) |
fileReadJSONBuffers | Stylistic (Strict) |