How to Fix the ‘No Restricted globals’ ESLint Error When Developing a React App?

Sometimes, we may run into the ‘No restricted globals’ ESLint Error when developing a React app.

In this article, we’ll look at how to fix the ‘No restricted globals’ ESLint Error when developing a React app.

Fix the ‘No Restricted globals’ ESLint Error When Developing a React App

To fix the ‘No restricted globals’ ESLint Error when developing a React app, we can add the // eslint-disable-next-line no-restricted-globals comment before the code that is causing the error.

But the better solution is to put window before the variable that causes the error.

For instance, instead of writing location, we write window.location.

Conclusion

To fix the ‘No restricted globals’ ESLint Error when developing a React app, we can add the // eslint-disable-next-line no-restricted-globals comment before the code that is causing the error.

But the better solution is to put window before the variable that causes the error.