Skip to main content

Lesson 6 of 10

ESLint + Prettier - Code Quality

ESLint catches bugs before runtime; Prettier enforces consistent formatting automatically. Together they eliminate entire categories of code review comments and make the codebase more uniform across contributors.

20 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

ESLint + Prettier Setup for Expo

ESLint + Prettier Setup for Expo
npm install --save-dev eslint eslint-config-expo @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-native eslint-plugin-jsx-a11y prettier eslint-config-prettier

# .eslintrc.js
module.exports = {
  extends: [
    'expo',
    'plugin:@typescript-eslint/recommended',
    'plugin:react-hooks/recommended',
    'plugin:jsx-a11y/recommended',
    'prettier',  // last: disables ESLint formatting rules that conflict with Prettier
  ],
  plugins: ['@typescript-eslint', 'react-native'],
  rules: {
    // TypeScript - strict
    '@typescript-eslint/no-explicit-any': 'error',
    '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
    '@typescript-eslint/explicit-function-return-type': 'off', // too verbose for React components

    // React Native specific
    'react-native/no-unused-styles': 'error',    // catch unused StyleSheet entries
    'react-native/split-platform-components': 'warn',
    'react-native/no-color-literals': 'warn',    // enforce using theme constants

    // React
    'react-hooks/exhaustive-deps': 'error',      // catch missing deps in useEffect

    // Accessibility
    'jsx-a11y/accessible-emoji': 'warn',
  },
};

# .prettierrc
{
  "singleQuote": true,
  "trailingComma": "all",
  "tabWidth": 2,
  "semi": true,
  "printWidth": 100,
  "bracketSpacing": true,
  "arrowParens": "avoid"
}

# package.json scripts
"scripts": {
  "lint": "eslint . --ext .ts,.tsx",
  "lint:fix": "eslint . --ext .ts,.tsx --fix",
  "format": "prettier --write 'src/**/*.{ts,tsx}'"
}

Tip

Tip

Practice ESLint Prettier Code Quality in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

Configuring eslint-plugin-react-native, strict TypeScript, and automated formatting

Practice Task

Note

Practice Task - (1) Write a working example of ESLint Prettier Code Quality from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with ESLint Prettier Code Quality is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready react native code.

Topics in This Module

0/10 done