![Forrest logo](/images/logo.png)
eslint:tldr:10a46
The command eslint --init
is used to initialize a new ESLint configuration file for a project.
ESLint is a popular open-source JavaScript linter that helps identify and report issues in code and ensures code quality and adherence to coding standards. By using rules defined in the ESLint configuration file, developers can automatically enforce coding styles, find common coding mistakes, and promote best practices.
When you run eslint --init
, it prompts you with a series of questions to configure your project's ESLint setup. These questions include:
-
How would you like to configure ESLint?
- Here, you can choose whether to set up a basic configuration or select a popular style guide (such as Airbnb or Standard) as a starting point for your rules. Alternatively, you can answer questions to customize the rules yourself.
-
Are you using ECMAScript modules?
- You can choose "Yes" if your project uses ES6 modules (import/export syntax) or "No" if you use a different module system.
-
Where will your code run?
- You can specify your project environment, such as the browser, Node.js, or both.
-
Do you use JSX?
- If your project includes JSX syntax (React), you can choose "Yes" for enabling appropriate rule support, or "No" if not applicable.
-
What style of indentation do you use?
- You can select your preferred indentation style, like spaces or tabs.
After answering these questions, ESLint generates an appropriate configuration file (typically named .eslintrc.js
or .eslintrc.json
) based on your choices. This file will be placed in the root directory of your project and includes the selected rule sets or customizations.
Once the ESLint configuration file is set up, you can run eslint
on your project to identify coding issues and enforce the defined rules.