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

remark-lint-no-empty-sections

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint-no-empty-sections - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

.eslintignore

20

dist/no-empty-section.js
'use strict';
var rule = require('unified-lint-rule');
var visit = require('unist-util-visit');
var toString = require('mdast-util-to-string');
function noEmptySection(ast, file, preferred, done) {
visit(ast, function (node, index, parent) {
function noEmptySection(ast, file) {
visit(ast, 'heading', function (node, index, parent) {
var next = parent && parent.children[index + 1];
var label = toString(node);
if (next && node.type === 'heading' && next.type === 'heading' && node.depth === next.depth) {
file.warn('Remove empty section' + (node.children.length ? ': "' + node.children[0].value + '"' : ''), next);
if (next && next.type === 'heading' && next.depth === node.depth) {
file.warn('Remove empty section: "' + label + '"', {
start: node.position.end,
end: next.position.start
});
}
});
done();
}
module.exports = {
'empty-sections': noEmptySection
};
module.exports = rule('remark-lint:no-empty-sections', noEmptySection);

@@ -0,22 +1,19 @@

const rule = require('unified-lint-rule');
const visit = require('unist-util-visit');
const toString = require('mdast-util-to-string');
function noEmptySection(ast, file, preferred, done) {
visit(ast, (node, index, parent) => {
function noEmptySection(ast, file) {
visit(ast, 'heading', (node, index, parent) => {
const next = parent && parent.children[index + 1];
const label = toString(node);
if (
next &&
(node.type === 'heading') &&
(next.type === 'heading') &&
(node.depth === next.depth)
) {
file.warn('Remove empty section' + (node.children.length ? ': "' + node.children[0].value + '"' : ''), next);
if (next && next.type === 'heading' && next.depth === node.depth) {
file.warn(`Remove empty section: "${label}"`, {
start: node.position.end,
end: next.position.start
});
}
});
done();
}
module.exports = {
'empty-sections': noEmptySection
};
module.exports = rule('remark-lint:no-empty-sections', noEmptySection);
{
"name": "remark-lint-no-empty-sections",
"version": "1.0.0",
"version": "2.0.0",
"description": "Checks that all markdown titles have a content",

@@ -12,14 +12,28 @@ "author": "Victor Felder <victorfelder@gmail.com>",

"dependencies": {
"mdast-util-to-string": "^1.0.2",
"unified-lint-rule": "^1.0.0",
"unist-util-visit": "^1.0.0"
},
"devDependencies": {
"babel-cli": "^6.23.0",
"babel-core": "^6.3.17",
"babel-eslint": "^5.0.0-beta6",
"babel-eslint": "^7.1.1",
"babel-preset-es2015": "^6.3.13",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^2.1.1",
"eslint-plugin-react": "^3.11.3"
"eslint": "^3.16.1",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.0",
"remark": "^7.0.0",
"remark-cli": "^3.0.0",
"remark-lint": "^6.0.0",
"tape": "^4.6.3"
},
"scripts": {
"build": "babel lib -d dist"
"lint": "eslint .",
"build-md": "remark . -qfo",
"build-lib": "babel lib -d dist",
"build": "npm run build-md && npm run build-lib",
"test-api": "node test",
"test": "npm run lint && npm run build && npm run test-api"
},

@@ -26,0 +40,0 @@ "bugs": {

@@ -5,3 +5,3 @@ # remark-lint-no-empty-sections

This rule checks that every `([#]+)title` has some content. This content can be anything: a lower-level title, a higher-level title, text, list, etc. It will only complain if you have a n-level title without content followed by another n-level title.
This rule checks that every `([#]+)title` has some content. This content can be anything: a lower-level title, a higher-level title, text, list, etc. It will only complain if you have an n-level title without content followed by another n-level title.

@@ -29,5 +29,4 @@ ```Text

```bash
npm install -g remark
npm install -g remark-lint
npm install remark-lint-no-empty-sections # local install!
npm install -g remark-cli
npm install remark-lint remark-lint-no-empty-sections
```

@@ -39,7 +38,6 @@

{
"plugins": {
"remark-lint": {
"external": ["remark-lint-no-empty-sections"]
}
}
"plugins": [
"lint",
"lint-no-empty-sections"
]
}

@@ -51,3 +49,3 @@ ```

```bash
remark --no-stdout xxx.md
remark xxx.md
```

@@ -58,10 +56,5 @@

```bash
npm install -g remark
npm install -g remark-lint
npm install -g remark-lint-no-empty-sections # global install!
remark --no-stdout -u remark-lint="external:[\"remark-lint-no-empty-sections\"]" xxx.md
npm install -g remark-cli
npm install remark-lint remark-lint-no-empty-sections
remark -u lint -u lint-no-empty-sections xxx.md
```
Note that the `lint=<lint_options>` option only works with `remark >= 1.1.1`.
This `README.md` is based on [this one](https://github.com/chcokr/mdast-lint-sentence-newline/blob/250b106c9e19b387270099cf16f17a84643f8944/README.md) by [@chcokr](https://github.com/chcokr) (MIT).

Sorry, the diff of this file is not supported yet

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