Mahamudul Hasan Rubel
HomeBlogCoursesAboutProjectsSkillsExperiencePhotosContact
Mahamudul Hasan Rubel

Senior Software Engineer crafting high-performance web applications and SaaS platforms.

Navigation

  • Home
  • Blog
  • Courses
  • About
  • Projects
  • Skills
  • Experience
  • Photos
  • Contact

Get in Touch

Available for senior/lead roles and consulting.

bd.mhrubel@gmail.comHire Me

© 2026 Mahamudul Hasan Rubel. All rights reserved.

Built with using Next.js 16 & Tailwind v4

Back to Blog
Lesson 3 of the Intermediate WordPress Plugins: REST API & React Admin course
WordPressJune 25, 20263 min read

Configuring ESLint and Prettier for WordPress React Plugins

Master Code Quality in your WordPress plugins by configuring ESLint and Prettier. Learn to automate linting and formatting to keep your React code professional.

WordPressESLintPrettierReactDevelopment ToolsCode Qualityphpplugin-development

Previously in this course, we covered the Introduction to @wordpress/scripts to handle our build process. Now that we have a functional build pipeline, we need to ensure the code we're shipping meets professional standards.

Manual code reviews are slow and error-prone. By integrating ESLint and Prettier, we automate Code Quality, allowing our tools to catch common bugs and formatting inconsistencies before we even run our code.

Why ESLint and Prettier?

In a professional WordPress environment, consistency is king. ESLint focuses on logic and syntax—it catches undefined variables, unreachable code, and misuse of React hooks. Prettier, on the other hand, focuses on style—line breaks, indentation, and semicolon placement.

When used together, they eliminate "nitpicking" during code reviews. You spend less time worrying about tabs versus spaces and more time building features. Since we are using @wordpress/scripts, we already have the foundation for these tools.

Configuring ESLint

The @wordpress/scripts package comes with a pre-configured ESLint setup designed for WordPress development. However, we need to extend it for our specific needs.

  1. Create a .eslintrc.json file in your plugin root.
  2. Extend the WordPress configuration.
JSON
{
  "extends": [
    "plugin:@wordpress/eslint-plugin/recommended"
  ],
  "rules": {
    "no-console": "warn",
    "react/react-in-jsx-scope": "off"
  }
}

By extending plugin:@wordpress/eslint-plugin/recommended, you inherit rules that enforce WordPress coding standards for JavaScript. I've added no-console: "warn" because while we want to avoid console.log in production, they are often useful during development.

Implementing Prettier

Prettier ensures your code looks identical regardless of who wrote it. To implement it:

  1. Install the Prettier package via npm: npm install --save-dev prettier
  2. Create a .prettierrc file in your root directory:
JSON
{
  "singleQuote": true,
  "trailingComma": "es5",
  "printWidth": 80,
  "tabWidth": 2,
  "semi": true
}

This configuration ensures your code adheres to common modern JS standards. To make this work seamlessly with your editor, I highly recommend installing the Prettier extension for VS Code and enabling "Format on Save."

Resolving Linting Errors

Let’s advance our Knowledge Base plugin project. Suppose you have a component Dashboard.js with some messy code. Run the following command in your terminal:

npm run lint

If ESLint reports errors, you have two choices: fix them manually, or let the tool help. You can update your package.json scripts to include an auto-fixer:

JSON
"scripts": {
  "lint:js": "eslint .",
  "lint:js:fix": "eslint . --fix"
}

Running npm run lint:js:fix will automatically resolve many issues, such as missing semicolons or incorrect indentation, saving you significant manual effort.

Hands-on Exercise

  1. Add the .eslintrc.json and .prettierrc files to your plugin folder as shown above.
  2. Run npm run lint:js and identify at least three errors in your existing src/ folder.
  3. Use the --fix command to resolve them.
  4. If errors remain that cannot be auto-fixed (like missing dependencies in a useEffect hook), manually correct them to meet the WordPress standard.

Common Pitfalls

  • Ignoring the node_modules folder: Always ensure your .eslintignore file (or the ignore patterns in your config) excludes node_modules and your build/ directory. Linting third-party code is a waste of resources and will result in thousands of false positives.
  • Conflicting Rules: If you install both ESLint and Prettier, they might fight over formatting rules (like indentation). Use eslint-config-prettier to disable ESLint rules that might conflict with Prettier.
  • Over-customization: Stick to the WordPress recommended rules as much as possible. WordPress has a specific ecosystem; fighting the standards usually results in cleaner, more maintainable code when collaborating with other developers.

Recap

We have successfully integrated automated tooling into our workflow. By configuring ESLint and Prettier, we ensure that our codebase remains consistent, readable, and free of common syntax errors. This is the first step toward Refactoring for Clean Code: Improving React Maintainability as our project grows in complexity.

Up next: We will explore how to pass API base URLs and nonces from PHP to our JavaScript environment, ensuring our React components can securely communicate with the REST API.

Previous lessonIntroduction to @wordpress/scriptsNext lesson Localizing Data for JavaScript
Back to Blog

Similar Posts

WordPressJune 25, 20263 min read

Creating a React Form for Submissions in WordPress

Learn to build interactive React forms in WordPress using controlled components. Master state management and submission events for your admin dashboard.

Read more
WordPressJune 25, 20263 min read

Working with @wordpress/components for WordPress Admin UIs

Master the @wordpress/components library to build consistent, accessible, and native-feeling WordPress admin interfaces for your plugin's React dashboard.

Part of the course

Intermediate WordPress Plugins: REST API & React Admin

intermediate · Lesson 3 of 45

  1. 1

    Setting up the WordPress Development Environment

    3 min
  2. 2

    Introduction to @wordpress/scripts

    3 min
  3. 3

    Configuring ESLint and Prettier

    3 min
Read more
WordPressJune 25, 20263 min read

Scaffolding the React Admin Dashboard for WordPress Plugins

Learn how to scaffold your React admin dashboard by registering a WordPress menu, creating a root container, and mounting your application into the DOM.

Read more
  • 4

    Localizing Data for JavaScript

    3 min
  • 5

    Anatomy of a REST API Endpoint

    3 min
  • 6

    Implementing REST API Permission Callbacks

    3 min
  • 7

    Handling GET Requests in REST API

    3 min
  • 8

    Validating and Sanitizing API Arguments

    4 min
  • 9

    Creating POST Endpoints for Data Submission

    3 min
  • 10

    Updating Existing API Resources

    3 min
  • 11

    Handling Asynchronous State in React

    3 min
  • 12

    Building the Knowledge Base Service Layer

    3 min
  • 13

    Scaffolding the React Admin Dashboard

    3 min
  • 14

    Working with @wordpress/components

    3 min
  • 15

    Creating a React Form for Submissions

    3 min
  • 16

    Implementing CRUD in the Admin UI

    Coming soon
  • 17

    Understanding WordPress Data Store Architecture

    Coming soon
  • 18

    Registering a Custom Data Store

    Coming soon
  • 19

    Writing Selectors for Data Access

    Coming soon
  • 20

    Defining Actions and Reducers

    Coming soon
  • 21

    Implementing Resolvers for Data Fetching

    Coming soon
  • 22

    Optimizing Performance with Selectors

    Coming soon
  • 23

    Handling Complex State Dependencies

    Coming soon
  • 24

    Implementing Nonce Verification

    Coming soon
  • 25

    Advanced Sanitization Techniques

    Coming soon
  • 26

    Input Validation and Error Handling

    Coming soon
  • 27

    Protecting Admin Screens

    Coming soon
  • 28

    Production Build Pipeline

    Coming soon
  • 29

    Debugging React in the WordPress Admin

    Coming soon
  • 30

    Building Search and Filter Functionality

    Coming soon
  • 31

    Internationalization in React

    Coming soon
  • 32

    Managing File Uploads via REST API

    Coming soon
  • 33

    Optimizing API Response Times

    Coming soon
  • 34

    Working with Date and Time in React

    Coming soon
  • 35

    Implementing Drag-and-Drop Sorting

    Coming soon
  • 36

    Creating Custom Hooks for API Logic

    Coming soon
  • 37

    Integrating with Gutenberg Blocks

    Coming soon
  • 38

    Handling Conflict Resolution

    Coming soon
  • 39

    Building a Modal Confirmation System

    Coming soon
  • 40

    Implementing Activity Logging

    Coming soon
  • 41

    Using Webpack Aliases

    Coming soon
  • 42

    Unit Testing API Endpoints

    Coming soon
  • 43

    Unit Testing React Components

    Coming soon
  • 44

    Handling Large Datasets with GraphQL

    Coming soon
  • 45

    Implementing Real-time Updates with Web

    Coming soon
  • View full course