ESLint v3.16.0 released

We just pushed ESLint v3.16.0, which is a minor release upgrade of ESLint. This release adds some new features and fixes several bugs found in the previous release.

Highlights

This is a summary of some of the notable changes in this version of ESLint.

Updated Token Iterator Methods

This release includes an exciting update for rule authors! Many of the token iterator methods provided by sourceCode have been updated with a new options parameter. Some highlights:

includeComments

Many of these methods can now include comments in the returned results using the { includeComments: true } option. The following methods are now deprecated:

  • sourceCode.getTokenOrCommentBefore(node)
  • sourceCode.getTokenOrCommentAfter(node)

Instead, please use the following, respectively:

  • sourceCode.getTokenBefore(node, { includeComments: true })
  • sourceCode.getTokenAfter(node, { includeComments: true })

filter

The filter option is a function that will filter the returned tokens. This allows for finding a specific token by type or value without having to create a loop.

For instance, the following:

let token = sourceCode.getTokenAfter(node);

while (token.type !== "Keyword") {
    token = sourceCode.getTokenAfter(token);
}

can now be written as:

const token = sourceCode.getTokenAfter(node, { filter: token => token.type === "Keyword" });

The update includes other options as well! For more details, please read the updated documentation.

Performance Improvements

Performance improvements were made to both the initial processing of source code as well as to autofixing.

Autofixing

Autofix support was added to one rule:

Enhancements

Bug Fixes

Documentation

Dependency Upgrades

Chores

  • 21be366 Chore: Ensuring eslint:recommended rules are sorted. (#8106) (Kevin Partington)
  • f62a724 Chore: use updated token iterator methods (#8103) (Kai Cataldo)
  • ff066dc Chore: Incorrect source code test text (#8096) (Jack Ford)
  • 55ac302 Chore: fix the timing to define rules for tests (#8082) (Toru Nagashima)
  • 591b74a Chore: enable operator-linebreak on ESLint codebase (#8064) (Teddy Katz)
  • fcc38db Chore: simplify and improve performance for autofix (#8035) (Toru Nagashima)
  • b04fde7 Chore: improve performance of SourceCode constructor (#8054) (Teddy Katz)
  • 329dcdc Chore: unify checks for statement list parents (#8048) (Teddy Katz)
  • 7bc92d9 Chore: fix invalid test cases (#8030) (Toru Nagashima)