Forrest logo
back to the eslint tool

eslint:tldr:10a46

eslint: Create the ESLint config file.
$ eslint --init
try on your machine

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:

  1. 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.
  2. 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.
  3. Where will your code run?

    • You can specify your project environment, such as the browser, Node.js, or both.
  4. 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.
  5. 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.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the eslint tool