Skip to content

Latest commit

 

History

History
71 lines (50 loc) · 4.37 KB

node.md

File metadata and controls

71 lines (50 loc) · 4.37 KB

node config

Config for Node.js projects.

🏗️ Setup

  1. If you haven't already, make sure to install @code-pushup/eslint-config and its required peer dependencies.

  2. Since this plugin requires additional peer dependencies, you have to install them as well:

    npm install -D eslint-plugin-n
  3. Add to your eslint.config.js file:

    import node from '@code-pushup/eslint-config/node.js';
    import tseslint from 'typescript-eslint';
    
    export default tseslint.config(...node);
  4. Some rules (e.g. n/no-unsupported-features/node-builtins) need to know which Node version is being used. Configuration options include:

    • engines field in package.json:

      {
        // ...
        "engines": {
          "node": ">=22.12.0"
        }
    • settings.node.version in eslint.config.js:

      export default tseslint.config({
        // ...
        {
          settings: {
             node: {
               version: '>=22.12.0'
             }
          }
        }
      });

    For more information, refer to eslint-plugin-n docs.

📏 Rules (294)

290 rules are included from javascript config. For brevity, only the 4 additional rules are listed in this document.

🔧 Automatically fixable by the --fix CLI option.
💡 Manually fixable by editor suggestions.
🧪🚫 Disabled for test files.
🧪⚠️ Severity lessened to warning for test files.

🚨 Errors (1)

Plugin Rule Options Autofix Overrides
n no-unsupported-features/node-builtins
disallow unsupported Node.js built-in APIs on the specified version

⚠️ Warnings (3)

Plugin Rule Options Autofix Overrides
n no-process-exit
disallow the use of process.exit()
n no-sync
disallow synchronous methods
n prefer-promises/fs
enforce require("fs").promises