remark-lint-linebreak-style
Advanced tools
Comparing version 1.0.3 to 1.0.4
30
index.js
@@ -16,3 +16,3 @@ /** | ||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify) | ||
* always uses unix-style linebreaks. | ||
* always uses unix linebreaks. | ||
* | ||
@@ -22,3 +22,3 @@ * See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) | ||
* | ||
* @example {"name": "valid-consistent-as-windows.md"} | ||
* @example {"name": "ok-consistent-as-windows.md"} | ||
* | ||
@@ -28,3 +28,3 @@ * Alpha␍␊ | ||
* | ||
* @example {"name": "valid-consistent-as-unix.md"} | ||
* @example {"name": "ok-consistent-as-unix.md"} | ||
* | ||
@@ -34,15 +34,15 @@ * Alpha␊ | ||
* | ||
* @example {"name": "invalid-unix.md", "label": "input", "setting": "unix", "config": {"positionless": true}} | ||
* @example {"name": "not-ok-unix.md", "label": "input", "setting": "unix", "config": {"positionless": true}} | ||
* | ||
* Alpha␍␊ | ||
* | ||
* @example {"name": "invalid-unix.md", "label": "output", "setting": "unix"} | ||
* @example {"name": "not-ok-unix.md", "label": "output", "setting": "unix"} | ||
* | ||
* 1:7: Expected linebreaks to be unix (`\n`), not windows (`\r\n`) | ||
* | ||
* @example {"name": "invalid-windows.md", "label": "input", "setting": "windows", "config": {"positionless": true}} | ||
* @example {"name": "not-ok-windows.md", "label": "input", "setting": "windows", "config": {"positionless": true}} | ||
* | ||
* Alpha␊ | ||
* | ||
* @example {"name": "invalid-windows.md", "label": "output", "setting": "windows"} | ||
* @example {"name": "not-ok-windows.md", "label": "output", "setting": "windows"} | ||
* | ||
@@ -62,3 +62,5 @@ * 1:6: Expected linebreaks to be windows (`\r\n`), not unix (`\n`) | ||
function linebreakStyle(tree, file, pref) { | ||
function linebreakStyle(tree, file, option) { | ||
var preferred = | ||
typeof option === 'string' && option !== 'consistent' ? option : null | ||
var content = String(file) | ||
@@ -70,14 +72,12 @@ var position = location(content).toPosition | ||
pref = typeof pref === 'string' && pref !== 'consistent' ? pref : null | ||
while (index !== -1) { | ||
type = types[content.charAt(index - 1) === '\r'] | ||
if (pref) { | ||
if (pref !== type) { | ||
if (preferred) { | ||
if (preferred !== type) { | ||
reason = | ||
'Expected linebreaks to be ' + | ||
pref + | ||
preferred + | ||
' (`' + | ||
escaped[pref] + | ||
escaped[preferred] + | ||
'`), not ' + | ||
@@ -92,3 +92,3 @@ type + | ||
} else { | ||
pref = type | ||
preferred = type | ||
} | ||
@@ -95,0 +95,0 @@ |
{ | ||
"name": "remark-lint-linebreak-style", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "remark-lint rule to warn when linebreaks violate a given or detected style", | ||
@@ -10,2 +10,3 @@ "license": "MIT", | ||
"rule", | ||
"remark-lint-rule", | ||
"linebreak", | ||
@@ -21,2 +22,6 @@ "line", | ||
"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)", | ||
@@ -23,0 +28,0 @@ "contributors": [ |
@@ -22,3 +22,3 @@ <!--This file is generated--> | ||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify) | ||
always uses unix-style linebreaks. | ||
always uses unix linebreaks. | ||
@@ -34,3 +34,3 @@ See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) | ||
##### `valid-consistent-as-windows.md` | ||
##### `ok-consistent-as-windows.md` | ||
@@ -50,3 +50,3 @@ ###### In | ||
##### `valid-consistent-as-unix.md` | ||
##### `ok-consistent-as-unix.md` | ||
@@ -66,3 +66,3 @@ ###### In | ||
##### `invalid-unix.md` | ||
##### `not-ok-unix.md` | ||
@@ -85,3 +85,3 @@ When configured with `'unix'`. | ||
##### `invalid-windows.md` | ||
##### `not-ok-windows.md` | ||
@@ -117,12 +117,12 @@ When configured with `'windows'`. | ||
```diff | ||
... | ||
… | ||
"remarkConfig": { | ||
"plugins": [ | ||
... | ||
… | ||
"lint", | ||
+ "lint-linebreak-style", | ||
... | ||
… | ||
] | ||
} | ||
... | ||
… | ||
``` | ||
@@ -139,4 +139,4 @@ | ||
```diff | ||
var remark = require('remark'); | ||
var report = require('vfile-reporter'); | ||
var remark = require('remark') | ||
var report = require('vfile-reporter') | ||
@@ -147,4 +147,4 @@ remark() | ||
.process('_Emphasis_ and **importance**', function (err, file) { | ||
console.error(report(err || file)); | ||
}); | ||
console.error(report(err || file)) | ||
}) | ||
``` | ||
@@ -158,4 +158,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. | ||
@@ -189,3 +189,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 | ||
@@ -192,0 +192,0 @@ [chat]: https://spectrum.chat/unified/remark |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7526
82