
VS Code has built-in support for Node.js, JavaScript, and TypeScript. Happy Coding! Feel free to leave any feedback.Visual Studio Code, popularly known as VS Code, is one of the most used code editors. You may also want to disable specific rules which are not to your liking or do not follow your coding standards. prettierrc.json.Īs stated previously, see the Airbnb styling guide and react specific linting rules, to better understand the errors outputted by the linter. This issue will be solved, as we set the "tabWidth:2" in. If you followed the previous steps when configuring the prettier extension, save the file and it will auto-format the code. 'React' must be in scope when using JSX react/react-in-jsx-scopeĪdd React import to the file import React from 'react' Įxpected indentation of 2 spaces but found 4 indent: JSX not allowed in files with extension '.js' react/jsx-filename-extension Prop spreading is forbidden react/jsx-props-no-spreadingĮxplicitly state what props are to be received by the component. This is because the code generated by that command does not follow Airbnb’s styling guide conventions. If you made use of Airbnb’s styling guide, you may notice that some JavaScript files which were created when we executed the create-next-app command, are highlighted with errors. Well done, we managed to set up Prettier to our newly created Next.js project to help us maintain consistency throughout our codebase. Similar to the previous step when configuring ESLint, we may wish to ignore files from being “prettified” in our app.

In our projects, we usually ignore the following directories:

It is worth noting that we can also specify files that should be ignored by ESLint.

This file holds the configuration for our linter. When prompted to install dependencies select ‘yes’.Īfter answering all the questions, a new file will be created called.What format do you want your config file to be in? JSON.Which style guide do you want to follow? Airbnb (In this guide we use this style as it is our personal preference).How would you like to define a style for your project? Use a popular style guide.Which framework does your project use? React.What types of modules does your project use? Javascript modules (import/export).How would you like to use ESLint? To check syntax, find problems, and enforce code style.

Enter fullscreen mode Exit fullscreen modeĪfter executing the previous command, you will be prompted with a set of questions.
