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.

ESLint Official Docs

Installation

Install the ESLint configuration using the ServerCN CLI:

npx servercn-cli add tooling eslint

This 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 rules
  • eslint-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
import tseslint from "@typescript-eslint/eslint-plugin";
import tsparser from "@typescript-eslint/parser";
import prettierPlugin from "eslint-plugin-prettier";
import eslintConfigPrettier from "eslint-config-prettier/flat";
export default [
  {
    files: ["**/*.ts"],
 
    languageOptions: {
      parser: tsparser,
      sourceType: "module"
    },
 
    plugins: {
      "@typescript-eslint": tseslint,
      prettier: prettierPlugin
    },
 
    rules: {
      ...tseslint.configs.recommended.rules,
      "@typescript-eslint/no-unused-vars": "warn",
      "no-console": "warn",
      semi: ["error", "always"],
      quotes: ["error", "double"],
      "prettier/prettier": "error"
    }
  },
  eslintConfigPrettier
];

Scripts

Add the following scripts to your package.json to standardize linting across environments:

{
  "scripts": {
    "lint:check": "eslint .",
    "lint:fix": "eslint . --fix"
  }
}

Script Usage:

  • npm run lint:check – Runs ESLint in read-only mode
  • npm 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:check locally before pushing commits
  • Use npm run lint:fix only 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 

Installation

npx servercn-cli add tooling eslint