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

remark-lint-maximum-heading-length

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-maximum-heading-length - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

index.d.ts

45

index.js

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

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

@@ -20,7 +21,9 @@ * # Alpha bravo charlie delta echo foxtrot golf hotel

*
* @example {"name": "not-ok.md", "setting": 40, "label": "input"}
* @example
* {"name": "not-ok.md", "setting": 40, "label": "input"}
*
* # Alpha bravo charlie delta echo foxtrot golf hotel
*
* @example {"name": "not-ok.md", "setting": 40, "label": "output"}
* @example
* {"name": "not-ok.md", "setting": 40, "label": "output"}
*

@@ -30,24 +33,24 @@ * 1:1-1:52: Use headings shorter than `40`

'use strict'
/**
* @typedef {import('mdast').Root} Root
* @typedef {number} Options
*/
var rule = require('unified-lint-rule')
var visit = require('unist-util-visit')
var generated = require('unist-util-generated')
var toString = require('mdast-util-to-string')
import {lintRule} from 'unified-lint-rule'
import {visit} from 'unist-util-visit'
import {generated} from 'unist-util-generated'
import {toString} from 'mdast-util-to-string'
module.exports = rule(
const remarkLintMaximumHeadingLength = lintRule(
'remark-lint:maximum-heading-length',
maximumHeadingLength
/** @type {import('unified-lint-rule').Rule<Root, Options>} */
(tree, file, option = 60) => {
visit(tree, 'heading', (node) => {
if (!generated(node) && toString(node).length > option) {
file.message('Use headings shorter than `' + option + '`', node)
}
})
}
)
function maximumHeadingLength(tree, file, option) {
var preferred = typeof option === 'number' && !isNaN(option) ? option : 60
visit(tree, 'heading', visitor)
function visitor(node) {
if (!generated(node) && toString(node).length > preferred) {
file.message('Use headings shorter than `' + preferred + '`', node)
}
}
}
export default remarkLintMaximumHeadingLength
{
"name": "remark-lint-maximum-heading-length",
"version": "2.0.1",
"version": "3.0.0",
"description": "remark-lint rule to warn when headings are too long",

@@ -24,12 +24,28 @@ "license": "MIT",

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

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

@@ -68,2 +71,5 @@

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

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

@@ -121,5 +130,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

@@ -144,6 +153,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

@@ -150,0 +161,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