ESLint v3.16.0 released
by Kai Cataldo - 20 February 2017We just pushed ESLint v3.16.0, which is a minor release upgrade of ESLint. This release adds a new feature 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
- d89d0b4 Update: fix quotes false negative for string literals as template tags (#8107) (Teddy Katz)
- 360dbe4 Update: Improve error message when extend config missing (fixes #6115) (#8100) (alberto)
- cfb65c5 Update: make no-lone-blocks report blocks in switch cases (fixes #8047) (#8062) (Teddy Katz)
- 290fb1f Update: Add includeComments to getTokenByRangeStart (fixes #8068) (#8069) (Kai Cataldo)
- acc3301 Update: handle uncommon linebreaks consistently in rules (fixes #7949) (#8049) (Teddy Katz)
- 90fd555 Update: improve null detection in eqeqeq for ES6 regexes (fixes #8020) (#8042) (Teddy Katz)
- 834f45d Update: rewrite TokenStore (fixes #7810) (#7936) (Toru Nagashima)
- 1e3d4c6 Update: add fixer for no-unused-labels (#7841) (Teddy Katz)
- f47fb98 Update: ensure semi-spacing checks import/export declarations (#8033) (Teddy Katz)
- e228d56 Update: no-undefined handles properties/classes/modules (fixes #7964) (#7966) (Kevin Partington)
Bug Fixes
- daf6f26 Fix: check output in RuleTester when errors is a number (fixes #7640) (#8097) (alberto)
- 7516303 Fix:
sourceCode.getTokenAfter
shouldn't skip tokens after comments (#8055) (Toru Nagashima) - c53e034 Fix: unicode-bom fixer insert BOM in appropriate location (fixes #8083) (#8084) (pantosha)
- 16248e2 Fix: no-extra-boolean-cast incorrect Boolean() autofixing (fixes #7977) (#8037) (Jonathan Wilsson)
Documentation
- 14d146d Docs: Clarify --ext only works with directories (fixes #7939) (#8095) (alberto)
- 013a454 Docs: Add TSC meeting quorum requirement (#8086) (Kevin Partington)
- 6445d2a Docs: Add documentation for /* exported */ (fixes #7998) (#8065) (Lee Yi Min)
- c596690 Docs: Clarify generator-star-spacing config example (fixes #8027) (#8034) (Hòa Trần)
- a11d4a6 Docs: fix a typo in shareable configs documentation (#8036) (Dan Homola)
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)