From c2ab3c5c2bd3b976f52a2f497b1ab32f2501b27f Mon Sep 17 00:00:00 2001 From: Mani Maghsoudlou Date: Mon, 1 May 2017 20:00:12 -0700 Subject: [PATCH] Add standard-markdown to lint js code inside docs files --- README.md | 4 +--- docs/copy.md | 2 +- docs/emptyDir.md | 2 +- docs/ensureDir.md | 2 +- docs/ensureFile.md | 2 +- docs/ensureLink.md | 2 +- docs/ensureSymlink.md | 2 +- docs/move.md | 2 +- docs/outputFile.md | 3 ++- docs/outputJson.md | 3 ++- docs/readJson.md | 4 ++-- docs/remove.md | 2 +- docs/writeJson.md | 2 +- package.json | 5 +++-- 14 files changed, 19 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 4e6e127e..bb9422dd 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,7 @@ const fs = require('fs-extra') // Async with promises: fs.copy('/tmp/myfile', '/tmp/mynewfile') .then(() => console.log('success!')) - .catch(err => { - // Handle error - }) + .catch(err => console.error(err)) // Async with callbacks: fs.copy('/tmp/myfile', '/tmp/mynewfile', err => { diff --git a/docs/copy.md b/docs/copy.md index 94c71c0c..ff0811f5 100644 --- a/docs/copy.md +++ b/docs/copy.md @@ -35,7 +35,7 @@ fs.copy('/tmp/myfile', '/tmp/mynewfile') console.log('success!') }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/docs/emptyDir.md b/docs/emptyDir.md index 58268184..6553e9a9 100644 --- a/docs/emptyDir.md +++ b/docs/emptyDir.md @@ -25,6 +25,6 @@ fs.emptyDir('/tmp/some/dir') console.log('success!') }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/docs/ensureDir.md b/docs/ensureDir.md index a342a219..d030d866 100644 --- a/docs/ensureDir.md +++ b/docs/ensureDir.md @@ -24,6 +24,6 @@ fs.ensureDir(dir) console.log('success!') }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/docs/ensureFile.md b/docs/ensureFile.md index 6e006454..987be638 100644 --- a/docs/ensureFile.md +++ b/docs/ensureFile.md @@ -24,6 +24,6 @@ fs.ensureFile(file) console.log('success!') }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/docs/ensureLink.md b/docs/ensureLink.md index 736d73de..90d2a5d6 100644 --- a/docs/ensureLink.md +++ b/docs/ensureLink.md @@ -24,6 +24,6 @@ fs.ensureLink(srcpath, dstpath) console.log('success!') }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/docs/ensureSymlink.md b/docs/ensureSymlink.md index eeb993b6..45524f19 100644 --- a/docs/ensureSymlink.md +++ b/docs/ensureSymlink.md @@ -25,6 +25,6 @@ fs.ensureSymlink(srcpath, dstpath) console.log('success!') }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/docs/move.md b/docs/move.md index 4ad8bc57..0dd210c5 100644 --- a/docs/move.md +++ b/docs/move.md @@ -24,7 +24,7 @@ fs.move('/tmp/somefile', '/tmp/does/not/exist/yet/somefile') console.log('success!') }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/docs/outputFile.md b/docs/outputFile.md index 22ae2b90..766787d9 100644 --- a/docs/outputFile.md +++ b/docs/outputFile.md @@ -17,6 +17,7 @@ fs.outputFile(file, 'hello!', err => { console.log(err) // => null fs.readFile(file, 'utf8', (err, data) => { + if (err) return console.error(err) console.log(data) // => hello! }) }) @@ -28,6 +29,6 @@ fs.outputFile(file, 'hello!') console.log(data) // => hello! }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/docs/outputJson.md b/docs/outputJson.md index 62787210..fc6f2fe5 100644 --- a/docs/outputJson.md +++ b/docs/outputJson.md @@ -20,6 +20,7 @@ fs.outputJson(file, {name: 'JP'}, err => { console.log(err) // => null fs.readJson(file, (err, data) => { + if (err) return console.error(err) console.log(data.name) // => JP }) }) @@ -31,6 +32,6 @@ fs.outputJson(file, {name: 'JP'}) console.log(data.name) // => JP }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/docs/readJson.md b/docs/readJson.md index 5913aa69..6edc329d 100644 --- a/docs/readJson.md +++ b/docs/readJson.md @@ -26,7 +26,7 @@ fs.readJson('./package.json') console.log(packageObj.version) // => 0.1.3 }) .catch(err => { - // handle error + console.error(err) }) ``` @@ -53,6 +53,6 @@ fs.readJson(file, { throws: false }) console.log(obj) // => null }) .catch(err => { - // Not called + console.error(err) // Not called }) ``` diff --git a/docs/remove.md b/docs/remove.md index 5a1a566c..36402935 100644 --- a/docs/remove.md +++ b/docs/remove.md @@ -29,6 +29,6 @@ fs.remove('/tmp/myfile') console.log('success!') }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/docs/writeJson.md b/docs/writeJson.md index b5a2e092..0e9c3931 100644 --- a/docs/writeJson.md +++ b/docs/writeJson.md @@ -27,7 +27,7 @@ fs.writeJson('./package.json', {name: 'fs-extra'}) console.log('success!') }) .catch(err => { - // handle error + console.error(err) }) ``` diff --git a/package.json b/package.json index 8ee76ed4..b1999a17 100644 --- a/package.json +++ b/package.json @@ -48,13 +48,14 @@ "read-dir-files": "^0.1.1", "rimraf": "^2.2.8", "secure-random": "^1.1.1", - "standard": "^10.0.2" + "standard": "^10.0.2", + "standard-markdown": "^2.3.0" }, "main": "./lib/index", "scripts": { "coverage": "istanbul cover -i 'lib/**' -x '**/__tests__/**' test.js", "coveralls": "npm run coverage && coveralls < coverage/lcov.info", - "lint": "standard", + "lint": "standard && standard-markdown", "test-find": "find ./lib/**/__tests__ -name *.test.js | xargs mocha", "test": "npm run lint && npm run unit", "unit": "node test.js"