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
Changes from 1 commit
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: fix fs.markdown code examples
  • Loading branch information
tflanagan committed Feb 10, 2016
commit 4484863f9ab74eab05282532c14d561e40b55cef
39 changes: 36 additions & 3 deletions doc/api/fs.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ With the asynchronous methods there is no guaranteed ordering. So the
following is prone to error:

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

fs.rename('/tmp/hello', '/tmp/world', (err) => {
if (err) throw err;
console.log('renamed complete');
Expand All @@ -54,6 +56,8 @@ It could be that `fs.stat` is executed before `fs.rename`.
The correct way to do this is to chain the callbacks.

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

fs.rename('/tmp/hello', '/tmp/world', (err) => {
if (err) throw err;
fs.stat('/tmp/world', (err, stats) => {
Expand Down Expand Up @@ -146,7 +150,7 @@ synchronous counterparts are of this type.
For a regular file [`util.inspect(stats)`][] would return a string very
similar to this:

```js
```
{
dev: 2114,
ino: 48064969,
Expand Down Expand Up @@ -239,6 +243,8 @@ argument will be populated. The following example checks if the file
`/etc/passwd` can be read and written by the current process.

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

fs.access('/etc/passwd', fs.R_OK | fs.W_OK, (err) => {
console.log(err ? 'no access!' : 'can read/write');
});
Expand All @@ -265,6 +271,8 @@ Asynchronously append data to a file, creating the file if it does not yet exist
Example:

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

fs.appendFile('message.txt', 'data to append', (err) => {
if (err) throw err;
console.log('The "data to append" was appended to file!');
Expand All @@ -274,6 +282,9 @@ fs.appendFile('message.txt', 'data to append', (err) => {
If `options` is a string, then it specifies the encoding. Example:

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

/* eslint no-undef:0 */
fs.appendFile('message.txt', 'data to append', 'utf8', callback);
```

Expand Down Expand Up @@ -322,7 +333,7 @@ default value of 64 kb for the same parameter.

`options` is an object or string with the following defaults:

```js
```
{
flags: 'r',
encoding: null,
Expand Down Expand Up @@ -353,6 +364,8 @@ file was created.
An example to read the last 10 bytes of a file which is 100 bytes long:

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

fs.createReadStream('sample.txt', {start: 90, end: 99});
```

Expand All @@ -364,7 +377,7 @@ Returns a new [`WriteStream`][] object. (See [Writable Stream][]).

`options` is an object or string with the following defaults:

```js
```
{
flags: 'w',
defaultEncoding: 'utf8',
Expand Down Expand Up @@ -400,6 +413,8 @@ Test whether or not the given path exists by checking with the file system.
Then call the `callback` argument with either true or false. Example:

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

fs.exists('/etc/passwd', (exists) => {
console.log(exists ? 'it\'s there' : 'no passwd!');
});
Expand Down Expand Up @@ -626,6 +641,8 @@ Synchronous readdir(3). Returns an array of filenames excluding `'.'` and
Asynchronously reads the entire contents of a file. Example:

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

fs.readFile('/etc/passwd', (err, data) => {
if (err) throw err;
console.log(data);
Expand All @@ -640,6 +657,9 @@ If no encoding is specified, then the raw buffer is returned.
If `options` is a string, then it specifies the encoding. Example:

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

/* eslint no-undef:0 */
fs.readFile('/etc/passwd', 'utf8', callback);
```

Expand Down Expand Up @@ -673,6 +693,8 @@ resolution or avoid additional `fs.stat` calls for known real paths.
Example:

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

var cache = {'/etc':'/private/etc'};
fs.realpath('/etc/passwd', cache, (err, resolvedPath) => {
if (err) throw err;
Expand Down Expand Up @@ -730,6 +752,8 @@ Note that Windows junction points require the destination path to be absolute.
Here is an example below:

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

fs.symlink('./foo', './new-port');
```

Expand Down Expand Up @@ -845,6 +869,8 @@ be provided. Therefore, don't assume that `filename` argument is always
provided in the callback, and have some fallback logic if it is null.

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

fs.watch('somedir', (event, filename) => {
console.log(`event is: ${event}`);
if (filename) {
Expand All @@ -871,6 +897,8 @@ The `listener` gets two arguments the current stat object and the previous
stat object:

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

fs.watchFile('message.text', (curr, prev) => {
console.log(`the current mtime is: ${curr.mtime}`);
console.log(`the previous mtime was: ${prev.mtime}`);
Expand Down Expand Up @@ -959,6 +987,8 @@ to `'utf8'`.
Example:

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

fs.writeFile('message.txt', 'Hello Node.js', (err) => {
if (err) throw err;
console.log('It\'s saved!');
Expand All @@ -968,6 +998,9 @@ fs.writeFile('message.txt', 'Hello Node.js', (err) => {
If `options` is a string, then it specifies the encoding. Example:

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

/* eslint no-undef:0 */
fs.writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
```

Expand Down