Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: use eslint #5053

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
06b7a92
tools: add eslint-plugin-markdown to tools
tflanagan Feb 3, 2016
7ef37e7
build: add jslint-docs
tflanagan Feb 3, 2016
b1d72c4
doc: fix zlib.markdown code examples
tflanagan Feb 3, 2016
f33102f
doc: fix vm.markdown code examples
tflanagan Feb 3, 2016
dce6f63
doc: fix v8.markdown code examples
tflanagan Feb 3, 2016
785cf8a
doc: fix util.markdown code examples
tflanagan Feb 3, 2016
28c097e
doc: fix url.markdown code examples
tflanagan Feb 3, 2016
12c2164
doc: fix tls.markdown code examples
tflanagan Feb 3, 2016
a1ccb3f
doc: fix synopsis.markdown code examples
tflanagan Feb 3, 2016
0a8e050
doc: fix string_decoder.markdown code examples
tflanagan Feb 3, 2016
a092aff
doc: fix stream.markdown code examples
tflanagan Feb 3, 2016
844a648
doc: fix repl.markdown code examples
tflanagan Feb 3, 2016
fe84729
doc: fix readline.markdown code examples
tflanagan Feb 3, 2016
cd82e93
doc: fix querystring.markdown code examples
tflanagan Feb 3, 2016
aec9d27
doc: fix process.markdown code examples
tflanagan Feb 3, 2016
91b5733
doc: fix path.markdown code examples
tflanagan Feb 3, 2016
8a0517d
doc: fix punycode.markdown code examples
tflanagan Feb 3, 2016
2141a53
doc: fix os.markdown code examples
tflanagan Feb 3, 2016
eeb11f6
doc: fix net.markdown code examples
tflanagan Feb 3, 2016
fe80931
doc: fix modules.markdown code examples
tflanagan Feb 3, 2016
4ea4dec
doc: fix https.markdown code examples
tflanagan Feb 3, 2016
d6192c5
doc: fix http.markdown code examples
tflanagan Feb 3, 2016
4484863
doc: fix fs.markdown code examples
tflanagan Feb 3, 2016
a9e421d
doc: fix events.markdown code examples
tflanagan Feb 3, 2016
cf3685d
doc: fix errors.markdown code examples
tflanagan Feb 3, 2016
26de732
doc: fix domain.markdown code examples
tflanagan Feb 3, 2016
f9dfcef
doc: fix dgram.markdown code examplesc
tflanagan Feb 3, 2016
9f9243e
doc: fix debugger.markdown code examplesc
tflanagan Feb 3, 2016
4c16952
doc: fix addons.markdown code examples
tflanagan Feb 3, 2016
8686f19
doc: fix assert.markdown code examples
tflanagan Feb 3, 2016
3a362a9
doc: fix child_process.markdown code examples
tflanagan Feb 3, 2016
b05d621
doc: fix console.markdown code examples
tflanagan Feb 3, 2016
4c28eb4
doc: fix cluster.markdown code examples
tflanagan Feb 3, 2016
66c4081
doc: fix crypto.markdown code examples
tflanagan Feb 3, 2016
775cf49
doc: fix buffer.markdown code examples
tflanagan Feb 3, 2016
5d58b3f
build,doc: moving doc lint rules to doc/api/.eslintrc
tflanagan Feb 12, 2016
cb5c1dd
build: add jslint-docs to test
tflanagan Feb 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ cctest: all
test: | cctest # Depends on 'all'.
$(PYTHON) tools/test.py --mode=release message parallel sequential -J
$(MAKE) jslint
$(MAKE) jslint-docs
$(MAKE) cpplint

test-parallel: all
Expand Down Expand Up @@ -519,6 +520,9 @@ bench-idle:
jslint:
$(NODE) tools/eslint/bin/eslint.js lib src test tools/doc tools/eslint-rules \
--rulesdir tools/eslint-rules --quiet
jslint-docs:
$(NODE) tools/eslint/bin/eslint.js --plugin eslint-plugin-markdown --ext markdown doc/api/ \
--rulesdir tools/eslint-rules --quiet

CPPLINT_EXCLUDE ?=
CPPLINT_EXCLUDE += src/node_lttng.cc
Expand All @@ -545,11 +549,11 @@ CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \
cpplint:
@$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)

lint: jslint cpplint
lint: jslint jslint-docs cpplint

.PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean \
.PHONY: lint cpplint jslint jslint-docs bench clean docopen docclean doc \
check uninstall install install-includes install-bin all staticlib \
dynamiclib test test-all test-addons build-addons website-upload pkg \
blog blogclean tar binary release-only bench-http-simple bench-idle \
bench-all bench bench-misc bench-array bench-buffer bench-net \
bench-http bench-fs bench-tls cctest run-ci
bench-http bench-fs bench-tls cctest run-ci distclean dist
5 changes: 5 additions & 0 deletions doc/api/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Documentation-specific linter rules

rules:
strict: 0
eol-last: 0
24 changes: 13 additions & 11 deletions doc/api/addons.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ Once compiled, the example Addon can be required and used from within Node.js:
// test.js
const addon = require('./build/Release/addon');

console.log('This should be eight:', addon.add(3,5));
console.log('This should be eight:', addon.add(3, 5));
```


Expand Down Expand Up @@ -423,7 +423,7 @@ const addon = require('./build/Release/addon');

var obj1 = addon('hello');
var obj2 = addon('world');
console.log(obj1.msg+' '+obj2.msg); // 'hello world'
console.log(obj1.msg + ' ' + obj2.msg); // 'hello world'
```


Expand Down Expand Up @@ -638,9 +638,9 @@ Test it with:
const addon = require('./build/Release/addon');

var obj = new addon.MyObject(10);
console.log( obj.plusOne() ); // 11
console.log( obj.plusOne() ); // 12
console.log( obj.plusOne() ); // 13
console.log(obj.plusOne()); // 11
console.log(obj.plusOne()); // 12
console.log(obj.plusOne()); // 13
```

### Factory of wrapped objects
Expand All @@ -649,6 +649,7 @@ Alternatively, it is possible to use a factory pattern to avoid explicitly
creating object instances using the JavaScript `new` operator:

```js
/* eslint no-unused-vars:0, no-undef:0 */
var obj = addon.createObject();
// instead of:
// var obj = new addon.Object();
Expand Down Expand Up @@ -824,14 +825,14 @@ Test it with:
const createObject = require('./build/Release/addon');

var obj = createObject(10);
console.log( obj.plusOne() ); // 11
console.log( obj.plusOne() ); // 12
console.log( obj.plusOne() ); // 13
console.log(obj.plusOne()); // 11
console.log(obj.plusOne()); // 12
console.log(obj.plusOne()); // 13

var obj2 = createObject(20);
console.log( obj2.plusOne() ); // 21
console.log( obj2.plusOne() ); // 22
console.log( obj2.plusOne() ); // 23
console.log(obj2.plusOne()); // 21
console.log(obj2.plusOne()); // 22
console.log(obj2.plusOne()); // 23
```


Expand Down Expand Up @@ -1075,6 +1076,7 @@ Test in JavaScript by running:

```js
// test.js
/* eslint no-unused-vars:0 */
const addon = require('./build/Release/addon');
```

Expand Down
22 changes: 18 additions & 4 deletions doc/api/assert.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ results. For example, the following example does not throw an `AssertionError`
because the properties on the [`Error`][] object are non-enumerable:

```js
const assert = require('assert');

// WARNING: This does not throw an AssertionError!
assert.deepEqual(Error('a'), Error('b'));
```
Expand All @@ -65,7 +67,7 @@ const obj3 = {
a : {
b : 1
}
}
};
const obj4 = Object.create(obj1);

assert.deepEqual(obj1, obj1);
Expand Down Expand Up @@ -124,6 +126,8 @@ The following, for instance, will throw the [`TypeError`][] because there is no
matching error type in the assertion:

```js
const assert = require('assert');

assert.doesNotThrow(
() => {
throw new TypeError('Wrong value');
Expand All @@ -136,6 +140,8 @@ However, the following will result in an `AssertionError` with the message
'Got unwanted exception (TypeError)..':

```js
const assert = require('assert');

assert.doesNotThrow(
() => {
throw new TypeError('Wrong value');
Expand All @@ -149,6 +155,8 @@ parameter, the value of `message` will be appended to the `AssertionError`
message:

```js
const assert = require('assert');

assert.doesNotThrow(
() => {
throw new TypeError('Wrong value');
Expand Down Expand Up @@ -208,7 +216,7 @@ const assert = require('assert');

assert.ifError(0); // OK
assert.ifError(1); // Throws 1
assert.ifError('error') // Throws 'error'
assert.ifError('error'); // Throws 'error'
assert.ifError(new Error()); // Throws Error
```

Expand All @@ -233,7 +241,7 @@ const obj3 = {
a : {
b : 1
}
}
};
const obj4 = Object.create(obj1);

assert.notDeepEqual(obj1, obj1);
Expand Down Expand Up @@ -366,6 +374,8 @@ constructor, [`RegExp`][], or validation function.
Validate instanceof using constructor:

```js
const assert = require('assert');

assert.throws(
() => {
throw new Error('Wrong value');
Expand All @@ -377,6 +387,8 @@ assert.throws(
Validate error message using [`RegExp`][]:

```js
const assert = require('assert');

assert.throws(
() => {
throw new Error('Wrong value');
Expand All @@ -388,12 +400,14 @@ assert.throws(
Custom error validation:

```js
const assert = require('assert');

assert.throws(
() => {
throw new Error('Wrong value');
},
function(err) {
if ( (err instanceof Error) && /value/.test(err) ) {
if ((err instanceof Error) && /value/.test(err)) {
return true;
}
},
Expand Down
Loading