Migrating to v3.0.0

ESLint v3.0.0 is the third major version release. We have made several breaking changes in this release, however, we believe the changes to be small enough that they should not require significant changes for ESLint users. This guide is intended to walk you through the changes.

Dropping Support for Node.js < 4

With ESLint v3.0.0, we are dropping support for Node.js versions prior to 4. Node.js 0.10 and 0.12 are in maintenance mode and Node.js 4 is the current LTS version. If you are using an older version of Node.js, we recommend upgrading to at least Node.js 4 as soon as possible. If you are unable to upgrade to Node.js 4 or higher, then we recommend continuing to use ESLint v2.x until you are ready to upgrade Node.js.

Important: We will not be updating the ESLint v2.x versions going forward. All bug fixes and enhancements will land in ESLint v3.x.

Requiring Configuration to Run

ESLint v3.0.0 now requires that you use a configuration to run. A configuration can be any of the following:

  1. A .eslintrc.js, .eslintrc.json, .eslintrc.yml, .eslintrc.yaml, or .eslintrc file either in your project or home directory.
  2. Configuration options passed on the command line using --rule (or to CLIEngine using rules).
  3. A configuration file passed on the command line using -c (or to CLIEngine using configFile).
  4. A base configuration is provided to CLIEngine using the baseConfig option.

If ESLint can’t find a configuration, then it will throw an error and ask you to provide one.

This change was made to help new ESLint users who are frequently confused that ESLint does nothing by default besides reporting parser errors. We anticipate this change will have minimal impact on most established users because you’re more likely to have configuration files already.

To Address: You should be sure to use a configuration whenever you run ESLint. However, you can still run ESLint without a configuration by passing the --no-eslintrc option on the command line or setting the useEslintrc option to false for CLIEngine.

To create a new configuration, use eslint --init.

Changes to "eslint:recommended"

{
    "extends": "eslint:recommended"
}

In 3.0.0, the following rules were added to "eslint:recommended":

The following rules were removed from "eslint:recommended":

The following rules were modified:

To address: If you want to mimic how eslint:recommended worked in v2.x, you can use the following:

{
    "extends": "eslint:recommended",
    "rules": {
        "no-unsafe-finally": "off",
        "no-native-reassign": "off",
        "complexity": ["off", 11],
        "comma-dangle": "error",
        "require-yield": "error"
    }
}

Changes to CLIEngine#executeOnText()

The CLIEngine#executeOnText() method has changed to work more like CLIEngine#executeOnFiles(). In v2.x, CLIEngine#executeOnText() warned about ignored files by default and didn’t have a way to opt-out of those warnings whereas CLIEngine#executeOnFiles() did not warn about ignored files by default and allowed you to opt-in to warning about them. The CLIEngine#executeOnText() method now also does not warn about ignored files by default and allows you to opt-in with a new, third argument (a boolean, true to warn about ignored files and false to not warn).

To address: If you are currently using CLIEngine#executeOnText() in your project like this:

var result = engine.executeOnText(text, filename);

You can get the equivalent behavior using this:

var result = engine.executeOnText(text, filename, true);

If you do not want ignored file warnings output to the console, you can omit the third argument or pass false.