Note: This version of ESLint is not ready for production use and is provided to gather feedback from the community before releasing the final version. Please let us know if you having any problems or feedback by creating issues.
Highlights
This is a summary of the major changes you need to know about for this version of ESLint.
Installing
Since this is a pre-release version, you will not automatically be upgraded by npm. You must specify the next
tag when installing:
npm i eslint@next --save-dev
You can also specify the version directly:
npm i eslint@1.0.0-rc-1 --save-dev
Migration Guide
As there are a lot of changes, we’ve created a migration guide describing the changes in great detail along with the steps you should take to address them. Not all ESLint users will be affected by the changes, however, the changes are big enough that we recommend everyone read the migration thoroughly.
New Language Features
1.0.0-rc-1 has been upgraded to the latest version of Espree, which means you now have access to additional language features:
newTarget
allows you to usenew.target
in your code.experimentalObjectRestSpread
allows you to use the experimental object rest/spread in your code.
As special note about object rest/spread: We added this as a result of feedback that this was the only feature missing from ESLint that made many React users switch to babel-eslint
. We thought it was silly to require React users to load an entirely separate parser for a single language feature, and since it kept being requested, we decided to add it. Keep in mind that this feature is still experimental and as such, the node types reflect that:
ExperimentalRestProperty
- represents rest properties in destructured objectsExperimentalSpreadProperty
- represents spread properties in object literals
These are non-standard nodes and may change at any time. We therefore recommend that you don’t create rules that used these directly unless you are willing to have those rules break when/if these nodes are standardized.
Keep in mind that this does not mean we will start supporting all experimental features, but we will continue evaluate them on a case-by-case basis.
–reset is now the default
The --reset
behavior is now the default behavior for ESLint and the --reset
flag has been removed. This means there are no rules on by default in ESLint; you must enable the rules that you want. For more information on this change and how it affects you, please see the migration guide.
Missing rules handled safely
In previous version, a missing rule would immediately cause ESLint to crash and exit. In this version, ESLint will just warn you about the missing rule, and if the rule has been replaced by something else, will tell you what rule to use instead.
New Rules
There are several new rules for this release:
arrow-parens
arrow-spacing
callback-return
init-declarations
no-class-assign
no-const-assign
no-useless-call
prefer-spread
require-yield
Breaking Changes
- Breaking: Create eslint:recommended and add to --init (fixes #2713) (Greg Cochard)
- Breaking: Default to --reset behavior (fixes #2100) (Brandon Mills)
- Breaking: Remove deprecated rules (fixes #1898) (Ian VanSchooten)
- Breaking: Switch to 1-based columns (fixes #2284) (Nicholas C. Zakas)
Features
- New:
context.getDeclaredVariables(node)
(fixes #2801) (Toru Nagashima) - New:
require-yield
rule (fixes #2822) (Toru Nagashima) - New: Add arrow-parens and arrow-spacing rule (fixes #2628) (Jxck)
- New: add callback-return rule (fixes #994) (Jamund Ferguson)
- New: Add exported comment option (fixes #1200) (Jamund Ferguson)
- New: Add init-declarations rule (fixes #2606) (cjihrig)
- New: Add serviceworker environment (fixes #2557) (Gyandeep Singh)
- New: Add support for root: true in config files (fixes #2736) (Ian VanSchooten)
- New: the
no-class-assign
rule (fixes #2718) (Toru Nagashima) - New: the
no-const-assign
rule (fixes #2719) (Toru Nagashima) - New: the
no-useless-call
rule (fixes #1925) (Toru Nagashima) - New: the
prefer-spread
rule (fixes #2946) (Toru Nagashima) - New: Warn on missing rule definition or deprecation (fixes #1549) (Ian VanSchooten)
Enhancements
- Update:
no-loop-func
allows block-scoped variables (fixes #2517) (Toru Nagashima) - Update: Add missing schema to rules (fixes #2858) (Ilya Volodin)
- Update: adding some tests for no-redeclare to test named functions (fixes #2953) (Dominic Barnes)
- Update: Attach parent in getNodeByRangeIndex (fixes #2863) (Brandon Mills)
- Update: Handle CRLF line endings in spaced-comment rule (fixes #2884) (David Anson)
- Update: Handle CRLF line endings in spaced-comment rule - 2 (fixes #3005) (Burak Yigit Kaya)
- Update: Loosens regex rules around intentional fall through comments (Fixes #2811) (greg5green)
Bug Fixes
- Fix:
no-redeclare
checks module scopes (fixes #2903) (Toru Nagashima) - Fix:
valid-jsdoc
countsreturn
for arrow expressions (fixes #2952) (Toru Nagashima) - Fix: add destructuring support to comma-dangle rule (fixes #2911) (Mathias Schreck)
- Fix: Added missing export syntax support to the block-scoped-var rule. (fixes #2887) (Mathieu M-Gosselin)
- Fix: Include execScript in no-implied-eval rule (fixes #2873) (Frederik Braun)
- Fix: Indent rule (fixes #1797, fixes #1799, fixes #2248, fixes #2343, fixes #2278, fixes #1800) (Gyandeep Singh)
- Fix: Indent rule error on empty block body (fixes #2999) (Gyandeep Singh)
- Fix: indent rule should recognize single line statements with ASI (fixes #3001, fixes #3000) (Mathias Schreck)
- Fix: lines-around-comment was crashing in some cases due to a missing check (fixes #2892) (Mathieu M-Gosselin)
- Fix: max-len to report correct column number (fixes #2926) (Mathias Schreck)
- Fix: multi-line + fat arrow indent (fixes #2239) (Gyandeep Singh)
- Fix: object-shorthand computed props (fixes #2937) (Jamund Ferguson)
- Fix: Remove invalid check inside
getJSDocComment
function (fixes #2938) (Gyandeep Singh) - Fix: Shallow cloning issues in eslint config (fixes #2961) (Gyandeep Singh)
- Fix: Support class syntax for line-around-comment rule (fixes #2894) (Gyandeep Singh)
- Fix: workaround for leading and trailing comments in padded-block (fixes #2336 and fixes #2788) (Mathias Schreck)
- Fix: Yoda should ignore comparisons where both sides are constants (fixes #2867) (cjihrig)
Documentation
- Docs: Add 1.0.0 migration guide (fixes #2994) (Nicholas C. Zakas)
- Docs: Add space-in-brackets deprecation notice (Brandon Mills)
- Docs: Add spaced-line-comment deprecation notice (Brandon Mills)
- Docs: array-bracket-spacing examples used space-in-brackets (Brandon Mills)
- Docs: clarification in no-unused-vars (Jan Schär)
- Docs: Clarify when not to use space-before-blocks (Ian VanSchooten)
- Docs: fix a typo (bartmichu)
- Docs: Fix typo (Bryan Smith)
- Docs: Fix typo in array-bracket-spacing rule (zallek)
- Docs: Fix typo in the shareable configs doc (Siddharth Kannan)
- Docs: missing quotes in JSON (Jan Schär)
- Docs: remove mistaken “off by default” (Jan Schär)
- Docs: Update changelog for 0.24.1 (fixes #2976) (Nicholas C. Zakas)
Build Related
- Build: Add appveyor CI system (fixes #2923) (Gyandeep Singh)
- Build: gensite target supports rule removal (refs #1898) (Brandon Mills)
Dependency Upgrades
- Upgrade: Espree to 2.2.0 (fixes #3011) (Nicholas C. Zakas)