ESLint configuration tailored for Node.js applications and server-side JavaScript/TypeScript development. Provides Node.js-specific environment settings and linting rules for backend services, CLI tools, and server applications.
Configuration optimized for Node.js runtime environments with server-side specific rules and settings.
// Traditional ESLint config (.eslintrc.js)
module.exports = {
extends: ['universe/node']
};
// Package.json configuration
{
"eslintConfig": {
"extends": "universe/node"
}
}Configuration Details:
ESLint 9+ flat configuration format for Node.js projects.
// eslint.config.js
const { defineConfig } = require('eslint/config');
const config = require('eslint-config-universe/flat/node');
module.exports = defineConfig(config);
// Or with ES modules
import { defineConfig } from 'eslint/config';
import config from 'eslint-config-universe/flat/node';
export default defineConfig(config);Usage Examples:
// Basic Node.js application
// .eslintrc.js
module.exports = {
extends: ['universe/node']
};
// Express.js API server
// .eslintrc.js
module.exports = {
extends: ['universe/node'],
rules: {
'no-console': 'off', // Allow console.log in server applications
'node/no-missing-import': 'error'
}
};
// Node.js CLI tool
// .eslintrc.js
module.exports = {
extends: ['universe/node'],
overrides: [
{
files: ['bin/**/*.js'],
rules: {
'no-process-exit': 'off' // Allow process.exit in CLI tools
}
}
]
};
// TypeScript Node.js project
// .eslintrc.js
module.exports = {
extends: ['universe/node'],
overrides: [
{
files: ['*.ts'],
parserOptions: {
project: './tsconfig.json'
}
}
]
};// Traditional config
env: { node: true }
// Flat config
languageOptions: {
globals: { ...globals.node }
}Available Node.js Globals:
require, module, exports, __dirname, __filenameprocess, global, BuffersetTimeout, setInterval, setImmediate, clearTimeout, clearInterval, clearImmediateconsole object for loggingURL, URLSearchParams// Traditional config uses eslint-plugin-node
plugins: ['node']
// Flat config uses eslint-plugin-n
plugins: {
n: nodePlugin
}// Prevents deprecated Buffer constructor usage
'no-buffer-constructor': 'warn'
// Example of what this prevents:
// ❌ new Buffer(size) // Deprecated and unsafe
// ✅ Buffer.alloc(size) // Preferred safe alternative
// ✅ Buffer.from(data) // Preferred for data conversion// Traditional config - prevents unsafe path concatenation
'node/no-path-concat': 'warn'
// Flat config - prevents unsafe path concatenation
'n/no-path-concat': 'warn'
// Example of what this prevents:
// ❌ __dirname + '/file.txt' // Unsafe path concatenation
// ✅ path.join(__dirname, 'file.txt') // Preferred cross-platform approach
// ✅ path.resolve(__dirname, 'file.txt') // Alternative safe method// Flat config - warns about deprecated Node.js APIs
'n/no-deprecated-api': 'warn'
// Example of what this prevents:
// ❌ fs.exists() // Deprecated, use fs.access() or fs.stat()
// ❌ Buffer() // Deprecated constructor
// ✅ fs.access() // Modern alternative
// ✅ Buffer.from() / Buffer.alloc() // Safe alternativesStandard JavaScript and TypeScript extensions for Node.js:
// JavaScript extensions
.js, .jsx
// TypeScript extensions
.ts, .tsx, .d.tsNote: While .jsx and .tsx are supported for completeness, React/JSX rules are not included in the Node.js configuration.
Configured for Node.js module resolution:
// Import/export settings
settings: {
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
'import/resolver': {
node: { extensions: ['.js', '.jsx', '.ts', '.tsx'] }
}
}Perfect for Express.js web servers, REST APIs, and GraphQL backends.
Suitable for command-line applications and build tools with Node.js-specific considerations.
Ideal for Node.js microservices, serverless functions, and backend services.
Appropriate for build scripts, automation tools, and development utilities.
Suitable for applications using databases with Node.js drivers (MongoDB, PostgreSQL, etc.).
Perfect for WebSocket servers, chat applications, and real-time communication services.
Can be combined with other universe configurations for full-stack projects:
// Full-stack project with Node.js backend and React frontend
module.exports = {
extends: ['universe/node'],
overrides: [
{
files: ['client/**/*', 'frontend/**/*'],
extends: ['universe/web']
},
{
files: ['mobile/**/*', 'app/**/*'],
extends: ['universe/native']
}
]
};