remark-lint-no-table-indentation
Advanced tools
Comparing version 1.0.1 to 1.0.2
49
index.js
@@ -9,2 +9,10 @@ /** | ||
* | ||
* ## Fix | ||
* | ||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify) | ||
* removes all unneeded indentation before tables. | ||
* | ||
* 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"} | ||
@@ -32,31 +40,36 @@ * | ||
'use strict'; | ||
'use strict' | ||
var rule = require('unified-lint-rule'); | ||
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 visit = require('unist-util-visit') | ||
var position = require('unist-util-position') | ||
var generated = require('unist-util-generated') | ||
module.exports = rule('remark-lint:no-table-indentation', noTableIndentation); | ||
module.exports = rule('remark-lint:no-table-indentation', noTableIndentation) | ||
function noTableIndentation(ast, file) { | ||
visit(ast, 'table', visitor); | ||
var reason = 'Do not indent table rows' | ||
function noTableIndentation(tree, file) { | ||
var contents = String(file) | ||
visit(tree, 'table', visitor) | ||
function visitor(node) { | ||
var contents = file.toString(); | ||
if (generated(node)) { | ||
return; | ||
if (!generated(node)) { | ||
node.children.forEach(each) | ||
} | ||
node.children.forEach(each); | ||
return visit.SKIP | ||
} | ||
function each(row) { | ||
var fence = contents.slice(position.start(row).offset, position.start(row.children[0]).offset); | ||
function each(row) { | ||
var fence = contents.slice( | ||
position.start(row).offset, | ||
position.start(row.children[0]).offset | ||
) | ||
if (fence.indexOf('|') > 1) { | ||
file.message('Do not indent table rows', row); | ||
} | ||
if (fence.indexOf('|') > 1) { | ||
file.message(reason, row) | ||
} | ||
} | ||
} |
{ | ||
"name": "remark-lint-no-table-indentation", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "remark-lint rule to warn when tables are indented", | ||
@@ -13,4 +13,4 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-table-indentation", | ||
"bugs": "https://github.com/wooorm/remark-lint/issues", | ||
"repository": "https://github.com/remarkjs/remark-lint/tree/master/packages/remark-lint-no-table-indentation", | ||
"bugs": "https://github.com/remarkjs/remark-lint/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
@@ -17,0 +17,0 @@ "contributors": [ |
@@ -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 before tables. | ||
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 | ||
@@ -14,3 +22,3 @@ | ||
| ------ | ------- | | ||
| [`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) | | | ||
@@ -101,2 +109,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) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
4394
63
108