Skip to content

Commit 19b58bf

Browse files
authored
Add example of usage within npm scripts
Related #621 (comment)
1 parent 39ded11 commit 19b58bf

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

README.md

+27-27
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ in JavaScript Standard Style, or check out some of
6565

6666
- [Install](#install)
6767
- [Usage](#usage)
68+
- [Runnning standard with npm test](#runnning-standard-with-npm-test)
6869
- [Badge](#badge)
6970
- [Text editor plugins](#text-editor-plugins)
70-
- [What you might do if you're clever](#what-you-might-do-if-youre-clever)
7171
- [FAQ](#faq)
7272
- [Why would I use JavaScript Standard Style?](#why-would-i-use-javascript-standard-style)
7373
- [I disagree with rule X, can you change it?](#i-disagree-with-rule-x-can-you-change-it)
@@ -132,6 +132,32 @@ $ standard "src/util/**/*.js" "test/**/*.js"
132132
**Note:** by default `standard` will look for all files matching the patterns:
133133
`**/*.js`, `**/*.jsx`.
134134

135+
### Runnning standard with npm test
136+
137+
Below is a simple example of running standard before running tests:
138+
139+
```json
140+
{
141+
"name": "my-cool-package",
142+
"devDependencies": {
143+
"standard": "*"
144+
},
145+
"scripts": {
146+
"test": "standard && node my-tests.js"
147+
}
148+
}
149+
```
150+
151+
Style will now be checked automatically when you run `npm test`. Never give style feedback on a pull request again!
152+
153+
```
154+
$ npm test
155+
Error: Use JavaScript Standard Style
156+
lib/torrent.js:950:11: Expected '===' and instead saw '=='.
157+
```
158+
159+
160+
135161
### Badge
136162

137163
Use this in one of your projects? Include one of these badges in your readme to
@@ -231,32 +257,6 @@ Both WebStorm and PhpStorm can be [configured for Standard Style][webstorm-2].
231257
[webstorm-1]: https://www.jetbrains.com/webstorm/
232258
[webstorm-2]: https://github.com/feross/standard/blob/master/docs/webstorm.md
233259

234-
### What you might do if you're clever
235-
236-
1. Add it to `package.json`
237-
238-
```json
239-
{
240-
"name": "my-cool-package",
241-
"devDependencies": {
242-
"standard": "*"
243-
},
244-
"scripts": {
245-
"test": "standard && node my-tests.js"
246-
}
247-
}
248-
```
249-
250-
2. Check style automatically when you run `npm test`
251-
252-
```
253-
$ npm test
254-
Error: Use JavaScript Standard Style
255-
lib/torrent.js:950:11: Expected '===' and instead saw '=='.
256-
```
257-
258-
3. Never give style feedback on a pull request again!
259-
260260
## FAQ
261261

262262
### Why would I use JavaScript Standard Style?

0 commit comments

Comments
 (0)