Skip to content

Implement ESLint and Prettier for code consistency #3

@BekahHW

Description

@BekahHW

Description

RepoReady currently lacks automated code linting and formatting tools. Adding ESLint and Prettier will ensure consistent code style across the project and make it easier for new contributors to maintain code quality standards.

Current State

  • ❌ No ESLint configuration
  • ❌ No Prettier configuration
  • ❌ No linting scripts in package.json
  • ✅ TypeScript is configured (good foundation)
  • ✅ Project structure is clean and organized

Acceptance Criteria

ESLint Setup

  • Install ESLint dependencies (@typescript-eslint/parser, @typescript-eslint/eslint-plugin)
  • Create .eslintrc.js or .eslintrc.json configuration
  • Configure TypeScript-specific rules
  • Add lint and lint:fix scripts to package.json
  • Ensure all existing code passes linting

Prettier Setup

  • Install Prettier dependencies
  • Create .prettierrc configuration file
  • Create .prettierignore file
  • Add format and format:check scripts to package.json
  • Format all existing code

Integration

  • Configure ESLint to work with Prettier (eslint-config-prettier)
  • Add pre-commit hooks (optional but recommended)
  • Update VS Code settings for better developer experience
  • Document the setup in README or CONTRIBUTING.md

Implementation Suggestions

Recommended ESLint Configuration

// .eslintrc.js
module.exports = {
  parser: '@typescript-eslint/parser',
  plugins: ['@typescript-eslint'],
  extends: [
    'eslint:recommended',
    '@typescript-eslint/recommended',
    'prettier'
  ],
  parserOptions: {
    ecmaVersion: 2020,
    sourceType: 'module',
  },
  env: {
    node: true,
    es6: true,
  },
  rules: {
    // Add project-specific rules here
    '@typescript-eslint/explicit-function-return-type': 'warn',
    '@typescript-eslint/no-explicit-any': 'warn',
    '@typescript-eslint/no-unused-vars': 'error'
  },
};

Recommended Prettier Configuration

// .prettierrc
{
  "semi": true,
  "trailingComma": "es5",
  "singleQuote": true,
  "printWidth": 100,
  "tabWidth": 2,
  "useTabs": false
}

Package.json Scripts

"scripts": {
  "lint": "eslint src --ext .ts,.tsx",
  "lint:fix": "eslint src --ext .ts,.tsx --fix",
  "format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
  "format:check": "prettier --check \"src/**/*.{ts,tsx,json,md}\""
}

Files to Create/Modify

  • .eslintrc.js (new)
  • .prettierrc (new)
  • .prettierignore (new)
  • package.json (add dependencies and scripts)
  • .vscode/settings.json (optional, for better developer experience)

Dependencies to Add

npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
npm install --save-dev prettier eslint-config-prettier eslint-plugin-prettier

Benefits

  • 🔧 Consistent code formatting across the project
  • 🐛 Catch potential bugs and issues early
  • 👥 Easier for new contributors to follow coding standards
  • ⚡ Automated formatting saves time during development
  • 📝 Better code readability and maintainability

Resources

Estimated Effort

Easy to Medium - Straightforward setup with some configuration decisions.


Perfect for contributors who want to improve developer experience and code quality! 🔧

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