1
1
# ![ remark-lint] [ logo ]
2
2
3
- [ ![ Build Status] [ travis-badge ]] [ travis-ci ]
4
- [ ![ Coverage Status] [ coverage-badge ]] [ coverage-ci ]
3
+ [ ![ Build Status] [ build-badge ]] [ build-status ]
4
+ [ ![ Coverage Status] [ coverage-badge ]] [ coverage-status ]
5
+ [ ![ Chat] [ chat-badge ]] [ chat ]
6
+
7
+ <!-- lint disable list-item-spacing-->
5
8
6
9
** remark-lint** is a markdown code style linter. Another linter? Yes.
7
10
Ensuring the markdown you (and contributors) write is of great quality will
8
11
provide better rendering in all the different markdown parsers, and makes
9
- sure less refactoring is needed afterwards. What is quality? That’s up to you,
12
+ sure less refactoring is needed afterwards. What is quality? That’s up to you,
10
13
but the defaults are sensible :ok_hand : .
11
14
12
- ** remark-lint** has lots of tests. Supports Node, io.js, and the browser.
13
- 100% coverage. 50+ rules. It’s built on [ ** remark** ] [ remark ] ,
14
- a powerful markdown processor powered by [ plugins] [ remark-plugins ]
15
- (such as this one).
15
+ ** remark-lint** is built on [ ** remark** ] [ remark ] , a powerful markdown
16
+ processor powered by [ plugins] [ remark-plugins ] (such as this one).
16
17
17
18
## Table of Contents
18
19
19
20
* [ Installation] ( #installation )
20
21
* [ Command line] ( #command-line )
21
22
* [ Programmatic] ( #programmatic )
23
+ * [ remark.use(lint\[ , options\] )] ( #remarkuselint-options )
22
24
* [ Rules] ( #rules )
23
25
* [ Configuring remark-lint] ( #configuring-remark-lint )
24
26
* [ Using remark to fix your markdown] ( #using-remark-to-fix-your-markdown )
@@ -29,7 +31,7 @@ a powerful markdown processor powered by [plugins][remark-plugins]
29
31
30
32
## Installation
31
33
32
- [ npm] [ npm-install ] :
34
+ [ npm] [ ] :
33
35
34
36
``` bash
35
37
npm install remark-lint
@@ -42,10 +44,10 @@ module, [uncompressed and compressed][releases].
42
44
43
45
![ Example of how remark-lint looks on screen] [ screenshot ]
44
46
45
- Use remark-lint together with remark:
47
+ Use ` remark-lint ` together with [ ` remark-cli ` ] [ cli ] :
46
48
47
49
``` bash
48
- npm install --global remark remark-lint
50
+ npm install --global remark-cli remark-lint
49
51
```
50
52
51
53
Let’s say ` example.md ` looks as follows:
@@ -56,27 +58,69 @@ Let’s say `example.md` looks as follows:
56
58
[World][]
57
59
```
58
60
59
- Then, to run ** remark-lint ** on ` example.md ` :
61
+ Now, running ` remark example.md -u remark-lint ` yields :
60
62
61
- ``` bash
62
- remark example.md -u remark-lint
63
- #
64
- # Yields:
65
- #
66
- # example.md
67
- # 1:3 warning Incorrect list-item indent: add 2 spaces list-item-indent
68
- # 3:1-3:10 warning Found reference to undefined definition no-undefined-references
69
- #
70
- # ⚠ 2 warnings
63
+ ``` txt
64
+ example.md
65
+ 1:3 warning Incorrect list-item indent: add 2 spaces list-item-indent
66
+ 3:1-3:10 warning Found reference to undefined definition no-undefined-references
67
+ ⚠ 2 warnings
71
68
```
72
69
73
70
See [ ` doc/rules.md ` ] [ rules ] for what those warnings are (and how to
74
71
turn them off).
75
72
76
73
## Programmatic
77
74
78
- [ ` doc/api.md ` ] [ api ] describes how to use ** remark-lint** ’s
79
- programatic interface in JavaScript.
75
+ Use ` remark-lint ` together with [ ` remark ` ] [ api ] :
76
+
77
+ ``` bash
78
+ npm install remark remark-lint
79
+ ```
80
+
81
+ Let’s say ` example.js ` looks as follows:
82
+
83
+ ``` js
84
+ var report = require (' vfile-reporter' );
85
+ var remark = require (' remark' );
86
+ var lint = require (' remark-lint' );
87
+
88
+ var file = remark ().use (lint).process (' ## Hello world!' );
89
+
90
+ console .log (report (file));
91
+ ```
92
+
93
+ Now, running ` node example.js ` yields:
94
+
95
+ ``` txt
96
+ <stdin>
97
+ 1:1 warning Missing newline character at end of file final-newline
98
+ 1:1-1:16 warning First heading level should be `1` first-heading-level
99
+ 1:1-1:16 warning Don’t add a trailing `!` to headings no-heading-punctuation
100
+
101
+ ⚠ 3 warnings
102
+ ```
103
+
104
+ ### ` remark.use(lint[, options]) `
105
+
106
+ Adds warnings for style violations to the processed [ virtual file] [ vfile ] .
107
+
108
+ When processing a file, these warnings are available at ` file.messages ` , and
109
+ look as follows:
110
+
111
+ ``` js
112
+ {
113
+ file: ' ~/example.md' ,
114
+ reason: ' First heading level should be `1`' ,
115
+ line: 1 ,
116
+ column: 1 ,
117
+ location: Position { start: [Object ], end: [Object ] },
118
+ ruleId: ' first-heading-level' ,
119
+ fatal: false ,
120
+ source: ' remark-lint' }
121
+ ```
122
+
123
+ See [ ` VFileMessage ` ] [ vfile-message ] for more information.
80
124
81
125
## Rules
82
126
@@ -85,31 +129,25 @@ for, examples of markdown they warn for, and how to fix their warnings.
85
129
86
130
## Configuring remark-lint
87
131
88
- ** remark-lint** is just a ** remark** plug-in. Meaning, you can opt to
89
- configure using configuration files. Read more about these files
90
- (` .remarkrc ` or ` package.json ` ) in [ ** remark** ’s docs] [ remarkrc ] .
132
+ ** remark-lint** is a ** remark** plug-in and supports configuration
133
+ through its [ configuration files] [ cli ] .
91
134
92
135
An example ` .remarkrc ` file could look as follows:
93
136
94
137
``` json
95
138
{
96
139
"plugins" : {
97
- "lint" : {
140
+ "remark- lint" : {
98
141
"no-multiple-toplevel-headings" : false ,
99
142
"list-item-indent" : false ,
100
143
"maximum-line-length" : 79
101
144
}
102
- },
103
- "settings" : {
104
- "commonmark" : true
105
145
}
106
146
}
107
147
```
108
148
109
- Where the object at ` plugins.lint ` is a map of ` ruleId ` s and their values. The
110
- object at ` settings ` determines how ** remark** parses (and compiles)
111
- markdown code. Read more about the latter on
112
- [ ** remark** ’s readme] [ remark-process ] .
149
+ Where the object at ` plugins['remark-lint'] ` is a map of ` ruleId ` s and
150
+ their values.
113
151
114
152
Using our ` example.md ` from before:
115
153
@@ -119,24 +157,20 @@ Using our `example.md` from before:
119
157
[World][]
120
158
```
121
159
122
- We now run the below command _ without _ the ` -u remark-lint ` since
123
- our ` .remarkrc ` includes the lint plugin.
160
+ Now, running ` remark example.md ` ( ** without ` -u remark-lint ` ** since
161
+ our ` .remarkrc ` includes the lint plugin) yields:
124
162
125
163
``` bash
126
- remark example.md
127
- #
128
- # Yields:
129
- #
130
- # example.md
131
- # 3:1-3:10 warning Found reference to undefined definition no-undefined-references
132
- #
133
- # ⚠ 2 warnings
164
+ example.md
165
+ 3:1-3:10 warning Found reference to undefined definition no-undefined-references
166
+
167
+ ⚠ 2 warnings
134
168
```
135
169
136
170
In addition, you can also provide configuration comments to turn a rule
137
- on or off inside a file. Note that you cannot change what a setting,
138
- such as ` maximum-line-length ` , checks for, as you’re either enabling
139
- or disabling warnings). Read more about configuration comments in
171
+ on or off inside a file. Note that you cannot change what a setting,
172
+ such as ` maximum-line-length ` , just whether they are shown or not.
173
+ Read more about configuration comments in
140
174
[ ** remark-message-control** ] [ message-control ] s documentation.
141
175
142
176
The following file will warn twice for the duplicate headings:
@@ -167,7 +201,7 @@ but the third is re-enabled):
167
201
## Using remark to fix your markdown
168
202
169
203
One of ** remark** ’s cool parts is that it compiles to very clean, and highly
170
- cross-vendor supported markdown. It’ll ensure list items use a single bullet,
204
+ cross-vendor supported markdown. It’ll ensure list items use a single bullet,
171
205
emphasis and strong use a standard marker, and that your table fences are
172
206
aligned.
173
207
@@ -179,7 +213,7 @@ and I strongly suggest checking out how it can make your life easier :+1:
179
213
Currently, ** remark-lint** is integrated with Atom through
180
214
[ ** linter-markdown** ] [ linter-markdown ] .
181
215
182
- I’m very interested in more integrations. Let me know if I can help.
216
+ I’m very interested in more integrations. Let me know if I can help.
183
217
184
218
## List of External Rules
185
219
@@ -190,23 +224,17 @@ excluding `remark-lint-no-` or `remark-lint-`
190
224
191
225
* [ ` vhf/remark-lint-alphabetize-lists ` ] ( https://github.com/vhf/remark-lint-alphabetize-lists )
192
226
— Ensure list items are in alphabetical order;
193
-
194
227
* [ ` vhf/remark-lint-blank-lines-1-0-2 ` ] ( https://github.com/vhf/remark-lint-blank-lines-1-0-2 )
195
228
— Ensure a specific number of lines between blocks;
196
-
197
229
* [ ` vhf/remark-lint-books-links ` ] ( https://github.com/vhf/remark-lint-books-links )
198
230
— Ensure links in lists of books follow a standard format;
199
-
200
231
* [ ` Qard/remark-lint-code ` ] ( https://github.com/Qard/remark-lint-code )
201
232
— Lint fenced code blocks by corresponding language tags,
202
233
currently supporting [ ESLint] ( https://github.com/Qard/remark-lint-code-eslint ) .
203
-
204
234
* [ ` vhf/remark-lint-no-empty-sections ` ] ( https://github.com/vhf/remark-lint-no-empty-sections )
205
235
— Ensure every heading is followed by content (forming a section);
206
-
207
236
* [ ` chcokr/remark-lint-sentence-newline ` ] ( https://github.com/chcokr/remark-lint-sentence-newline )
208
237
— Ensure sentences are followed by a newline;
209
-
210
238
* [ ` vhf/remark-lint-no-url-trailing-slash ` ] ( https://github.com/vhf/remark-lint-no-url-trailing-slash )
211
239
— Ensure that the ` href ` of links has no trailing slash.
212
240
@@ -221,38 +249,44 @@ excluding `remark-lint-no-` or `remark-lint-`
221
249
222
250
<!-- Definitions -->
223
251
224
- [ travis-badge ] : https://img.shields.io/travis/wooorm/remark-lint.svg
252
+ [ build-badge ] : https://img.shields.io/travis/wooorm/remark-inline-links.svg
253
+
254
+ [ build-status ] : https://travis-ci.org/wooorm/remark-inline-links
225
255
226
- [ travis-ci ] : https://travis-ci.org/ wooorm/remark-lint
256
+ [ coverage-badge ] : https://img.shields.io/codecov/c/github/ wooorm/remark-inline-links.svg
227
257
228
- [ coverage-badge ] : https://img.shields. io/codecov/c/ github/wooorm/remark-lint.svg
258
+ [ coverage-status ] : https://codecov. io/github/wooorm/remark-inline-links
229
259
230
- [ coverage-ci ] : https://codecov. io/github/ wooorm/remark-lint
260
+ [ chat-badge ] : https://img.shields. io/gitter/room/ wooorm/remark.svg
231
261
232
- [ npm-install ] : https://docs.npmjs.com/cli/install
262
+ [ chat ] : https://gitter.im/wooorm/remark
233
263
234
- [ releases ] : https://github.com/wooorm/remark-lint/releases
264
+ [ releases ] : https://github.com/wooorm/remark-inline-links/releases
265
+
266
+ [ license ] : LICENSE
235
267
236
268
[ author ] : http://wooorm.com
237
269
270
+ [ npm ] : https://docs.npmjs.com/cli/install
271
+
272
+ [ remark ] : https://github.com/wooorm/remark
273
+
238
274
[ logo ] : https://cdn.rawgit.com/wooorm/remark-lint/master/logo.svg
239
275
240
276
[ screenshot ] : https://cdn.rawgit.com/wooorm/remark-lint/master/screenshot.png
241
277
242
278
[ rules ] : doc/rules.md
243
279
244
- [ api ] : doc/api.md
245
-
246
- [ license ] : LICENSE
280
+ [ api ] : https://github.com/wooorm/remark/tree/master/packages/remark
247
281
248
- [ remark ] : https://github.com/wooorm/remark
282
+ [ cli ] : https://github.com/wooorm/remark/tree/master/packages/remark-cli
249
283
250
284
[ remark-plugins ] : https://github.com/wooorm/remark/blob/master/doc/plugins.md
251
285
252
- [ remarkrc ] : https://github.com/wooorm/remark/blob/master/doc/remarkrc.5.md
253
-
254
- [ remark-process ] : https://github.com/wooorm/remark#remarkprocessvalue-options-done
255
-
256
286
[ linter-markdown ] : https://atom.io/packages/linter-markdown
257
287
258
288
[ message-control ] : https://github.com/wooorm/remark-message-control#markers
289
+
290
+ [ vfile ] : https://github.com/wooorm/vfile
291
+
292
+ [ vfile-message ] : https://github.com/wooorm/vfile#vfilemessage
0 commit comments