Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-lint-linebreak-style

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint-linebreak-style - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

66

index.js

@@ -13,2 +13,10 @@ /**

*
* ## Fix
*
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify)
* always uses unix-style linebreaks.
*
* See [Using remark to fix your markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
* on how to automatically fix warnings for this rule.
*
* @example {"name": "valid-consistent-as-windows.md"}

@@ -41,42 +49,46 @@ *

'use strict';
'use strict'
var rule = require('unified-lint-rule');
var location = require('vfile-location');
var rule = require('unified-lint-rule')
var location = require('vfile-location')
module.exports = rule('remark-lint:linebreak-style', linebreakStyle);
module.exports = rule('remark-lint:linebreak-style', linebreakStyle)
var sequences = {
unix: '\n',
windows: '\r\n'
};
var escaped = {unix: '\\n', windows: '\\r\\n'}
var types = {true: 'windows', false: 'unix'}
var escaped = {
unix: '\\n',
windows: '\\r\\n'
};
function linebreakStyle(tree, file, pref) {
var content = String(file)
var position = location(content).toPosition
var index = content.indexOf('\n')
var type
var reason
function linebreakStyle(ast, file, preferred) {
var content = String(file);
var position = location(content).toPosition;
var index = content.indexOf('\n');
var type;
pref = typeof pref === 'string' && pref !== 'consistent' ? pref : null
while (index !== -1) {
type = content.charAt(index - 1) === '\r' ? 'windows' : 'unix';
type = types[content.charAt(index - 1) === '\r']
if (preferred) {
if (sequences[preferred] !== sequences[type]) {
file.message(
'Expected linebreaks to be ' + preferred + ' (`' + escaped[preferred] + '`), ' +
'not ' + type + ' (`' + escaped[type] + '`)',
position(index)
);
if (pref) {
if (pref !== type) {
reason =
'Expected linebreaks to be ' +
pref +
' (`' +
escaped[pref] +
'`), ' +
'not ' +
type +
' (`' +
escaped[type] +
'`)'
file.message(reason, position(index))
}
} else {
preferred = type;
pref = type
}
index = content.indexOf('\n', index + 1);
index = content.indexOf('\n', index + 1)
}
}
{
"name": "remark-lint-linebreak-style",
"version": "1.0.1",
"version": "1.0.2",
"description": "remark-lint rule to warn when linebreaks violate a given or detected style",

@@ -18,4 +18,4 @@ "license": "MIT",

],
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-linebreak-style",
"bugs": "https://github.com/wooorm/remark-lint/issues",
"repository": "https://github.com/remarkjs/remark-lint/tree/master/packages/remark-lint-linebreak-style",
"bugs": "https://github.com/remarkjs/remark-lint/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

@@ -22,0 +22,0 @@ "contributors": [

@@ -11,2 +11,10 @@ <!--This file is generated-->

## Fix
[`remark-stringify`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify)
always uses unix-style linebreaks.
See [Using remark to fix your markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
on how to automatically fix warnings for this rule.
## Presets

@@ -129,2 +137,2 @@

[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
[MIT](https://github.com/remarkjs/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc