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

remark-lint-definition-spacing

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint-definition-spacing - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

index.d.ts

61

index.js

@@ -9,11 +9,14 @@ /**

*
* @example {"name": "ok.md"}
* @example
* {"name": "ok.md"}
*
* [example domain]: http://example.com "Example Domain"
*
* @example {"name": "not-ok.md", "label": "input"}
* @example
* {"name": "not-ok.md", "label": "input"}
*
* [example····domain]: http://example.com "Example Domain"
*
* @example {"name": "not-ok.md", "label": "output"}
* @example
* {"name": "not-ok.md", "label": "output"}
*

@@ -23,30 +26,38 @@ * 1:1-1:57: Do not use consecutive whitespace in definition labels

'use strict'
/**
* @typedef {import('mdast').Root} Root
*/
var rule = require('unified-lint-rule')
var visit = require('unist-util-visit')
var position = require('unist-util-position')
var generated = require('unist-util-generated')
import {lintRule} from 'unified-lint-rule'
import {visit} from 'unist-util-visit'
import {pointStart, pointEnd} from 'unist-util-position'
module.exports = rule('remark-lint:definition-spacing', definitionSpacing)
const label = /^\s*\[((?:\\[\s\S]|[^[\]])+)]/
var label = /^\s*\[((?:\\[\s\S]|[^[\]])+)]/
var reason = 'Do not use consecutive whitespace in definition labels'
const remarkLintDefinitionSpacing = lintRule(
'remark-lint:definition-spacing',
/** @type {import('unified-lint-rule').Rule<Root, void>} */
(tree, file) => {
const value = String(file)
function definitionSpacing(tree, file) {
var contents = String(file)
visit(tree, (node) => {
if (node.type === 'definition' || node.type === 'footnoteDefinition') {
const start = pointStart(node).offset
const end = pointEnd(node).offset
visit(tree, ['definition', 'footnoteDefinition'], check)
if (typeof start === 'number' && typeof end === 'number') {
const match = value.slice(start, end).match(label)
function check(node) {
var start = position.start(node).offset
var end = position.end(node).offset
if (match && /[ \t\n]{2,}/.test(match[1])) {
file.message(
'Do not use consecutive whitespace in definition labels',
node
)
}
}
}
})
}
)
if (
!generated(node) &&
/[ \t\n]{2,}/.test(contents.slice(start, end).match(label)[1])
) {
file.message(reason, node)
}
}
}
export default remarkLintDefinitionSpacing
{
"name": "remark-lint-definition-spacing",
"version": "2.0.1",
"version": "3.0.0",
"description": "remark-lint rule to warn when consecutive whitespace is used in a definition",

@@ -24,12 +24,27 @@ "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",
"unist-util-generated": "^1.1.0",
"unist-util-position": "^3.0.0",
"unist-util-visit": "^2.0.0"
"@types/mdast": "^3.0.0",
"unified": "^10.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^4.0.0"
},
"xo": false
"scripts": {
"build": "rimraf \"*.d.ts\" && tsc && type-coverage"
},
"xo": false,
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true
}
}

@@ -55,2 +55,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][]:

@@ -62,2 +65,5 @@

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

@@ -89,10 +95,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 remarkLintDefinitionSpacing from 'remark-lint-definition-spacing'
remark()
.use(require('remark-lint'))
+ .use(require('remark-lint-definition-spacing'))
.process('_Emphasis_ and **importance**', function (err, file) {
console.error(report(err || file))
.use(remarkLint)
+ .use(remarkLintDefinitionSpacing)
.process('_Emphasis_ and **importance**')
.then((file) => {
console.error(reporter(file))
})

@@ -115,5 +124,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

@@ -138,6 +147,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

@@ -144,0 +155,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