Socket
Socket
Sign inDemoInstall

remark-lint-no-heading-indent

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-no-heading-indent - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

index.d.ts

71

index.js

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

*
* @example {"name": "ok.md"}
* @example
* {"name": "ok.md"}
*

@@ -30,3 +31,4 @@ * #·Hello world

*
* @example {"name": "not-ok.md", "label": "input"}
* @example
* {"name": "not-ok.md", "label": "input"}
*

@@ -43,3 +45,4 @@ * ···# Hello world

*
* @example {"name": "not-ok.md", "label": "output"}
* @example
* {"name": "not-ok.md", "label": "output"}
*

@@ -52,35 +55,39 @@ * 1:4: Remove 3 spaces before this heading

'use strict'
/**
* @typedef {import('mdast').Root} Root
*/
var rule = require('unified-lint-rule')
var plural = require('pluralize')
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 plural from 'pluralize'
import {visit} from 'unist-util-visit'
import {pointStart} from 'unist-util-position'
import {generated} from 'unist-util-generated'
module.exports = rule('remark-lint:no-heading-indent', noHeadingIndent)
const remarkLintNoHeadingIndent = lintRule(
'remark-lint:no-heading-indent',
/** @type {import('unified-lint-rule').Rule<Root, void>} */
(tree, file) => {
visit(tree, 'heading', (node, _, parent) => {
// Note: it’s rather complex to detect what the expected indent is in block
// quotes and lists, so let’s only do directly in root for now.
if (generated(node) || (parent && parent.type !== 'root')) {
return
}
var start = position.start
const diff = pointStart(node).column - 1
function noHeadingIndent(tree, file) {
visit(tree, 'heading', visitor)
if (diff) {
file.message(
'Remove ' +
diff +
' ' +
plural('space', diff) +
' before this heading',
pointStart(node)
)
}
})
}
)
function visitor(node, _, parent) {
var diff
// Note: it’s rather complex to detect what the expected indent is in block
// quotes and lists, so let’s only do directly in root for now.
if (generated(node) || (parent && parent.type !== 'root')) {
return
}
diff = start(node).column - 1
if (diff) {
file.message(
'Remove ' + diff + ' ' + plural('space', diff) + ' before this heading',
start(node)
)
}
}
}
export default remarkLintNoHeadingIndent
{
"name": "remark-lint-no-heading-indent",
"version": "3.0.0",
"version": "4.0.0",
"description": "remark-lint rule to warn when headings are indented",

@@ -24,13 +24,29 @@ "license": "MIT",

],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts",
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"pluralize": "^8.0.0",
"unified-lint-rule": "^1.0.0",
"unist-util-generated": "^1.1.0",
"unist-util-position": "^3.0.0",
"unist-util-visit": "^2.0.0"
"unified": "^10.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-generated": "^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
}
}

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

@@ -87,2 +90,5 @@

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

@@ -114,10 +120,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 remarkLintNoHeadingIndent from 'remark-lint-no-heading-indent'
remark()
.use(require('remark-lint'))
+ .use(require('remark-lint-no-heading-indent'))
.process('_Emphasis_ and **importance**', function (err, file) {
console.error(report(err || file))
.use(remarkLint)
+ .use(remarkLintNoHeadingIndent)
.process('_Emphasis_ and **importance**')
.then((file) => {
console.error(reporter(file))
})

@@ -140,5 +149,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

@@ -167,2 +176,4 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://docs.npmjs.com/cli/install

@@ -169,0 +180,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