Skip to content

Commit

Permalink
Merge pull request #78 from alrra/use-eslint-on-js-code-blocks-from-m…
Browse files Browse the repository at this point in the history
…arkdown-files

Use `ESLint` to validate the markdown JS code blocks
  • Loading branch information
molant authored Apr 5, 2017
2 parents 9b1f8f5 + 513985c commit 70e5a5f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"parser": "typescript-eslint-parser",
"plugins": [
"import",
"markdown",
"typescript"
],
"rules": {
Expand Down
26 changes: 15 additions & 11 deletions docs/develeloper-guide/rules/how-to-test-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,28 @@ need to:
* `string` containing the response for `/` (HTML, plain text, etc.).
* `object` with paths as properties names and their content as values:

<!-- eslint-disable no-unused-vars -->

```js
{
'/': 'some HTML here',
'site.webmanifest': '{ "property1": "value1" }'
}
const tests = [{
'/': 'some HTML here',
'site.webmanifest': { property: 'value' }
}];
```

* You can even specify the status code for the response for
a specific path:

<!-- eslint-disable no-unused-vars -->

```js
{
'/': 'some HTML here',
'/site.webmanifest': {
statusCode: 200,
content: 'The content of the response'
}
}
const tests = [{
'/': 'some HTML here',
'/site.webmanifest': {
content: 'The content of the response',
statusCode: 200
}
}];
```

In the last example, if you don't specify `content`, the response
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build:ts": "tsc --outDir dist --rootDir src",
"build": "npm-run-all build:*",
"clean": "rimraf dist",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint --ext ts src/ --ext md . --ignore-pattern dist/*",
"site": "node dist/bin/sonar --debug",
"test": "npm run lint && npm run clean && npm run build && nyc ava",
"watch": "npm run build && npm-run-all --parallel -c watch:*",
Expand Down Expand Up @@ -65,6 +65,7 @@
"cpx": "^1.5.0",
"eslint-config-airbnb-base": "^11.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-markdown": "^1.0.0-beta.4",
"eslint-plugin-typescript": "^0.1.0",
"express": "^4.15.2",
"leche": "^2.1.2",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/rules/disallowed-headers/disallowed-headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ Yes, you can use:
E.g. The following configuration will make the rule allow responses
to be served with the `Server` HTTP headers, but not with `Custom-Header`.

```js
```json
"disallowed-headers": [ "warning", {
ignore: ['Server'],
include: ['Custom-Header']
"ignore": ["Server"],
"include": ["Custom-Header"]
}]
```

0 comments on commit 70e5a5f

Please sign in to comment.