Skip to content

Add ESLint and Prettier for consistent code style #165

Description

@ShivamH1

Problem

No linting or formatting tools were configured. Code style was enforced through convention only, making it easy for inconsistencies to slip into PRs.

Solution

Added ESLint and Prettier with project-aligned defaults:

New Files

  • .eslintrc.json — ESLint config extending @typescript-eslint/recommended with prettier to avoid conflicts
  • .prettierrc — Prettier config matching codebase conventions (double quotes, semicolons, trailing commas, 120 print width, 2-space indent)
  • .prettierignore — Excludes dist/, node_modules/, scripts/

Updated Files

  • package.json — Added devDependencies and scripts

New Dependencies

  • eslint
  • @typescript-eslint/eslint-plugin
  • @typescript-eslint/parser
  • eslint-config-prettier
  • prettier

New Scripts

Script Purpose
npm run lint Check for lint errors
npm run lint:fix Auto-fix lint errors
npm run format Format all files with Prettier
npm run format:check Check if files are formatted

ESLint Rules

  • @typescript-eslint/no-unused-vars — error (args/vars prefixed with _ allowed)
  • @typescript-eslint/no-explicit-any — warn
  • @typescript-eslint/require-await — warn
  • no-console — off (CLI tool requires console output)

Prettier Config

  • semi: true
  • singleQuote: false
  • trailingComma: "all"
  • printWidth: 120
  • tabWidth: 2

Verification

  • npm run lint — 0 errors, 3 warnings
  • npm run format:check — all files pass
  • npm test — all tests pass (2 pre-existing Windows-specific failures unrelated to this change)

Why This Matters

  • Enforces consistent formatting without manual review overhead
  • Catches common bugs (unused imports, implicit any, etc.) before review
  • Makes contributor onboarding smoother with auto-format on save
  • Prevents ESLint/Prettier conflicts via eslint-config-prettier

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions