remark-lint-emphasis-marker
Advanced tools
Comparing version 1.0.3 to 1.0.4
43
index.js
@@ -25,27 +25,27 @@ /** | ||
* | ||
* @example {"setting": "*", "name": "valid.md"} | ||
* @example {"setting": "*", "name": "ok.md"} | ||
* | ||
* *foo* | ||
* | ||
* @example {"setting": "*", "name": "invalid.md", "label": "input"} | ||
* @example {"setting": "*", "name": "not-ok.md", "label": "input"} | ||
* | ||
* _foo_ | ||
* | ||
* @example {"setting": "*", "name": "invalid.md", "label": "output"} | ||
* @example {"setting": "*", "name": "not-ok.md", "label": "output"} | ||
* | ||
* 1:1-1:6: Emphasis should use `*` as a marker | ||
* | ||
* @example {"setting": "_", "name": "valid.md"} | ||
* @example {"setting": "_", "name": "ok.md"} | ||
* | ||
* _foo_ | ||
* | ||
* @example {"setting": "_", "name": "invalid.md", "label": "input"} | ||
* @example {"setting": "_", "name": "not-ok.md", "label": "input"} | ||
* | ||
* *foo* | ||
* | ||
* @example {"setting": "_", "name": "invalid.md", "label": "output"} | ||
* @example {"setting": "_", "name": "not-ok.md", "label": "output"} | ||
* | ||
* 1:1-1:6: Emphasis should use `_` as a marker | ||
* | ||
* @example {"name": "invalid.md", "label": "input"} | ||
* @example {"name": "not-ok.md", "label": "input"} | ||
* | ||
@@ -55,9 +55,9 @@ * *foo* | ||
* | ||
* @example {"name": "invalid.md", "label": "output"} | ||
* @example {"name": "not-ok.md", "label": "output"} | ||
* | ||
* 2:1-2:6: Emphasis should use `*` as a marker | ||
* | ||
* @example {"setting": "invalid", "name": "invalid.md", "label": "output", "config": {"positionless": true}} | ||
* @example {"setting": "💩", "name": "not-ok.md", "label": "output", "config": {"positionless": true}} | ||
* | ||
* 1:1: Invalid emphasis marker `invalid`: use either `'consistent'`, `'*'`, or `'_'` | ||
* 1:1: Incorrect emphasis marker `💩`: use either `'consistent'`, `'*'`, or `'_'` | ||
*/ | ||
@@ -76,11 +76,11 @@ | ||
function emphasisMarker(tree, file, pref) { | ||
function emphasisMarker(tree, file, option) { | ||
var contents = String(file) | ||
var preferred = | ||
typeof option === 'string' && option !== 'consistent' ? option : null | ||
pref = typeof pref === 'string' && pref !== 'consistent' ? pref : null | ||
if (markers[pref] !== true) { | ||
if (markers[preferred] !== true) { | ||
file.fail( | ||
'Invalid emphasis marker `' + | ||
pref + | ||
'Incorrect emphasis marker `' + | ||
preferred + | ||
"`: use either `'consistent'`, `'*'`, or `'_'`" | ||
@@ -98,8 +98,11 @@ ) | ||
if (pref) { | ||
if (marker !== pref) { | ||
file.message('Emphasis should use `' + pref + '` as a marker', node) | ||
if (preferred) { | ||
if (marker !== preferred) { | ||
file.message( | ||
'Emphasis should use `' + preferred + '` as a marker', | ||
node | ||
) | ||
} | ||
} else { | ||
pref = marker | ||
preferred = marker | ||
} | ||
@@ -106,0 +109,0 @@ } |
{ | ||
"name": "remark-lint-emphasis-marker", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "remark-lint rule to warn when emphasis markers violate the given style", | ||
@@ -10,2 +10,3 @@ "license": "MIT", | ||
"rule", | ||
"remark-lint-rule", | ||
"emphasis", | ||
@@ -16,2 +17,6 @@ "marker" | ||
"bugs": "https://github.com/remarkjs/remark-lint/issues", | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/unified" | ||
}, | ||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)", | ||
@@ -18,0 +23,0 @@ "contributors": [ |
@@ -42,3 +42,3 @@ <!--This file is generated--> | ||
##### `valid.md` | ||
##### `ok.md` | ||
@@ -57,3 +57,3 @@ When configured with `'*'`. | ||
##### `invalid.md` | ||
##### `not-ok.md` | ||
@@ -74,3 +74,3 @@ When configured with `'*'`. | ||
##### `valid.md` | ||
##### `ok.md` | ||
@@ -89,3 +89,3 @@ When configured with `'_'`. | ||
##### `invalid.md` | ||
##### `not-ok.md` | ||
@@ -106,3 +106,3 @@ When configured with `'_'`. | ||
##### `invalid.md` | ||
##### `not-ok.md` | ||
@@ -122,5 +122,5 @@ ###### In | ||
##### `invalid.md` | ||
##### `not-ok.md` | ||
When configured with `'invalid'`. | ||
When configured with `'💩'`. | ||
@@ -130,3 +130,3 @@ ###### Out | ||
```text | ||
1:1: Invalid emphasis marker `invalid`: use either `'consistent'`, `'*'`, or `'_'` | ||
1:1: Incorrect emphasis marker `💩`: use either `'consistent'`, `'*'`, or `'_'` | ||
``` | ||
@@ -147,12 +147,12 @@ | ||
```diff | ||
... | ||
… | ||
"remarkConfig": { | ||
"plugins": [ | ||
... | ||
… | ||
"lint", | ||
+ "lint-emphasis-marker", | ||
... | ||
… | ||
] | ||
} | ||
... | ||
… | ||
``` | ||
@@ -169,4 +169,4 @@ | ||
```diff | ||
var remark = require('remark'); | ||
var report = require('vfile-reporter'); | ||
var remark = require('remark') | ||
var report = require('vfile-reporter') | ||
@@ -177,4 +177,4 @@ remark() | ||
.process('_Emphasis_ and **importance**', function (err, file) { | ||
console.error(report(err || file)); | ||
}); | ||
console.error(report(err || file)) | ||
}) | ||
``` | ||
@@ -188,4 +188,4 @@ | ||
This project has a [Code of Conduct][coc]. | ||
By interacting with this repository, organisation, or community you agree to | ||
This project has a [code of conduct][coc]. | ||
By interacting with this repository, organization, or community you agree to | ||
abide by its terms. | ||
@@ -219,3 +219,3 @@ | ||
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg | ||
[chat-badge]: https://img.shields.io/badge/chat-spectrum.svg | ||
@@ -222,0 +222,0 @@ [chat]: https://spectrum.chat/unified/remark |
8380
97
2