Skip to content

Commit a8784c0

Browse files
committed
Autogenerated new docs and demo at Fri Aug 28 2015 13:11:33
1 parent 64afe41 commit a8784c0

File tree

91 files changed

+3139
-1589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3139
-1589
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
layout: post
3+
title: ESLint v1.3.0 released
4+
tags:
5+
- release
6+
- minor
7+
---
8+
# ESLint v1.3.0 released
9+
10+
We just pushed ESLint v1.3.0, which is a minor release upgrade of ESLint. This release adds some new features and fixes several bugs found in the previous release.
11+
12+
13+
14+
15+
16+
17+
## Features
18+
19+
20+
* New: `no-useless-concat` rule (fixes [#3506](https://github.com/eslint/eslint/issues/3506)) (Henry Zhu)
21+
* New: Added HTML formatter (fixes [#3505](https://github.com/eslint/eslint/issues/3505)) (Julian Laval)
22+
* New: Protractor environment (fixes [#3457](https://github.com/eslint/eslint/issues/3457)) (James Whitney)
23+
24+
25+
26+
27+
## Enhancements
28+
29+
30+
* Update: Add `keywords` flag to `consistent-as-needed` mode in `quote-props` (fixes [#3532](https://github.com/eslint/eslint/issues/3532)) (Burak Yigit Kaya)
31+
* Update: adds `numbers` option to quote-props (fixes [#2914](https://github.com/eslint/eslint/issues/2914)) (Jose Roberto Vidal)
32+
* Update: Return to accept `undefined` type (fixes [#3382](https://github.com/eslint/eslint/issues/3382)) (Gyandeep Singh)
33+
* Update: Quote var name in `no-unused-vars` error messages (refs [#3526](https://github.com/eslint/eslint/issues/3526)) (Burak Yigit Kaya)
34+
* Update: Move methods to SourceCode (fixes [#3516](https://github.com/eslint/eslint/issues/3516)) (Nicholas C. Zakas)
35+
* Update: Add quotes around the label in `no-empty-label` error reports (fixes [#3526](https://github.com/eslint/eslint/issues/3526)) (Burak Yigit Kaya)
36+
* Update: `newline-after-var` Allow comment + blank after var (fixes [#2852](https://github.com/eslint/eslint/issues/2852)) (Ian VanSchooten)
37+
* Update: Add `unnecessary` option to `quote-props` (fixes [#3381](https://github.com/eslint/eslint/issues/3381)) (Burak Yigit Kaya)
38+
* Update: separate options for block and line comments in `spaced-comment` rule (fixes [#2897](https://github.com/eslint/eslint/issues/2897)) (Burak Yigit Kaya)
39+
* Update: Added "properties" option to `id-length` rule to ignore property names. (fixes [#3450](https://github.com/eslint/eslint/issues/3450)) (Mathieu M-Gosselin)
40+
* Update: add new ignore pattern options to no-unused-vars (fixes [#2321](https://github.com/eslint/eslint/issues/2321)) (Mathias Schreck)
41+
* Update: Allow pre-parsed code (fixes [#1025](https://github.com/eslint/eslint/issues/1025), fixes [#948](https://github.com/eslint/eslint/issues/948)) (Nicholas C. Zakas)
42+
43+
44+
45+
46+
## Bug Fixes
47+
48+
49+
* Fix: `quote-props` rule should ignore computed and shorthand properties (fixes [#3557](https://github.com/eslint/eslint/issues/3557)) (fixes [#3544](https://github.com/eslint/eslint/issues/3544)) (Burak Yigit Kaya)
50+
* Fix: check space after yield keyword in space-unary-ops (fixes [#2707](https://github.com/eslint/eslint/issues/2707)) (Mathias Schreck)
51+
* Fix: Don't try too hard to find fault in `no-implicit-coercion` (refs [#3402](https://github.com/eslint/eslint/issues/3402)) (Burak Yigit Kaya)
52+
* Fix: Detect ternary operator in operator-linebreak rule (fixes [#3274](https://github.com/eslint/eslint/issues/3274)) (Burak Yigit Kaya)
53+
* Fix: ASI indentation issue (fixes [#3514](https://github.com/eslint/eslint/issues/3514)) (Burak Yigit Kaya)
54+
* Fix: Make `no-implicit-coercion` smarter about numerical expressions (fixes [#3510](https://github.com/eslint/eslint/issues/3510)) (Burak Yigit Kaya)
55+
* Fix: `prefer-template` had not been handling TemplateLiteral as literal node (fixes [#3507](https://github.com/eslint/eslint/issues/3507)) (Toru Nagashima)
56+
* Fix: `indent` shouldn't check the last line unless it is a punctuator (fixes [#3498](https://github.com/eslint/eslint/issues/3498)) (Burak Yigit Kaya)
57+
* Fix: `indent` rule does not indent when doing multi-line chain calls (fixes [#3279](https://github.com/eslint/eslint/issues/3279)) (Burak Yigit Kaya)
58+
* Fix: sort-vars rule fails when memo is undefined (fixes [#3474](https://github.com/eslint/eslint/issues/3474)) (Burak Yigit Kaya)
59+
* Fix: `brace-style` doesn't report some closing brace errors (fixes [#3486](https://github.com/eslint/eslint/issues/3486)) (Burak Yigit Kaya)
60+
* Fix: `indent` does not check FunctionDeclaration nodes properly (fixes [#3173](https://github.com/eslint/eslint/issues/3173)) (Burak Yigit Kaya)
61+
62+
63+
64+
65+
## Documentation
66+
67+
68+
* Docs: Add config comments for rule examples 'accessor-pairs' to 'no-extra-semi' (refs [#2271](https://github.com/eslint/eslint/issues/2271)) (Ian VanSchooten)
69+
* Docs: (curly) Fix broken code in example (Kent C. Dodds)
70+
* Docs: Clearer plugin rule configuration (fixes [#2022](https://github.com/eslint/eslint/issues/2022)) (Nicholas C. Zakas)
71+
* Docs: Turn off Liquid in example (Nicholas C. Zakas)
72+
* Docs: Mention CommonJS along with Node.js (fixes [#3388](https://github.com/eslint/eslint/issues/3388)) (Nicholas C. Zakas)
73+
* Docs: Make it clear which rules are recommended (fixes [#3398](https://github.com/eslint/eslint/issues/3398)) (Nicholas C. Zakas)
74+
* Docs: Add links to JSON Schema resources (fixes [#3411](https://github.com/eslint/eslint/issues/3411)) (Nicholas C. Zakas)
75+
* Docs: Add more info to migration guide (fixes [#3439](https://github.com/eslint/eslint/issues/3439)) (Nicholas C. Zakas)
76+
* Docs: Added section to shareable config (Gregory Waxman)
77+
78+
79+
80+
81+
82+
83+
## Build Related
84+
85+
86+
* Build: Autogenerate release blog post (fixes [#3562](https://github.com/eslint/eslint/issues/3562)) (Nicholas C. Zakas)
87+
88+

docs/developer-guide/nodejs-api.md

+44-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ While ESLint is designed to be run on the command line, it's possible to use ESL
99

1010
**Note:** Use undocumented parts of the API at your own risk. Only those parts that are specifically mentioned in this document are approved for use and will remain stable and reliable. Anything left undocumented is unstable and may change or be removed at any point.
1111

12+
## SourceCode
13+
14+
The `SourceCode` type represents the parsed source code that ESLint executes on. It's used internally in ESLint and is also available so that already-parsed code can be used. You can create a new instance of `SourceCode` by passing in the text string representing the code and an abstract syntax tree (AST) in [ESTree](https://github.com/estree/estree) format (including location information, range information, comments, and tokens):
15+
16+
```js
17+
var SourceCode = require("eslint").SourceCode;
18+
19+
var code = new SourceCode("var foo = bar;", ast);
20+
```
21+
22+
The `SourceCode` constructor throws an error if the AST is missing any of the required information.
23+
1224
## linter
1325

1426
The `linter` object does the actual evaluation of the JavaScript code. It doesn't do any filesystem operations, it simply parses and reports on the code. You can retrieve `linter` like this:
@@ -19,7 +31,7 @@ var linter = require("eslint").linter;
1931

2032
The most important method on `linter` is `verify()`, which initiates linting of the given text. This method accepts four arguments:
2133

22-
* `code` - the source code to lint (a string).
34+
* `code` - the source code to lint (a string or instance of `SourceCode`).
2335
* `config` - a configuration object.
2436
* `filename` - (optional) the filename to associate with the source code.
2537
* `saveState` - (optional) set to true to maintain the internal state of `linter` after linting (mostly used for testing purposes).
@@ -34,6 +46,19 @@ var messages = linter.verify("var foo;", {
3446
semi: 2
3547
}
3648
}, "foo.js");
49+
50+
// or using SourceCode
51+
52+
var linter = require("eslint").linter,
53+
SourceCode = require("eslint").SourceCode;
54+
55+
var code = new SourceCode("var foo = bar;", ast);
56+
57+
var messages = linter.verify(code, {
58+
rules: {
59+
semi: 2
60+
}
61+
}, "foo.js");
3762
```
3863

3964
The `verify()` method returns an array of objects containing information about the linting warnings and errors. Here's an example:
@@ -61,6 +86,24 @@ The information available for each linting message is:
6186
* `severity` - either 1 or 2, depending on your configuration.
6287
* `source` - the line of code where the problem is (or empty string if it can't be found).
6388

89+
You can also get an instance of the `SourceCode` object used inside of `linter` by using the `getSourceCode()` method:
90+
91+
```js
92+
var linter = require("eslint").linter;
93+
94+
var messages = linter.verify("var foo = bar;", {
95+
rules: {
96+
semi: 2
97+
}
98+
}, "foo.js");
99+
100+
var code = linter.getSourceCode();
101+
102+
console.log(code.text); // "var foo = bar;"
103+
```
104+
105+
In this way, you can retrieve the text and AST used for the last run of `linter.verify()`.
106+
64107
## CLIEngine
65108

66109
The primary Node.js API is `CLIEngine`, which is the underlying utility that runs the ESLint command line interface. This object will read the filesystem for configuration and file information but will not output any results. Instead, it allows you direct access to the important information so you can deal with the output yourself.

docs/developer-guide/shareable-configs.md

+67
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,73 @@ Note that you can leave off the `.js` from the filename. In this way, you can ad
9191

9292
**Important:** We strongly recommend always including a default config for your plugin to avoid errors.
9393

94+
## Local Config File Resolution
95+
96+
If you need to make multiple configs that can extend from each other and live in different directories, you can create a single shareable config that handles this scenario.
97+
98+
As an example, let's assume you're using the package name `eslint-config-myconfig` and your package looks something like this:
99+
100+
```text
101+
myconfig
102+
├── index.js
103+
└─┬ lib
104+
├── defaults.js
105+
├── dev.js
106+
├── ci.js
107+
└─┬ ci
108+
├── frontend.js
109+
├── backend.js
110+
└── common.js
111+
```
112+
113+
In your `index.js` you can do something like this:
114+
115+
```js
116+
module.exports = require('./lib/ci.js);
117+
```
118+
119+
Now inside your package you have `/lib/defaults.js`, which contains:
120+
121+
```js
122+
module.exports = {
123+
rules: {
124+
'no-console': 1
125+
}
126+
};
127+
```
128+
129+
Inside your `/lib/ci.js` you have
130+
131+
```js
132+
module.exports = require('./ci/backend');
133+
```
134+
135+
Inside your `/lib/ci/common.js`
136+
137+
```js
138+
module.exports = {
139+
rules: {
140+
'no-alert': 2
141+
},
142+
extends: 'myconfig/lib/defaults'
143+
};
144+
```
145+
146+
Despite being in an entirely different directory, you'll see that all `extends` must use the full package path to the config file you wish to extend.
147+
148+
Now inside your `/lib/ci/backend.js`
149+
150+
```js
151+
module.exports = {
152+
rules: {
153+
'no-console': 1
154+
},
155+
extends: 'myconfig/lib/ci/common'
156+
};
157+
```
158+
159+
In the last file, you'll once again see that to properly resolve your config, you'll need include the full package path.
160+
94161
## Further Reading
95162

96163
* [npm Developer Guide](https://www.npmjs.org/doc/misc/npm-developers.html)

0 commit comments

Comments
 (0)