remark-lint-no-heading-like-paragraph
Advanced tools
Comparing version 1.0.1 to 1.0.2
37
index.js
@@ -26,27 +26,34 @@ /** | ||
'use strict'; | ||
'use strict' | ||
var rule = require('unified-lint-rule'); | ||
var visit = require('unist-util-visit'); | ||
var generated = require('unist-util-generated'); | ||
var rule = require('unified-lint-rule') | ||
var visit = require('unist-util-visit') | ||
var generated = require('unist-util-generated') | ||
module.exports = rule('remark-lint:no-heading-like-paragraph', noHeadingLikeParagraph); | ||
module.exports = rule( | ||
'remark-lint:no-heading-like-paragraph', | ||
noHeadingLikeParagraph | ||
) | ||
var fence = '#######'; | ||
var fence = '#######' | ||
var reason = 'This looks like a heading but has too many hashes' | ||
function noHeadingLikeParagraph(tree, file) { | ||
visit(tree, 'paragraph', visitor); | ||
visit(tree, 'paragraph', visitor) | ||
function visitor(node) { | ||
var head = node.children[0]; | ||
var head | ||
if ( | ||
head && | ||
head.type === 'text' && | ||
head.value.slice(0, fence.length) === fence && | ||
!generated(node) | ||
) { | ||
file.message('This looks like a heading but has too many hashes', node); | ||
if (!generated(node)) { | ||
head = node.children[0] | ||
if ( | ||
head && | ||
head.type === 'text' && | ||
head.value.slice(0, fence.length) === fence | ||
) { | ||
file.message(reason, node) | ||
} | ||
} | ||
} | ||
} |
{ | ||
"name": "remark-lint-no-heading-like-paragraph", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "remark-lint rule to for too many hashes (h7+ “headings”)", | ||
@@ -13,4 +13,4 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-heading-like-paragraph", | ||
"bugs": "https://github.com/wooorm/remark-lint/issues", | ||
"repository": "https://github.com/remarkjs/remark-lint/tree/master/packages/remark-lint-no-heading-like-paragraph", | ||
"bugs": "https://github.com/remarkjs/remark-lint/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
@@ -17,0 +17,0 @@ "contributors": [ |
@@ -88,2 +88,2 @@ <!--This file is generated--> | ||
[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) |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
3182
50