Skip to content

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.

Terminal window
npm install @flint.fyi/plugin-node

Flint’s Node.js plugin provides the following presets:

PresetRecommendedDescription
logical✅ AlwaysCommon rules for finding bugs and enforcing good logical practices in Markdown files.
stylistic✅ AlwaysCommon rules for consistent styling and best stylistic practices in Markdown files.
stylisticStrict☑️ When ReadyAdditional 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:

flint.config.ts
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:

flint.config.ts
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],
},
],
});

Rules that find bugs and enforce good Node.js and general server-side best practices for most-to-all JavaScript and TypeScript files.

flint.config.ts
import { defineConfig, node } from "flint";
export default defineConfig({
use: [
{
files: node.files.all,
rules: node.presets.logical,
},
],
});

Rules that enforce consistent styling and best stylistic practices for most-to-all JavaScript and TypeScript files dealing with Node.js APIs.

flint.config.ts
import { node } from "@flint.fyi/node";
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: node.presets.stylistic,
},
],
});

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.

flint.config.ts
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: 11 of 18 (61.1%)
Flint RulePreset
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
hashbangslogical
nodeProtocolsPrefer the node: protocol prefix for Node.js built-in modules for clarity and consistency.logical
processExitsPrevent direct use of process.exit() for better error handling and testing.logical
unpublishedBinslogical
unpublishedImportslogical
unsupportedGlobalslogical
unsupportedNodeAPIslogical
unsupportedSyntaxlogical
eventClassesPrefer EventTarget over EventEmitter for cross-platform compatibility.logical (strict)
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
consoleSpacesDisallow leading or trailing spaces in console method string arguments.stylistic (strict)
filePathsFromImportMetaPrefer import.meta.dirname and import.meta.filename over legacy file path techniques.stylistic (strict)
fileReadJSONBuffersPrefer reading JSON files as buffers when using JSON.parse for better performance.stylistic (strict)
importFileExtensions(none)
Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.