Socket
Socket
Sign inDemoInstall

remark-lint-no-heading-indent

Package Overview
Dependencies
Maintainers
1
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 1.0.1 to 1.0.2

59

index.js

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

*
* ## Fix
*
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify)
* removes all unneeded indentation around headings.
*
* 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.md"}

@@ -42,45 +50,48 @@ *

'use strict';
'use strict'
var rule = require('unified-lint-rule');
var plural = require('plur');
var visit = require('unist-util-visit');
var position = require('unist-util-position');
var generated = require('unist-util-generated');
var rule = require('unified-lint-rule')
var plural = require('plur')
var visit = require('unist-util-visit')
var position = require('unist-util-position')
var generated = require('unist-util-generated')
module.exports = rule('remark-lint:no-heading-indent', noHeadingIndent);
module.exports = rule('remark-lint:no-heading-indent', noHeadingIndent)
var start = position.start;
var start = position.start
function noHeadingIndent(ast, file) {
var contents = file.toString();
var length = contents.length;
function noHeadingIndent(tree, file) {
var contents = String(file)
var length = contents.length
visit(ast, 'heading', visitor);
visit(tree, 'heading', visitor)
function visitor(node) {
var initial = start(node);
var begin = initial.offset;
var index = begin - 1;
var character;
var diff;
var initial
var begin
var index
var character
var diff
if (generated(node)) {
return;
return
}
initial = start(node)
begin = initial.offset
index = begin - 1
while (++index < length) {
character = contents.charAt(index);
character = contents.charAt(index)
if (character !== ' ' && character !== '\t') {
break;
break
}
}
diff = index - begin;
diff = index - begin
if (diff) {
file.message(
'Remove ' + diff + ' ' + plural('space', diff) +
' before this heading',
'Remove ' + diff + ' ' + plural('space', diff) + ' before this heading',
{

@@ -90,5 +101,5 @@ line: initial.line,

}
);
)
}
}
}
{
"name": "remark-lint-no-heading-indent",
"version": "1.0.1",
"version": "1.0.2",
"description": "remark-lint rule to warn when headings are indented",

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

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

@@ -24,3 +24,3 @@ "contributors": [

"dependencies": {
"plur": "^2.1.2",
"plur": "^3.0.0",
"unified-lint-rule": "^1.0.0",

@@ -27,0 +27,0 @@ "unist-util-generated": "^1.1.0",

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

## Fix
[`remark-stringify`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify)
removes all unneeded indentation around headings.
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

@@ -108,2 +116,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