lint docs

This commit is contained in:
Leo Horie 2016-11-23 01:49:06 -05:00
parent e4ba0318d6
commit 42e13c1559
2 changed files with 15 additions and 8 deletions

View file

@ -70,12 +70,19 @@ function initMocks() {
global.m = require("../index")
global.o = require("../ospec/ospec")
global.stream = require("../stream")
global.alert = function() {}
//routes consumed by request.md
global.window.$defineRoutes({
"GET /api/v1/users": function(request) {
return {status: 200, responseText: JSON.stringify([{name: ""}])}
},
"GET /api/v1/users/search": function(request) {
return {status: 200, responseText: JSON.stringify([{id: 1, name: ""}])}
},
"GET /api/v1/users/1/projects": function(request) {
return {status: 200, responseText: JSON.stringify([{id: 1, name: ""}])}
},
"GET /api/v1/todos": function(request) {
return {status: 200, responseText: JSON.stringify([])}
},
@ -125,7 +132,7 @@ function traverseDirectory(pathname, callback) {
//run
traverseDirectory("./docs", function(pathname) {
if (pathname.indexOf(".md") > -1 && pathname.indexOf("migration") < 0 && pathname.indexOf("tutorial") < 0) {
if (pathname.indexOf(".md") > -1 && !pathname.match(/migration|zero|simple|node_modules/)) {
fs.readFile(pathname, "utf8", function(err, data) {
if (err) console.log(err)
else lint(pathname, data)

View file

@ -191,9 +191,9 @@ In the refactored version, it's trivial to test whether `getFirstTen` has any of
Promises absorb other promises. Basically, this means you can never receive a Promise as an argument to `onFulfilled` or `onRejected` callbacks for `then` and `catch` methods. This feature allows us to flatten nested promises to make code more manageable.
```Javascript
```javascript
function searchUsers(q) {return m.request("/api/v1/users/search", {data: {q: q}})}
function getUserProjects() {return m.request("/api/v1/user/" + id + "/projects")}
function getUserProjects(id) {return m.request("/api/v1/users/" + id + "/projects")}
// AVOID: pyramid of doom
searchUsers("John").then(function(users) {
@ -230,7 +230,7 @@ searchUsers("John")
.then(getProjectTitles)
.then(alert)
.catch(function(e) {
console.error(e)
console.log(e)
})
```
@ -275,10 +275,10 @@ Promise.all([
// data[0] is an array of users whose names are John
// data[1] is an array of users whose names are Mary
//the returned value is equivalent to [
// getUserNames(data[0]),
// getUserNames(data[1]),
//]
// the returned value is equivalent to [
// getUserNames(data[0]),
// getUserNames(data[1]),
// ]
return data.map(getUserNames)
})
.then(alert)