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
2
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 2.0.1 to 3.0.0

index.d.ts

89

index.js

@@ -21,3 +21,4 @@ /**

*
* @example {"name": "ok-consistent-as-windows.md"}
* @example
* {"name": "ok-consistent-as-windows.md"}
*

@@ -27,3 +28,4 @@ * Alpha␍␊

*
* @example {"name": "ok-consistent-as-unix.md"}
* @example
* {"name": "ok-consistent-as-unix.md"}
*

@@ -33,15 +35,19 @@ * Alpha␊

*
* @example {"name": "not-ok-unix.md", "label": "input", "setting": "unix", "config": {"positionless": true}}
* @example
* {"name": "not-ok-unix.md", "label": "input", "setting": "unix", "positionless": true}
*
* Alpha␍␊
*
* @example {"name": "not-ok-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": "not-ok-windows.md", "label": "input", "setting": "windows", "config": {"positionless": true}}
* @example
* {"name": "not-ok-windows.md", "label": "input", "setting": "windows", "positionless": true}
*
* Alpha␊
*
* @example {"name": "not-ok-windows.md", "label": "output", "setting": "windows"}
* @example
* {"name": "not-ok-windows.md", "label": "output", "setting": "windows"}
*

@@ -51,45 +57,46 @@ * 1:6: Expected linebreaks to be windows (`\r\n`), not unix (`\n`)

'use strict'
/**
* @typedef {import('mdast').Root} Root
* @typedef {'unix'|'windows'} Type
* @typedef {'consistent'|Type} Options
*/
var rule = require('unified-lint-rule')
var location = require('vfile-location')
import {lintRule} from 'unified-lint-rule'
import {location} from 'vfile-location'
module.exports = rule('remark-lint:linebreak-style', linebreakStyle)
const escaped = {unix: '\\n', windows: '\\r\\n'}
var escaped = {unix: '\\n', windows: '\\r\\n'}
var types = {true: 'windows', false: 'unix'}
const remarkLintLinebreakStyle = lintRule(
'remark-lint:linebreak-style',
/** @type {import('unified-lint-rule').Rule<Root, Options>} */
(_, file, option = 'consistent') => {
const value = String(file)
const toPoint = location(value).toPoint
let index = value.indexOf('\n')
function linebreakStyle(tree, file, option) {
var preferred =
typeof option === 'string' && option !== 'consistent' ? option : null
var content = String(file)
var position = location(content).toPosition
var index = content.indexOf('\n')
var type
var reason
while (index !== -1) {
const type = value.charAt(index - 1) === '\r' ? 'windows' : 'unix'
while (index !== -1) {
type = types[content.charAt(index - 1) === '\r']
if (preferred) {
if (preferred !== type) {
reason =
if (option === 'consistent') {
option = type
} else if (option !== type) {
file.message(
'Expected linebreaks to be ' +
preferred +
' (`' +
escaped[preferred] +
'`), not ' +
type +
' (`' +
escaped[type] +
'`)'
option +
' (`' +
escaped[option] +
'`), not ' +
type +
' (`' +
escaped[type] +
'`)',
toPoint(index)
)
}
file.message(reason, position(index))
}
} else {
preferred = type
index = value.indexOf('\n', index + 1)
}
}
)
index = content.indexOf('\n', index + 1)
}
}
export default remarkLintLinebreakStyle
{
"name": "remark-lint-linebreak-style",
"version": "2.0.1",
"version": "3.0.0",
"description": "remark-lint rule to warn when linebreaks violate a given or detected style",

@@ -29,10 +29,26 @@ "license": "MIT",

],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts",
"index.js"
],
"dependencies": {
"unified-lint-rule": "^1.0.0",
"vfile-location": "^3.0.0"
"@types/mdast": "^3.0.0",
"unified": "^10.0.0",
"unified-lint-rule": "^2.0.0",
"vfile-location": "^4.0.0"
},
"xo": false
"scripts": {
"build": "rimraf \"*.d.ts\" && tsc && type-coverage"
},
"xo": false,
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true
}
}

@@ -101,2 +101,5 @@ <!--This file is generated-->

This package is [ESM only][esm]:
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
[npm][]:

@@ -108,2 +111,5 @@

This package exports no identifiers.
The default export is `remarkLintLinebreakStyle`.
## Use

@@ -135,10 +141,13 @@

```diff
var remark = require('remark')
var report = require('vfile-reporter')
import {remark} from 'remark'
import {reporter} from 'vfile-reporter'
import remarkLint from 'remark-lint'
import remarkLintLinebreakStyle from 'remark-lint-linebreak-style'
remark()
.use(require('remark-lint'))
+ .use(require('remark-lint-linebreak-style'))
.process('_Emphasis_ and **importance**', function (err, file) {
console.error(report(err || file))
.use(remarkLint)
+ .use(remarkLintLinebreakStyle)
.process('_Emphasis_ and **importance**')
.then((file) => {
console.error(reporter(file))
})

@@ -161,5 +170,5 @@ ```

[build-badge]: https://img.shields.io/travis/remarkjs/remark-lint/main.svg
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
[build]: https://travis-ci.org/remarkjs/remark-lint
[build]: https://github.com/remarkjs/remark-lint/actions

@@ -184,6 +193,8 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg

[chat-badge]: https://img.shields.io/badge/chat-spectrum.svg
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://spectrum.chat/unified/remark
[chat]: https://github.com/remarkjs/remark/discussions
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://docs.npmjs.com/cli/install

@@ -190,0 +201,0 @@

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