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

remark-lint-no-emphasis-as-heading

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint-no-emphasis-as-heading - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

34

index.js

@@ -32,33 +32,31 @@ /**

'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-emphasis-as-heading', noEmphasisAsHeading);
module.exports = rule('remark-lint:no-emphasis-as-heading', noEmphasisAsHeading)
function noEmphasisAsHeading(ast, file) {
visit(ast, 'paragraph', visitor);
var reason = 'Don’t use emphasis to introduce a section, use a heading'
function noEmphasisAsHeading(tree, file) {
visit(tree, 'paragraph', visitor)
function visitor(node, index, parent) {
var children = node.children;
var child = children[0];
var prev = parent.children[index - 1];
var next = parent.children[index + 1];
var head = node.children[0]
var prev = parent.children[index - 1]
var next = parent.children[index + 1]
if (generated(node)) {
return;
}
if (
!generated(node) &&
(!prev || prev.type !== 'heading') &&
next &&
next.type === 'paragraph' &&
children.length === 1 &&
(child.type === 'emphasis' || child.type === 'strong')
node.children.length === 1 &&
(head.type === 'emphasis' || head.type === 'strong')
) {
file.message('Don’t use emphasis to introduce a section, use a heading', node);
file.message(reason, node)
}
}
}
{
"name": "remark-lint-no-emphasis-as-heading",
"version": "1.0.1",
"version": "1.0.2",
"description": "remark-lint rule to warn when emphasis or importance is used instead of a heading",

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

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

@@ -17,0 +17,0 @@ "contributors": [

@@ -14,3 +14,3 @@ <!--This file is generated-->

| ------ | ------- |
| [`remark-preset-lint-markdown-style-guide`](https://github.com/wooorm/remark-lint/tree/master/packages/remark-preset-lint-markdown-style-guide) | |
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/master/packages/remark-preset-lint-markdown-style-guide) | |

@@ -99,2 +99,2 @@ ## Example

[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