Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
Autogenerated new docs and demo at Fri Dec 09 2016 11:56:38
Browse files Browse the repository at this point in the history
  • Loading branch information
ESLint Jenkins committed Dec 9, 2016
1 parent fef7006 commit 0ce3dc1
Show file tree
Hide file tree
Showing 15 changed files with 946 additions and 340 deletions.
6 changes: 5 additions & 1 deletion _data/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ categories:
- description: 'These rules relate to possible syntax or logic errors in JavaScript code:'
name: Possible Errors
rules:
- description: disallow `await` inside of loops
fixable: false
name: no-await-in-loop
recommended: false
- description: disallow assignment operators in conditional expressions
fixable: false
name: no-cond-assign
Expand Down Expand Up @@ -548,7 +552,7 @@ categories:
name: camelcase
recommended: false
- description: enforce or disallow capitalization of the first letter of a comment
fixable: false
fixable: true
name: capitalized-comments
recommended: false
- description: require or disallow trailing commas
Expand Down
84 changes: 84 additions & 0 deletions _posts/2016-12-09-eslint-v3.12.0-released.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
layout: post
title: ESLint v3.12.0 released
tags:
- release
- minor
---
# ESLint v3.12.0 released

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






## Features


* [1d0d61d](https://github.com/eslint/eslint/commit/1d0d61d) New: Add [no-await-in-loop](/docs/rules/no-await-in-loop) rule ([#7563](https://github.com/eslint/eslint/issues/7563)) (Nat Mote)
* [2cdfb4e](https://github.com/eslint/eslint/commit/2cdfb4e) New: Additional APIs (fixes [#6256](https://github.com/eslint/eslint/issues/6256)) ([#7669](https://github.com/eslint/eslint/issues/7669)) (Ilya Volodin)




## Enhancements


* [e569225](https://github.com/eslint/eslint/commit/e569225) Update: fix false positive/negative of [yoda](/docs/rules/yoda) rule (fixes [#7676](https://github.com/eslint/eslint/issues/7676)) ([#7695](https://github.com/eslint/eslint/issues/7695)) (Toru Nagashima)
* [4278c42](https://github.com/eslint/eslint/commit/4278c42) Update: make [no-obj-calls](/docs/rules/no-obj-calls) report errors for Reflect (fixes [#7700](https://github.com/eslint/eslint/issues/7700)) ([#7710](https://github.com/eslint/eslint/issues/7710)) (Tomas Echeverri Valencia)
* [b921d1f](https://github.com/eslint/eslint/commit/b921d1f) Update: add [`indent`](/docs/rules/`indent`) options for array and object literals (fixes [#7473](https://github.com/eslint/eslint/issues/7473)) ([#7681](https://github.com/eslint/eslint/issues/7681)) (Teddy Katz)
* [7079c89](https://github.com/eslint/eslint/commit/7079c89) Update: Add airbnb-base to init styleguides (fixes [#6986](https://github.com/eslint/eslint/issues/6986)) ([#7699](https://github.com/eslint/eslint/issues/7699)) (alberto)
* [f8786fb](https://github.com/eslint/eslint/commit/f8786fb) Update: add fixer for [`capitalized-comments`](/docs/rules/`capitalized-comments`) ([#7701](https://github.com/eslint/eslint/issues/7701)) (Teddy Katz)




## Bug Fixes


* [e95a230](https://github.com/eslint/eslint/commit/e95a230) Fix: [indent](/docs/rules/indent) "first" option false positive on nested arrays (fixes [#7727](https://github.com/eslint/eslint/issues/7727)) ([#7728](https://github.com/eslint/eslint/issues/7728)) (Teddy Katz)
* [81f9e7d](https://github.com/eslint/eslint/commit/81f9e7d) Fix: Allow duplicated let declarations in [`prefer-const`](/docs/rules/`prefer-const`) (fixes [#7712](https://github.com/eslint/eslint/issues/7712)) ([#7717](https://github.com/eslint/eslint/issues/7717)) (Teddy Katz)
* [abfd24f](https://github.com/eslint/eslint/commit/abfd24f) Fix: don't validate schemas for disabled rules (fixes [#7690](https://github.com/eslint/eslint/issues/7690)) ([#7692](https://github.com/eslint/eslint/issues/7692)) (Teddy Katz)
* [0a2a7fd](https://github.com/eslint/eslint/commit/0a2a7fd) Fix: Allow \u2028 and \u2029 as string escapes in [no-useless-escape](/docs/rules/no-useless-escape) ([#7672](https://github.com/eslint/eslint/issues/7672)) (Teddy Katz)




## Documentation


* [4742d82](https://github.com/eslint/eslint/commit/4742d82) Docs: clarify the default behavior of [`operator-linebreak`](/docs/rules/`operator-linebreak`) (fixes [#7459](https://github.com/eslint/eslint/issues/7459)) ([#7726](https://github.com/eslint/eslint/issues/7726)) (Teddy Katz)
* [63bb3f8](https://github.com/eslint/eslint/commit/63bb3f8) Docs: improve the documentation for the autofix API ([#7716](https://github.com/eslint/eslint/issues/7716)) (Teddy Katz)
* [90a5d29](https://github.com/eslint/eslint/commit/90a5d29) Docs: Remove incorrect info about issue requirements from PR guide ([#7691](https://github.com/eslint/eslint/issues/7691)) (Teddy Katz)
* [f80c278](https://github.com/eslint/eslint/commit/f80c278) Docs: Add sails-hook-lint to integrations list ([#7679](https://github.com/eslint/eslint/issues/7679)) (Anthony M)
* [e96da3f](https://github.com/eslint/eslint/commit/e96da3f) Docs: link first instance of `package.json` ([#7684](https://github.com/eslint/eslint/issues/7684)) (Kent C. Dodds)
* [b30116c](https://github.com/eslint/eslint/commit/b30116c) Docs: Fix code-blocks in [spaced-comment](/docs/rules/spaced-comment) docs ([#7524](https://github.com/eslint/eslint/issues/7524)) (Michał Gołębiowski)
* [76c33a9](https://github.com/eslint/eslint/commit/76c33a9) Docs: Change Sails.js integration to active npm package ([#7675](https://github.com/eslint/eslint/issues/7675)) (Anthony M)




## Dependency Upgrades


* [2ac07d8](https://github.com/eslint/eslint/commit/2ac07d8) Upgrade: Update globals dependency to 9.14.0 ([#7683](https://github.com/eslint/eslint/issues/7683)) (Aleksandr Oleynikov)




## Build Related


* [bf20e20](https://github.com/eslint/eslint/commit/bf20e20) Build: include links to rule pages in release blogpost ([#7671](https://github.com/eslint/eslint/issues/7671)) (Teddy Katz)




## Chores


* [a8489e2](https://github.com/eslint/eslint/commit/a8489e2) Chore: Avoid parserOptions boilerplate in tests for ES6 rules ([#7724](https://github.com/eslint/eslint/issues/7724)) (Teddy Katz)


2 changes: 0 additions & 2 deletions docs/developer-guide/contributing/pull-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ If there are any failing tests, update your code until all tests pass.
With your code ready to go, this is a good time to double-check your submission to make sure it follows our conventions. Here are the things to check:

* Run `npm run check-commit` to double-check that your commit is formatted correctly.
* Make sure there is an issue for any pull request you send.
* The only exception is for documentation changes.
* The pull request must have a description. The description should explain what you did and how its effects can be seen.
* The commit message is properly formatted.
* The change introduces no functional regression. Be sure to run `npm test` to verify your changes before submitting a pull request.
Expand Down
21 changes: 18 additions & 3 deletions docs/developer-guide/working-with-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ context.report({
});
```

Here, the `fix()` function is used to insert a semicolon after the node. Note that the fix is not immediately applied and may not be applied at all if there are conflicts with other fixes. If the fix cannot be applied, then the problem message is reported as usual; if the fix can be applied, then the problem message is not reported.
Here, the `fix()` function is used to insert a semicolon after the node. Note that a fix is not immediately applied, and may not be applied at all if there are conflicts with other fixes. After applying fixes, ESLint will run all of the enabled rules again on the fixed code, potentially applying more fixes. This process will repeat up to 10 times, or until no more fixable problems are found. Afterwards, any remaining problems will be reported as usual.

**Important:** Unless the rule [exports](#rule-basics) the `meta.fixable` property, ESLint does not apply fixes even if the rule implements `fix` functions.

Expand All @@ -204,9 +204,24 @@ The `fixer` object has the following methods:

Best practices for fixes:

1. Make fixes that are as small as possible. Anything more than a single character is risky and could prevent other, simpler fixes from being made.
1. Avoid any fixes that could change the runtime behavior of code and cause it to stop working.
1. Make fixes as small as possible. Fixes that are unnecessarily large could conflict with other fixes, and prevent them from being applied.
1. Only make one fix per message. This is enforced because you must return the result of the fixer operation from `fix()`.
1. Fixes should not introduce clashes with other rules. You can accidentally introduce a new problem that won't be reported until ESLint is run again. Another good reason to make as small a fix as possible.
1. Since all rules are run again after the initial round of fixes is applied, it's not necessary for a rule to check whether the code style of a fix will cause errors to be reported by another rule.
* For example, suppose a fixer would like to surround an object key with quotes, but it's not sure whether the user would prefer single or double quotes.

```js
({ foo : 1 })

// should get fixed to either

({ 'foo': 1 })

// or

({ "foo": 1 })
```
* This fixer can just select a quote type arbitrarily. If it guesses wrong, the resulting code will be automatically reported and fixed by the [`quotes`](/docs/rules/quotes) rule.

### context.options

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/capitalized-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ layout: doc

# enforce or disallow capitalization of the first letter of a comment (capitalized-comments)

(fixable) The `--fix` option on the [command line](../user-guide/command-line-interface#fix) automatically fixes problems reported by this rule.

Comments are useful for leaving information for future developers. In order for that information to be useful and not distracting, it is sometimes desirable for comments to follow a particular style. One element of comment formatting styles is whether the first word of a comment should be capitalized or lowercase.

In general, no comment style is any more or less valid than any others, but many developers would agree that a consistent style can improve a project's maintainability.
Expand Down
95 changes: 95 additions & 0 deletions docs/rules/indent.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ This rule has an object option:
* `body` (default: 1) enforces indentation level for the body of a function expression.
* `"CallExpression"` takes an object to define rules for function call expressions.
* `arguments` (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string `"first"` indicating that all arguments of the expression must be aligned with the first argument.
* `"ArrayExpression"` (default: 1) enforces indentation level for elements in arrays. It can also be set to the string `"first"`, indicating that all the elements in the array should be aligned with the first element.
* `"ObjectExpression"` (default: 1) enforces indentation level for properties in objects. It can be set to the string `"first"`, indicating that all properties in the object should be aligned with the first property.

Level of indentation denotes the multiple of the indent specified. Example:

Expand Down Expand Up @@ -436,6 +438,99 @@ foo(bar, baz,
baz, boop, beep);
```

### ArrayExpression

Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": 1 }` option:

```js
/*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/

var foo = [
bar,
baz,
qux
];
```

Examples of **correct** code for this rule with the `2, { "ArrayExpression": 1 }` option:

```js
/*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/

var foo = [
bar,
baz,
qux
];
```

Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": "first" }` option:

```js
/*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/

var foo = [bar,
baz,
qux
];
```

Examples of **correct** code for this rule with the `2, { "ArrayExpression": "first" }` option:

```js
/*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/

var foo = [bar,
baz,
qux
];
```

### ObjectExpression

Examples of **incorrect** code for this rule with the `2, { "ObjectExpression": 1 }` option:

```js
/*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/

var foo = {
bar: 1,
baz: 2,
qux: 3
};
```

Examples of **correct** code for this rule with the `2, { "ObjectExpression": 1 }` option:

```js
/*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/

var foo = {
bar: 1,
baz: 2,
qux: 3
};
```

Examples of **incorrect** code for this rule with the `2, { "ObjectExpression": "first" }` option:

```js
/*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/

var foo = { bar: 1,
baz: 2 };
```

Examples of **correct** code for this rule with the `2, { "ObjectExpression": "first" }` option:

```js
/*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/

var foo = { bar: 1,
baz: 2 };
```


## Compatibility

* **JSHint**: `indent`
Expand Down
89 changes: 89 additions & 0 deletions docs/rules/no-await-in-loop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: no-await-in-loop - Rules
layout: doc
---
<!-- Note: No pull requests accepted for this file. See README.md in the root directory for details. -->

# Disallow `await` inside of loops (no-await-in-loop)

Performing an operation on each element of an iterable is a common task. However, performing an
`await` as part of each operation is an indication that the program is not taking full advantage of
the parallelization benefits of `async`/`await`.

Usually, the code should be refactored to create all the promises at once, then get access to the
results using `Promise.all()`. Otherwise, each successive operation will not start until the
previous one has completed.

Concretely, the following function should be refactored as shown:

```js
async function foo(things) {
const results = [];
for (const thing of things) {
// Bad: each loop iteration is delayed until the entire asynchronous operation completes
results.push(await bar(thing));
}
return baz(results);
}
```

```js
async function foo(things) {
const results = [];
for (const thing of things) {
// Good: all asynchronous operations are immediately started.
results.push(bar(thing));
}
// Now that all the asynchronous operations are running, here we wait until they all complete.
return baz(await Promise.all(results));
}
```

## Rule Details

This rule disallows the use of `await` within loop bodies.

## Examples

Examples of **correct** code for this rule:

```js
async function foo(things) {
const results = [];
for (const thing of things) {
// Good: all asynchronous operations are immediately started.
results.push(bar(thing));
}
// Now that all the asynchronous operations are running, here we wait until they all complete.
return baz(await Promise.all(results));
}
```

Examples of **incorrect** code for this rule:

```js
async function foo(things) {
const results = [];
for (const thing of things) {
// Bad: each loop iteration is delayed until the entire asynchronous operation completes
results.push(await bar(thing));
}
return baz(results);
}
```

## When Not To Use It

In many cases the iterations of a loop are not actually independent of each-other. For example, the
output of one iteration might be used as the input to another. Or, loops may be used to retry
asynchronous operations that were unsuccessful. In such cases it makes sense to use `await` within a
loop and it is recommended to disable the rule via a standard ESLint disable comment.

## Version

This rule was introduced in ESLint 3.12.0.

## Resources

* [Rule source](https://github.com/eslint/eslint/tree/master/lib/rules/no-await-in-loop.js)
* [Documentation source](https://github.com/eslint/eslint/tree/master/docs/rules/no-await-in-loop.md)
8 changes: 7 additions & 1 deletion docs/rules/no-obj-calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ The [ECMAScript 5 specification](http://es5.github.io/#x15.8) makes it clear tha

> The Math object does not have a `[[Call]]` internal property; it is not possible to invoke the Math object as a function.
And the [ECMAScript 2015 specification](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-reflect-object) makes it clear that `Reflect` cannot be invoked:

> The Reflect object also does not have a `[[Call]]` internal method; it is not possible to invoke the Reflect object as a function.
## Rule Details

This rule disallows calling the `Math` and `JSON` objects as functions.
This rule disallows calling the `Math`, `JSON` and `Reflect` objects as functions.

Examples of **incorrect** code for this rule:

Expand All @@ -23,6 +27,7 @@ Examples of **incorrect** code for this rule:

var math = Math();
var json = JSON();
var reflect = Reflect();
```

Examples of **correct** code for this rule:
Expand All @@ -34,6 +39,7 @@ function area(r) {
return Math.PI * r * r;
}
var object = JSON.parse("{}");
var value = Reflect.get({ x: 1, y: 2 }, "x");
```

## Further Reading
Expand Down
Loading

0 comments on commit 0ce3dc1

Please sign in to comment.