
Tenant Data Isolation: Patterns and Anti-Patterns
Explore effective patterns and pitfalls of tenant data isolation in multi-tenant systems to enhance security and compliance.
Jul 30, 2025
Read MoreLinting React code ensures cleaner, more reliable, and consistent codebases. It helps catch errors, enforce coding standards, and improve collaboration, especially in team projects. Here's what you need to know:
eslint-plugin-react
, eslint-plugin-react-hooks
, and eslint-plugin-jsx-a11y
to handle JSX, hooks, and accessibility..eslintrc.json
and .prettierrc
for rules and formatting.When it comes to keeping your React code clean and consistent, two tools stand out: ESLint and Prettier. ESLint is a static analysis tool that identifies errors and enforces coding standards in your JavaScript and JSX. Prettier, on the other hand, is a code formatter that ensures your code follows a consistent style.
To make ESLint and Prettier work smoothly together, you'll need a couple of extra packages:
eslint-config-prettier
: Disables ESLint rules that conflict with Prettier.eslint-plugin-prettier
: Allows Prettier to run as an ESLint rule.Additionally, for React projects, you'll want plugins like eslint-plugin-react
, eslint-plugin-react-hooks
, and eslint-plugin-jsx-a11y
to handle React-specific linting.
Once you have these in place, you'll need to configure ESLint to bring everything together.
Setting up ESLint for your React project is simple, whether you're using Create React App or starting from scratch.
npm init @eslint/config
Or, if you're using Yarn:
yarn create @eslint/config
npm install eslint eslint-plugin-react eslint-plugin-react-hooks --save-dev
.eslintrc.json
file. Here's a basic example:
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended"
],
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true,
"es6": true,
"node": true
},
"settings": {
"react": {
"version": "detect"
}
}
}
You can tweak the rules
section to enforce or relax specific coding standards based on your project's needs.
package.json
with an ESLint script for easier usage:
"scripts": {
"lint": "eslint .",
"lint:src": "eslint src/**/*.{js,jsx}"
}
Now that ESLint is configured, it’s time to integrate it with Prettier.
To avoid conflicts between ESLint and Prettier, it's best to let each tool handle what it does best: Prettier formats the code, and ESLint enforces code quality.
npm install eslint-config-prettier eslint-plugin-prettier --save-dev
.eslintrc.json
to include Prettier's recommended settings:
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
]
}
.prettierrc
file to define your formatting preferences. Here's an example:
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2
}
package.json
for formatting and fixing linting issues:
"scripts": {
"format": "prettier --write .",
"lint:fix": "eslint . --fix"
}
React-specific linting rules are designed to catch common mistakes and encourage best practices. These rules go beyond standard JavaScript checks by addressing patterns and potential issues unique to React.
Some essential rules include react/jsx-uses-react
and react/jsx-uses-vars
, which prevent false positives when React or JSX variables seem unused. The react/no-danger
rule discourages using dangerouslySetInnerHTML
, helping to mitigate XSS vulnerabilities. For prop validation, react/prop-types
ensures components define their expected props, while react/no-unused-prop-types
flags props that are defined but not used.
When it comes to hooks, rules like react-hooks/rules-of-hooks
ensure that hooks are only called at the top level of a function, maintaining proper behavior. The react-hooks/exhaustive-deps
rule warns when dependencies are missing in hooks like useEffect
or useMemo
.
Accessibility is another critical area, and the jsx-a11y
plugin helps make applications more inclusive. Rules such as jsx-a11y/alt-text
enforce alternative text for images, jsx-a11y/anchor-has-content
ensures links are accessible, and jsx-a11y/form-has-label
checks that form controls have proper labels.
"Using the rules above will improve your code quality, consistency, and reduce the risk of bugs." - Tim James
In January 2023, Square adopted eslint-plugin-react-hooks
and eslint-plugin-jsx-a11y
in their React linting setup. This move ensured compliance with Hooks rules and addressed accessibility problems, such as missing alt
attributes on images or unlabeled input fields. These changes enhanced both the quality and inclusiveness of their React applications.
To implement these rules effectively, a well-planned configuration is crucial. The jsx-a11y
plugin offers both "recommended" and "strict" rule sets, giving teams the flexibility to adjust enforcement levels. Similarly, the React Hooks plugin includes an additionalHooks
option for validating custom hooks, but it’s best to use this feature sparingly to avoid overly complex configurations.
Next, consider integrating TypeScript to take your linting strategy to the next level.
TypeScript adds a layer of type safety to your React code, and combining it with ESLint can significantly improve code quality.
Installation and Setup involves adding the necessary TypeScript ESLint parser and plugin. Use @typescript-eslint/parser
to handle TypeScript syntax and @typescript-eslint/eslint-plugin
for TypeScript-specific linting rules. These replace the default ESLint parser for .ts
and .tsx
files.
Here’s an example of a typical .eslintrc.json
configuration:
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended"
],
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
"project": "./tsconfig.json"
}
}
TypeScript-specific rules further refine your code. For example, @typescript-eslint/no-unused-vars
detects unused variables more accurately, @typescript-eslint/explicit-function-return-type
enforces return type annotations, and @typescript-eslint/no-explicit-any
discourages the use of the any
type.
Keep in mind that enabling rules requiring type checking (via the project
parser option) can impact performance. To maintain a smooth workflow, consider running these rules only in CI/CD pipelines instead of during every file save.
Once TypeScript is set up, you may encounter exceptions or warnings that require fine-tuning.
Managing exceptions effectively ensures that your linting process remains productive without becoming overly restrictive. Occasionally, linters may flag valid code. In such cases, you can use inline disabling or adjust rule severity.
Inline Rule Disabling is a practical way to handle specific cases. For example, if you need to allow console.log
in a test file, you can disable the rule like this:
// For debugging purposes
// eslint-disable-next-line no-console
console.log("All tests were executed");
Configuration Adjustments can also help. For instance, when working with APIs that use snake_case for object keys, you can modify the camelcase rule in your .eslintrc
file:
{
"rules": {
"camelcase": ["error", { "properties": "never" }]
}
}
To keep exceptions manageable, document inline disable comments and treat them as temporary solutions. Instead of fully disabling a rule, consider lowering its severity from "error" to "warn" for cases that don’t justify a build failure but still deserve attention.
Once you've set up and configured your linting tools, the real challenge is weaving these practices seamlessly into your team's daily workflow. It’s not just about setting rules; it’s about creating a collaborative environment where everyone adheres to the same standards. In React projects, inconsistent linting can lead to avoidable headaches like merge conflicts and uneven code quality. Let’s dive into how shared configurations, automated pipelines, and developer education can streamline your linting processes.
Shared linting configurations act as the backbone of consistency across your team. They serve as a single source of truth, removing ambiguity and ensuring everyone is on the same page. When building a shareable configuration, stick to established naming conventions. For instance, prefix your configuration with something like eslint-config-
or use a scoped package name (e.g., @scope/eslint-config
). Make sure to declare ESLint as a peer dependency in your package.json
file and include any necessary plugins or custom parsers as dependencies.
Here’s an example of what a shared React linting configuration might look like:
{
"name": "@yourcompany/eslint-config-react",
"version": "1.0.0",
"main": "index.js",
"peerDependencies": {
"eslint": "^8.0.0"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint-plugin-react": "^7.0.0",
"eslint-plugin-react-hooks": "^4.0.0",
"eslint-plugin-jsx-a11y": "^6.0.0"
},
"keywords": ["eslint", "eslintconfig", "react"]
}
Popular shareable configurations, like those from Airbnb, Facebook, or Google, can also be excellent starting points.
Automating linting checks through CI/CD pipelines ensures every piece of code meets quality standards before it’s merged. Tools like ESLint integrate seamlessly into these pipelines to enforce consistent practices. For example, you can set up a Quality Gate to block non-compliant code from moving forward.
Here’s a sample GitHub Actions configuration for automating linting:
name: Code Quality
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm ci
- run: npm run lint
You can also take it a step further by implementing pre-commit hooks. These hooks can run linting, formatting, and tests on changed files before they’re even pushed, catching issues early and reducing the load on your CI/CD pipeline.
Even the most robust automation won’t work if your team isn’t aligned on linting practices. Developers need to understand not just the rules but also the reasoning behind them. A great way to achieve this is by documenting best practices in a CONTRIBUTING.md
file. This document should include:
Well-documented guidelines can reduce onboarding time and improve adherence rates significantly - up to 40% according to some studies. Regular training sessions and knowledge-sharing meetups can help keep the team up to date on new rules, updates to shared configurations, and lessons from recent code reviews. Peer reviews of documentation can further ensure clarity and consistency.
Keeping your React project’s code quality intact as it evolves requires consistent attention to linting. Here’s how to ensure your linting practices remain effective over time.
Maintaining code quality goes hand-in-hand with optimized workflows. Regular updates and automation can help your team stay on track.
To avoid vulnerabilities and ensure peak performance, it’s essential to regularly update your linting tools. Setting up a schedule - whether monthly or quarterly - can help you stay ahead of technical debt.
Automation tools like Dependabot or Renovate can simplify this process by creating pull requests whenever new versions of dependencies are available. This not only saves time but also ensures you’re always running the latest, safest versions. Be sure to review release notes for any updates, and remove unused dependencies to keep your project streamlined and secure.
After updating your dependencies, the next step is enforcing linting standards locally. Pre-commit hooks act as a safeguard, ensuring that only clean, standards-compliant code makes it into your repository. Tools like Husky make managing Git hooks straightforward, and when paired with Lint-Staged, they allow you to focus linting efforts only on the files that have been modified.
Here’s how it works: a developer stages changes, and upon committing, the pre-commit hook runs linting checks. If issues are detected, the commit is blocked, prompting the developer to address the problems before proceeding. Documenting these automated processes, along with any custom rules, helps establish consistent team practices.
Clear documentation is key to maintaining alignment across your team. Include custom rules and coding standards in files like the project’s README
or CONTRIBUTING.md
. Collaborate with your team to refine these guidelines, ensuring they reflect shared goals and reduce bottlenecks during code reviews.
As Artem Turlenko, a Frontend-Backend Engineer, aptly puts it:
"Effective code quality automation isn't about having the most rules - it's about having the right rules that: Catch real problems before they reach production, Enforce team standards without slowing development, Scale with your codebase and team size, Integrate seamlessly into your workflow."
Adopting effective linting practices can transform React development into a smoother, more predictable process. Studies show that thorough linting not only boosts efficiency but also enhances code quality across critical development metrics.
Linting does more than just catch syntax errors - it can significantly reduce bugs and improve workflow. For example, integrating code evaluation tools has been shown to decrease errors in JavaScript projects by up to 75%. Additionally, using a consistent code format can cut development time by roughly 30%. These advantages lead to faster project completion and more dependable applications.
The benefits extend to performance and team collaboration as well. Applications developed with strict coding standards often see a 50% improvement in load times. Teams report spending 33% less time debugging, and 70% of developers experience productivity gains when using linters. Case studies back this up: companies implementing ESLint report 25% fewer errors during peer reviews and a 40% reduction in post-deployment bugs. Teams that pair ESLint with Prettier also achieve 30% faster onboarding for new developers and a 15% boost in productivity.
Automated linting further optimizes workflows, saving an average of 15 minutes per commit. Over the course of a year, this adds up to around 240 hours saved per developer. These practices create a foundation for scalable, maintainable code throughout the development lifecycle.
At Propelius Technologies, we build on these proven benefits to deliver reliable React development solutions. With over 100 completed projects using React.js and related technologies, we consistently apply rigorous code quality practices, leveraging tools like TypeScript, ESLint, and Prettier.
Our development process incorporates linting at every stage to ensure high-quality, maintainable code. Whether you need end-to-end development through our Turnkey Delivery model or additional team support via our Developer-for-Hire service, we ensure your project adheres to industry-standard linting practices from the very beginning.
When working with React, ESLint and Prettier work hand-in-hand to boost both the quality and consistency of your code. ESLint zeroes in on spotting potential bugs, enforcing coding rules, and promoting best practices. Meanwhile, Prettier takes care of automatic code formatting, ensuring a uniform style throughout your team’s work.
Using these tools together can make your development process smoother. ESLint tackles code quality and logic issues, while Prettier keeps your code visually consistent. This clear division of responsibilities minimizes conflicts, enhances teamwork, and helps create cleaner, more dependable React applications.
When working with React applications, plugins like eslint-plugin-react-hooks
and eslint-plugin-jsx-a11y
can make a big difference in maintaining quality and consistency in your code.
The eslint-plugin-react-hooks
plugin is all about ensuring that React hooks are used correctly. It helps you avoid common pitfalls by enforcing rules, such as checking the dependency arrays in hooks like useEffect
. This keeps your code clean and reduces the chance of bugs sneaking in.
On the other hand, eslint-plugin-jsx-a11y
focuses on accessibility. It encourages developers to write code that works better for everyone, including users with disabilities. By pointing out accessibility issues, it helps you create apps that are more inclusive while also meeting important accessibility guidelines.
To keep your React project clean and consistent, you can automate linting and formatting by incorporating tools like ESLint and Prettier into your CI/CD pipeline. These tools work behind the scenes to enforce code quality standards, catching issues early in the build process - long before deployment.
Here's how it works: set up your pipeline to include dedicated steps for linting and formatting. ESLint can scan your codebase to identify and flag any rule violations, while Prettier takes care of ensuring a uniform code style. Want to take it a step further? Add a static analysis tool like SonarQube to uncover potential bugs and enforce additional coding rules.
By automating these processes, you can cut down on manual code reviews, maintain consistent quality, and follow best practices for React development - all without breaking a sweat.
Need an expert team to provide digital solutions for your business?
Book A Free CallDive into a wealth of knowledge with our unique articles and resources. Stay informed about the latest trends and best practices in the tech industry.
View All articlesGet in Touch
Let's Make It Happen
Get Your Free Quote Today!
Get in Touch
Let's Make It Happen
Get Your Free Quote Today!