ESLint
ESLint is a static code analysis and linting tool that detects problematic patterns, enforces best practices, and ensures consistent coding standards across a codebase.
In ServerCN projects, ESLint is treated as a first-line quality gate that:
- Prevents common runtime bugs
- Enforces consistent coding conventions
- Improves long-term maintainability
- Reduces review friction in team environments
This configuration is tailored specifically for Node.js, TypeScript, and Express.js backends.
Installation
Install the ESLint configuration using the ServerCN CLI:
npx servercn-cli add tooling eslintThis command automatically:
- Installs ESLint and required plugins
- Sets up a TypeScript-aware configuration
- Aligns ESLint with Prettier to avoid rule conflicts
What Gets Installed
The component installs and configures the following core packages:
eslint– Core linting engine@typescript-eslint/parser– TypeScript-aware parser@typescript-eslint/eslint-plugin– TypeScript-specific ruleseslint-config-prettier– Disables stylistic rules handled by Prettier
ESLint Configuration
ServerCN provides a sensible default configuration focused on backend correctness rather than frontend stylistic noise.
Below is the canonical configuration with inline explanations.
eslint.config.mjs
Scripts
Add the following scripts to your package.json to standardize linting across environments:
Script Usage:
npm run lint:check– Runs ESLint in read-only modenpm run lint:fix– Automatically fixes safe, rule-compliant issues
Prettier Compatibility
ServerCN intentionally separates code formatting from code correctness:
- ESLint focuses on logic, safety, and best practices
- Prettier handles formatting and stylistic concerns
This prevents the common ESLint–Prettier conflict and keeps responsibilities clear.
Features
- TypeScript-First: Fully aware of TypeScript syntax and semantics
- Backend-Oriented Rules: Optimized for Node.js and Express APIs
- Low Noise: Avoids unnecessary stylistic warnings
- CI Friendly: Safe to run in automated pipelines
- Extensible: Easy to layer additional rules per project needs
Best Practices
- Run
npm run lint:checklocally before pushing commits - Use
npm run lint:fixonly on clean working trees - Avoid disabling rules globally; prefer scoped overrides
- Pair ESLint with Commitlint and Prettier for full workflow coverage
Summary
The ServerCN ESLint component provides:
- A clean, production-ready baseline
- Strong TypeScript guarantees
- Minimal friction for backend developers
- Consistent standards across teams and repositories
This makes it suitable for serious backend systems and resume-grade projects.
Add More Tooling
npx servercn-cli add tooling commitlint husky eslint prettier lint-staged typescript