remark-lint-checkbox-character-style
Advanced tools
Comparing version 1.0.0 to 1.0.1
25
index.js
@@ -9,10 +9,11 @@ /** | ||
* | ||
* The default value, `consistent`, detects the first used checked | ||
* and unchecked checkbox styles, and will warn when a subsequent | ||
* checkboxes use a different style. | ||
* Options: `Object` or `'consistent'`, default: `'consistent'`. | ||
* | ||
* These values can also be passed in as an object, such as: | ||
* `'consistent'` detects the first used checked and unchecked checkbox | ||
* styles and warns when subsequent checkboxes use different styles. | ||
* | ||
* Styles can also be passed in like so: | ||
* | ||
* ```js | ||
* {checked: 'x', unchecked: ' '} | ||
* { checked: 'x', unchecked: ' ' } | ||
* ``` | ||
@@ -22,4 +23,2 @@ * | ||
* | ||
* <!--This file is also valid by default--> | ||
* | ||
* - [x] List item | ||
@@ -30,4 +29,2 @@ * - [x] List item | ||
* | ||
* <!--This file is also valid by default--> | ||
* | ||
* - [X] List item | ||
@@ -38,4 +35,2 @@ * - [X] List item | ||
* | ||
* <!--This file is also valid by default--> | ||
* | ||
* - [ ] List item | ||
@@ -48,4 +43,2 @@ * - [ ] List item | ||
* | ||
* <!--Also valid by default (note: `»` represents `\t`)--> | ||
* | ||
* - [»] List item | ||
@@ -56,4 +49,2 @@ * - [»] List item | ||
* | ||
* <!--Note: `»` represents `\t`--> | ||
* | ||
* - [x] List item | ||
@@ -66,4 +57,4 @@ * - [X] List item | ||
* | ||
* 4:4-4:5: Checked checkboxes should use `x` as a marker | ||
* 6:4-6:5: Unchecked checkboxes should use ` ` as a marker | ||
* 2:4-2:5: Checked checkboxes should use `x` as a marker | ||
* 4:4-4:5: Unchecked checkboxes should use ` ` as a marker | ||
* | ||
@@ -70,0 +61,0 @@ * @example {"setting": {"unchecked": "!"}, "name": "invalid.md", "label": "output", "config": {"positionless": true}} |
{ | ||
"name": "remark-lint-checkbox-character-style", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "remark-lint rule to warn when list item checkboxes violate a given style", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
147
readme.md
@@ -7,26 +7,30 @@ <!--This file is generated--> | ||
The default value, `consistent`, detects the first used checked | ||
and unchecked checkbox styles, and will warn when a subsequent | ||
checkboxes use a different style. | ||
Options: `Object` or `'consistent'`, default: `'consistent'`. | ||
These values can also be passed in as an object, such as: | ||
`'consistent'` detects the first used checked and unchecked checkbox | ||
styles and warns when subsequent checkboxes use different styles. | ||
Styles can also be passed in like so: | ||
```js | ||
{checked: 'x', unchecked: ' '} | ||
{ checked: 'x', unchecked: ' ' } | ||
``` | ||
## Install | ||
## Presets | ||
```sh | ||
npm install --save remark-lint-checkbox-character-style | ||
``` | ||
This rule is included in the following presets: | ||
| Preset | Setting | | ||
| ------ | ------- | | ||
| [`remark-preset-lint-consistent`](https://github.com/wooorm/remark-lint/tree/master/packages/remark-preset-lint-consistent) | | | ||
## Example | ||
When this rule is `{ checked: 'x' }`, the following file | ||
`valid.md` is ok: | ||
##### `valid.md` | ||
When configured with `{ checked: 'x' }`. | ||
###### In | ||
```markdown | ||
<!--This file is also valid by default--> | ||
- [x] List item | ||
@@ -36,8 +40,13 @@ - [x] List item | ||
When this rule is `{ checked: 'X' }`, the following file | ||
`valid.md` is ok: | ||
###### Out | ||
No messages. | ||
##### `valid.md` | ||
When configured with `{ checked: 'X' }`. | ||
###### In | ||
```markdown | ||
<!--This file is also valid by default--> | ||
- [X] List item | ||
@@ -47,8 +56,15 @@ - [X] List item | ||
When this rule is `{ unchecked: ' ' }`, the following file | ||
`valid.md` is ok: | ||
###### Out | ||
No messages. | ||
##### `valid.md` | ||
When configured with `{ unchecked: ' ' }`. | ||
###### In | ||
Note: `·` represents a space. | ||
```markdown | ||
<!--This file is also valid by default--> | ||
- [ ] List item | ||
@@ -60,8 +76,15 @@ - [ ] List item | ||
When this rule is `{ unchecked: '\t' }`, the following file | ||
`valid.md` is ok: | ||
###### Out | ||
No messages. | ||
##### `valid.md` | ||
When configured with `{ unchecked: '\t' }`. | ||
###### In | ||
Note: `»` represents a tab. | ||
```markdown | ||
<!--Also valid by default (note: `»` represents `\t`)--> | ||
- [»] List item | ||
@@ -71,8 +94,13 @@ - [»] List item | ||
When this rule is turned on, the following file | ||
`invalid.md` is **not** ok: | ||
###### Out | ||
No messages. | ||
##### `invalid.md` | ||
###### In | ||
Note: `»` represents a tab. | ||
```markdown | ||
<!--Note: `»` represents `\t`--> | ||
- [x] List item | ||
@@ -84,9 +112,15 @@ - [X] List item | ||
###### Out | ||
```text | ||
4:4-4:5: Checked checkboxes should use `x` as a marker | ||
6:4-6:5: Unchecked checkboxes should use ` ` as a marker | ||
2:4-2:5: Checked checkboxes should use `x` as a marker | ||
4:4-4:5: Unchecked checkboxes should use ` ` as a marker | ||
``` | ||
When `{ unchecked: '!' }` is passed in, the following error is given: | ||
##### `invalid.md` | ||
When configured with `{ unchecked: '!' }`. | ||
###### Out | ||
```text | ||
@@ -96,4 +130,8 @@ 1:1: Invalid unchecked checkbox marker `!`: use either `'\t'`, or `' '` | ||
When `{ checked: '!' }` is passed in, the following error is given: | ||
##### `invalid.md` | ||
When configured with `{ checked: '!' }`. | ||
###### Out | ||
```text | ||
@@ -103,4 +141,47 @@ 1:1: Invalid checked checkbox marker `!`: use either `'x'`, or `'X'` | ||
## Install | ||
```sh | ||
npm install remark-lint-checkbox-character-style | ||
``` | ||
## Usage | ||
You probably want to use it on the CLI through a config file: | ||
```diff | ||
... | ||
"remarkConfig": { | ||
"plugins": [ | ||
... | ||
"lint", | ||
+ "lint-checkbox-character-style", | ||
... | ||
] | ||
} | ||
... | ||
``` | ||
Or use it on the CLI directly | ||
```sh | ||
remark -u lint -u lint-checkbox-character-style readme.md | ||
``` | ||
Or use this on the API: | ||
```diff | ||
var remark = require('remark'); | ||
var report = require('vfile-reporter'); | ||
remark() | ||
.use(require('remark-lint')) | ||
+ .use(require('remark-lint-checkbox-character-style')) | ||
.process('_Emphasis_ and **importance**', function (err, file) { | ||
console.error(report(err || file)); | ||
}); | ||
``` | ||
## License | ||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com) |
7800
180
142