mirror of
https://github.com/remarkjs/remark-lint.git
synced 2024-09-11 19:57:15 +03:00
Rewrite so that rules are published to npm individually
Additionally, this updates for remark@7.0.0, unified@6.0.0.
This commit is contained in:
parent
f7129967f7
commit
4a380fca27
211
doc/external.md
211
doc/external.md
@ -1,211 +0,0 @@
|
||||
# External rules
|
||||
|
||||
External rules make it easy to develop and publish small linting rules
|
||||
for markdown.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [Using external rules](#using-external-rules)
|
||||
* [Creating external rules](#creating-external-rules)
|
||||
|
||||
## Using external rules
|
||||
|
||||
External rules can be used in two ways:
|
||||
Either by passing their file-path or their name,
|
||||
in which case `remark-lint-` can be omitted, in an `external` array
|
||||
to **remark-lint** (this only works in Node.js), or by loading
|
||||
modules yourself and pass them in the `external` array too.
|
||||
|
||||
### CLI
|
||||
|
||||
Say we are in the following directory: `~/projects/things`.
|
||||
|
||||
Create a `.remarkrc` file and add the following JSON:
|
||||
|
||||
```json
|
||||
{
|
||||
"plugins": {
|
||||
"lint": {
|
||||
"external": [
|
||||
"no-empty-sections"
|
||||
],
|
||||
"empty-sections": true
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Add a markdown file, such as `readme.md` file, which looks as follows:
|
||||
|
||||
```md
|
||||
# A
|
||||
|
||||
## B (this section is empty!)
|
||||
|
||||
## C
|
||||
```
|
||||
|
||||
Then, install the required dependencies:
|
||||
|
||||
```sh
|
||||
npm install -g remark-cli remark-lint remark-lint-no-empty-sections
|
||||
```
|
||||
|
||||
Now, run the following in your shell, from the same directory:
|
||||
|
||||
```sh
|
||||
# This will process all markdown files in the current
|
||||
# directory, and pass the through the specified plugins.
|
||||
remark .
|
||||
```
|
||||
|
||||
That should show a report like:
|
||||
|
||||
```sh
|
||||
readme.md
|
||||
5:1-5:5 warning Remove empty section: "B (this section is empty!)" empty-sections
|
||||
|
||||
⚠ 1 warning
|
||||
```
|
||||
|
||||
### Programmatic
|
||||
|
||||
Say we have a file, `example.md`, which looks as follows:
|
||||
|
||||
```md
|
||||
[link](http://example.com/);
|
||||
```
|
||||
|
||||
And `example.js` next to it:
|
||||
|
||||
```js
|
||||
var fs = require('fs');
|
||||
var remark = require('remark');
|
||||
var lint = require('remark-lint');
|
||||
var report = require('vfile-reporter');
|
||||
var doc = fs.readFileSync('example.md', 'utf8');
|
||||
|
||||
remark()
|
||||
.use(lint, {
|
||||
external: ['no-url-trailing-slash'],
|
||||
trailingSlash: true
|
||||
})
|
||||
.process(doc, function (err, file) {
|
||||
console.log(report(err || file));
|
||||
});
|
||||
```
|
||||
|
||||
Then, install the required dependencies:
|
||||
|
||||
```sh
|
||||
npm install remark remark-lint remark-lint-no-url-trailing-slash
|
||||
```
|
||||
|
||||
Finally, run `example.js` with Node:
|
||||
|
||||
```sh
|
||||
node example.js
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```txt
|
||||
1:1-1:28 warning Remove trailing slash (http://example.com) trailing-slash
|
||||
|
||||
⚠ 1 warning
|
||||
```
|
||||
|
||||
## Creating external rules
|
||||
|
||||
External rule packages expose an object of dash-cased rule id’s to
|
||||
functions.
|
||||
|
||||
`index.js`:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
'code-js-flag': require('./rules/code-js-flag.js')
|
||||
};
|
||||
```
|
||||
|
||||
### Synchronous
|
||||
|
||||
Each rule is a function which gets passed a [`root`][root] node,
|
||||
a [virtual file][vfile], and a setting.
|
||||
|
||||
The setting is never `true` or `false`, those are used later to filter
|
||||
messages. Rules always run, even when they’re turned off, as they can
|
||||
be turned on from within markdown code through [comments][].
|
||||
|
||||
An example, `./rules/code-js-flag.js`, is as follows:
|
||||
|
||||
```js
|
||||
var visit = require('unist-util-visit');
|
||||
|
||||
module.exports = rule;
|
||||
|
||||
var valid = ['js', 'javascript', 'es', 'es6', 'javascript'];
|
||||
var def = valid[0];
|
||||
|
||||
function rule(ast, file, setting) {
|
||||
pref = setting == null ? def : setting;
|
||||
|
||||
if (valid.indexOf(pref) === -1) {
|
||||
/* `file.fail` is for invalid, unrecoverable things, **not** for
|
||||
* linting messages. */
|
||||
file.fail(pref + ' is not a valid JavaScript extension');
|
||||
return
|
||||
}
|
||||
|
||||
visit(ast, 'code', function (node) {
|
||||
/* Emit a linting message, only for JS code though. */
|
||||
if (valid.indexOf(node.lang) !== -1 && node.lang !== pref) {
|
||||
file.message(
|
||||
'JavaScript code blocks should use `' + pref + '` as a ' +
|
||||
'language flag, not `' + node.lang + '`',
|
||||
node
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Promises
|
||||
|
||||
A rule can return a promise, this will automatically switch everything
|
||||
to asynchronous and wait for the rule to resolve or reject before
|
||||
continuing on. Note: Do not resolve a value. Rejecting an error is OK.
|
||||
|
||||
```js
|
||||
function rule(ast, file, setting) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
// ...do async things.
|
||||
setImmediate(function () {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Callbacks
|
||||
|
||||
If a rule has a fourth parameters, `next`, it must be invoked, and it
|
||||
may be invoked asynchronously. An error may be given to `next` to stop
|
||||
all processing.
|
||||
|
||||
```js
|
||||
function rule(ast, file, setting, next) {
|
||||
/* ...do async things. */
|
||||
setImmediate(function () {
|
||||
next();
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
<!--Definitions:-->
|
||||
|
||||
[root]: https://github.com/wooorm/mdast#root
|
||||
|
||||
[vfile]: https://github.com/wooorm/vfile
|
||||
|
||||
[comments]: https://github.com/wooorm/remark-lint#configuring-remark-lint
|
2719
doc/rules.md
2719
doc/rules.md
File diff suppressed because it is too large
Load Diff
45
package.json
45
package.json
@ -10,19 +10,17 @@
|
||||
"devDependencies": {
|
||||
"browserify": "^14.0.0",
|
||||
"chalk": "^1.1.3",
|
||||
"decamelize": "^1.2.0",
|
||||
"decamelize-keys": "^1.1.0",
|
||||
"dox": "^0.9.0",
|
||||
"esmangle": "^1.0.0",
|
||||
"lerna": "2.0.0-beta.37",
|
||||
"nyc": "^10.0.0",
|
||||
"remark": "^6.0.0",
|
||||
"remark-cli": "^2.0.0",
|
||||
"remark-comment-config": "^4.0.0",
|
||||
"remark-github": "^6.0.0",
|
||||
"remark-lint-no-url-trailing-slash": "^2.0.0",
|
||||
"remark-toc": "^3.0.0",
|
||||
"remark-validate-links": "^5.0.0",
|
||||
"parse-author": "^1.0.0",
|
||||
"remark": "^7.0.0",
|
||||
"remark-cli": "^3.0.0",
|
||||
"remark-comment-config": "^5.0.0",
|
||||
"remark-github": "^7.0.0",
|
||||
"remark-toc": "^4.0.0",
|
||||
"remark-validate-links": "^6.0.0",
|
||||
"strip-indent": "^2.0.0",
|
||||
"tape": "^4.6.0",
|
||||
"to-vfile": "^2.0.0",
|
||||
@ -33,16 +31,15 @@
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "lerna bootstrap",
|
||||
"build-index": "node script/build-index.js",
|
||||
"build-presets": "node script/build-presets.js",
|
||||
"build-rules": "node script/build-docs.js",
|
||||
"build-md": "remark . --quiet --frail",
|
||||
"build-rules": "node script/build-rules.js",
|
||||
"build-md": "remark . -qfo",
|
||||
"build-bundle": "browserify packages/remark-lint/index.js --bare -s remarkLint > remark-lint.js",
|
||||
"build-mangle": "esmangle remark-lint.js > remark-lint.min.js",
|
||||
"build": "npm run build-presets && npm run build-md && npm run build-index && npm run build-rules && npm run build-bundle && npm run build-mangle",
|
||||
"build": "npm run build-presets && npm run build-rules && npm run build-md && npm run build-bundle && npm run build-mangle",
|
||||
"lint": "xo",
|
||||
"test-api": "tape test/index.js",
|
||||
"test-coverage": "nyc --reporter lcov tape test/index.js",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js",
|
||||
"test": "npm run build && npm run lint && npm run test-coverage"
|
||||
},
|
||||
"nyc": {
|
||||
@ -64,20 +61,14 @@
|
||||
]
|
||||
},
|
||||
"remarkConfig": {
|
||||
"output": true,
|
||||
"presets": [
|
||||
"plugins": [
|
||||
"./packages/remark-preset-lint-recommended",
|
||||
"./packages/remark-preset-lint-consistent"
|
||||
"./packages/remark-preset-lint-consistent",
|
||||
["toc", {"tight": true, "maxDepth": 2}],
|
||||
"comment-config",
|
||||
"github",
|
||||
"validate-links"
|
||||
],
|
||||
"plugins": {
|
||||
"comment-config": null,
|
||||
"github": null,
|
||||
"toc": {
|
||||
"tight": true,
|
||||
"maxDepth": 2
|
||||
},
|
||||
"validate-links": null
|
||||
},
|
||||
"settings": {
|
||||
"bullet": "*"
|
||||
}
|
||||
|
@ -51,31 +51,21 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Expose. */
|
||||
module.exports = blockquoteIndentation;
|
||||
|
||||
/* Dependencies. */
|
||||
var visit = require('unist-util-visit');
|
||||
var toString = require('mdast-util-to-string');
|
||||
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 toString = require('mdast-util-to-string');
|
||||
|
||||
/**
|
||||
* Warn when a blockquote has a too large or too small
|
||||
* indentation.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {number?} [preferred='consistent'] - Preferred
|
||||
* indentation between a blockquote and its content.
|
||||
* When not a number, defaults to the first found
|
||||
* indentation.
|
||||
*/
|
||||
function blockquoteIndentation(ast, file, preferred) {
|
||||
module.exports = rule('remark-lint:blockquote-indentation', blockquoteIndentation);
|
||||
|
||||
function blockquoteIndentation(tree, file, preferred) {
|
||||
preferred = isNaN(preferred) || typeof preferred !== 'number' ? null : preferred;
|
||||
|
||||
visit(ast, 'blockquote', function (node) {
|
||||
visit(tree, 'blockquote', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var indent;
|
||||
var diff;
|
||||
var word;
|
||||
@ -101,15 +91,9 @@ function blockquoteIndentation(ast, file, preferred) {
|
||||
} else {
|
||||
preferred = check(node);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the indent of a blockquote.
|
||||
*
|
||||
* @param {Node} node - Node to test.
|
||||
* @return {number} - Indentation.
|
||||
*/
|
||||
function check(node) {
|
||||
var head = node.children[0];
|
||||
var indentation = position.start(head).column - position.start(node).column;
|
32
packages/remark-lint-blockquote-indentation/package.json
Normal file
32
packages/remark-lint-blockquote-indentation/package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "remark-lint-blockquote-indentation",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when blockquotes are either indented too much or too little",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"blockquote",
|
||||
"indentation",
|
||||
"indent"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-blockquote-indentation",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"mdast-util-to-string": "^1.0.2",
|
||||
"plur": "^2.1.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
68
packages/remark-lint-blockquote-indentation/readme.md
Normal file
68
packages/remark-lint-blockquote-indentation/readme.md
Normal file
@ -0,0 +1,68 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-blockquote-indentation
|
||||
|
||||
Warn when blockquotes are either indented too much or too little.
|
||||
|
||||
Options: `number`, default: `'consistent'`.
|
||||
|
||||
The default value, `consistent`, detects the first used indentation
|
||||
and will warn when other blockquotes use a different indentation.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-blockquote-indentation
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is `2`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--This file is also valid by default-->
|
||||
|
||||
> Hello
|
||||
|
||||
Paragraph.
|
||||
|
||||
> World
|
||||
```
|
||||
|
||||
When this rule is `4`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--This file is also valid by default-->
|
||||
|
||||
> Hello
|
||||
|
||||
Paragraph.
|
||||
|
||||
> World
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
> Hello
|
||||
|
||||
Paragraph.
|
||||
|
||||
> World
|
||||
|
||||
Paragraph.
|
||||
|
||||
> World
|
||||
```
|
||||
|
||||
```text
|
||||
5:3: Remove 1 space between blockquote and content
|
||||
9:3: Add 1 space between blockquote and content
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
* The default value, `consistent`, detects the first used checked
|
||||
* and unchecked checkbox styles, and will warn when a subsequent
|
||||
* checkboxes uses a different style.
|
||||
* checkboxes use a different style.
|
||||
*
|
||||
* These values can also be passed in as an object, such as:
|
||||
*
|
||||
@ -71,34 +71,21 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var vfileLocation = require('vfile-location');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = checkboxCharacterStyle;
|
||||
module.exports = rule('remark-lint:checkbox-character-style', checkboxCharacterStyle);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
var end = position.end;
|
||||
|
||||
/* Constants. */
|
||||
var CHECKED = {x: true, X: true};
|
||||
var UNCHECKED = {' ': true, '\t': true};
|
||||
|
||||
/**
|
||||
* Warn when list item checkboxes violate a given style.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {Object?} preferred - An object with `checked`
|
||||
* and `unchecked` properties, each set to null to default to
|
||||
* the first found style, or set to `'x'` or `'X'` for checked,
|
||||
* or `' '` (space) or `'\t'` (tab) for unchecked.
|
||||
*/
|
||||
function checkboxCharacterStyle(ast, file, preferred) {
|
||||
function checkboxCharacterStyle(tree, file, preferred) {
|
||||
var contents = file.toString();
|
||||
var location = vfileLocation(file);
|
||||
|
||||
@ -136,7 +123,9 @@ function checkboxCharacterStyle(ast, file, preferred) {
|
||||
);
|
||||
}
|
||||
|
||||
visit(ast, 'listItem', function (node) {
|
||||
visit(tree, 'listItem', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var type;
|
||||
var initial;
|
||||
var final;
|
||||
@ -178,5 +167,5 @@ function checkboxCharacterStyle(ast, file, preferred) {
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
32
packages/remark-lint-checkbox-character-style/package.json
Normal file
32
packages/remark-lint-checkbox-character-style/package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "remark-lint-checkbox-character-style",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when list item checkboxes violate a given style",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"checkbox",
|
||||
"style",
|
||||
"task",
|
||||
"list"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-checkbox-character-style",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1",
|
||||
"vfile-location": "^2.0.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
98
packages/remark-lint-checkbox-character-style/readme.md
Normal file
98
packages/remark-lint-checkbox-character-style/readme.md
Normal file
@ -0,0 +1,98 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-checkbox-character-style
|
||||
|
||||
Warn when list item checkboxes violate a given style.
|
||||
|
||||
The default value, `consistent`, detects the first used checked
|
||||
and unchecked checkbox styles, and will warn when a subsequent
|
||||
checkboxes use a different style.
|
||||
|
||||
These values can also be passed in as an object, such as:
|
||||
|
||||
```js
|
||||
{checked: 'x', unchecked: ' '}
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-checkbox-character-style
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is `{ checked: 'x' }`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--This file is also valid by default-->
|
||||
|
||||
- [x] List item
|
||||
- [x] List item
|
||||
```
|
||||
|
||||
When this rule is `{ checked: 'X' }`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--This file is also valid by default-->
|
||||
|
||||
- [X] List item
|
||||
- [X] List item
|
||||
```
|
||||
|
||||
When this rule is `{ unchecked: ' ' }`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--This file is also valid by default-->
|
||||
|
||||
- [ ] List item
|
||||
- [ ] List item
|
||||
- [ ]··
|
||||
- [ ]
|
||||
```
|
||||
|
||||
When this rule is `{ unchecked: '\t' }`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--Also valid by default (note: `»` represents `\t`)-->
|
||||
|
||||
- [»] List item
|
||||
- [»] List item
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
<!--Note: `»` represents `\t`-->
|
||||
|
||||
- [x] List item
|
||||
- [X] List item
|
||||
- [ ] List item
|
||||
- [»] List item
|
||||
```
|
||||
|
||||
```text
|
||||
4:4-4:5: Checked checkboxes should use `x` as a marker
|
||||
6:4-6:5: Unchecked checkboxes should use ` ` as a marker
|
||||
```
|
||||
|
||||
When `{ unchecked: '!' }` is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Invalid unchecked checkbox marker `!`: use either `'\t'`, or `' '`
|
||||
```
|
||||
|
||||
When `{ checked: '!' }` is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Invalid checked checkbox marker `!`: use either `'x'`, or `'X'`
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -9,7 +9,7 @@
|
||||
* @example {"name": "valid.md"}
|
||||
*
|
||||
* - [ ] List item
|
||||
* + [x] List item
|
||||
* + [x] List Item
|
||||
* * [X] List item
|
||||
* - [ ] List item
|
||||
*
|
||||
@ -29,31 +29,24 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var vfileLocation = require('vfile-location');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = checkboxContentIndent;
|
||||
module.exports = rule('remark-lint:checkbox-content-indent', checkboxContentIndent);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
var end = position.end;
|
||||
|
||||
/**
|
||||
* Warn when list item checkboxes are followed by too much white-space.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {*} preferred - Ignored.
|
||||
*/
|
||||
function checkboxContentIndent(ast, file) {
|
||||
function checkboxContentIndent(tree, file) {
|
||||
var contents = file.toString();
|
||||
var location = vfileLocation(file);
|
||||
|
||||
visit(ast, 'listItem', function (node) {
|
||||
visit(tree, 'listItem', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var initial;
|
||||
var final;
|
||||
var value;
|
||||
@ -64,6 +57,7 @@ function checkboxContentIndent(ast, file) {
|
||||
}
|
||||
|
||||
initial = start(node).offset;
|
||||
/* istanbul ignore next - hard to test, couldn’t find a case. */
|
||||
final = (node.children.length ? start(node.children[0]) : end(node)).offset;
|
||||
|
||||
while (/[^\S\n]/.test(contents.charAt(final))) {
|
||||
@ -84,5 +78,5 @@ function checkboxContentIndent(ast, file) {
|
||||
start: location.toPosition(final - value.length + 1),
|
||||
end: location.toPosition(final)
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
32
packages/remark-lint-checkbox-content-indent/package.json
Normal file
32
packages/remark-lint-checkbox-content-indent/package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "remark-lint-checkbox-content-indent",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when list item checkboxes are followed by too much white-space",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"checkbox",
|
||||
"content",
|
||||
"task",
|
||||
"list"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-checkbox-content-indent",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1",
|
||||
"vfile-location": "^2.0.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
43
packages/remark-lint-checkbox-content-indent/readme.md
Normal file
43
packages/remark-lint-checkbox-content-indent/readme.md
Normal file
@ -0,0 +1,43 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-checkbox-content-indent
|
||||
|
||||
Warn when list item checkboxes are followed by too much white-space.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-checkbox-content-indent
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
- [ ] List item
|
||||
+ [x] List Item
|
||||
* [X] List item
|
||||
- [ ] List item
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
- [ ] List item
|
||||
+ [x] List item
|
||||
* [X] List item
|
||||
- [ ] List item
|
||||
```
|
||||
|
||||
```text
|
||||
2:7-2:8: Checkboxes should be followed by a single character
|
||||
3:7-3:9: Checkboxes should be followed by a single character
|
||||
4:7-4:10: Checkboxes should be followed by a single character
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -90,36 +90,23 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = codeBlockStyle;
|
||||
module.exports = rule('remark-lint:code-block-style', codeBlockStyle);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
var end = position.end;
|
||||
|
||||
/* Valid styles. */
|
||||
var STYLES = {
|
||||
null: true,
|
||||
fenced: true,
|
||||
indented: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Warn for violating code-block style.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {string?} [preferred='consistent'] - Preferred
|
||||
* code block style. Defaults to `'consistent'` when
|
||||
* not a a string. Otherwise, should be one of
|
||||
* `'fenced'` or `'indented'`.
|
||||
*/
|
||||
function codeBlockStyle(ast, file, preferred) {
|
||||
function codeBlockStyle(tree, file, preferred) {
|
||||
var contents = file.toString();
|
||||
|
||||
preferred = typeof preferred !== 'string' || preferred === 'consistent' ? null : preferred;
|
||||
@ -128,7 +115,11 @@ function codeBlockStyle(ast, file, preferred) {
|
||||
file.fail('Invalid code block style `' + preferred + '`: use either `\'consistent\'`, `\'fenced\'`, or `\'indented\'`');
|
||||
}
|
||||
|
||||
visit(ast, 'code', function (node) {
|
||||
visit(tree, 'code', visitor);
|
||||
|
||||
return;
|
||||
|
||||
function visitor(node) {
|
||||
var current = check(node);
|
||||
|
||||
if (!current) {
|
||||
@ -140,17 +131,9 @@ function codeBlockStyle(ast, file, preferred) {
|
||||
} else if (preferred !== current) {
|
||||
file.message('Code blocks should be ' + preferred, node);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
/**
|
||||
* Get the style of `node`.
|
||||
*
|
||||
* @param {Node} node - Node.
|
||||
* @return {string?} - `'fenced'`, `'indented'`, or
|
||||
* `null`.
|
||||
*/
|
||||
/* Get the style of `node`. */
|
||||
function check(node) {
|
||||
var initial = start(node).offset;
|
||||
var final = end(node).offset;
|
29
packages/remark-lint-code-block-style/package.json
Normal file
29
packages/remark-lint-code-block-style/package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "remark-lint-code-block-style",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when code-blocks do not adhere to a given style",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"code",
|
||||
"block"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-code-block-style",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
115
packages/remark-lint-code-block-style/readme.md
Normal file
115
packages/remark-lint-code-block-style/readme.md
Normal file
@ -0,0 +1,115 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-code-block-style
|
||||
|
||||
Warn when code-blocks do not adhere to a given style.
|
||||
|
||||
Options: `string`, either `'consistent'`, `'fenced'`, or `'indented'`,
|
||||
default: `'consistent'`.
|
||||
|
||||
The default value, `consistent`, detects the first used code-block
|
||||
style, and will warn when a subsequent code-block uses a different
|
||||
style.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-code-block-style
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is `'indented'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!-- This is also valid when `'consistent'` -->
|
||||
|
||||
alpha();
|
||||
|
||||
Paragraph.
|
||||
|
||||
bravo();
|
||||
```
|
||||
|
||||
When this rule is `'indented'`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
````markdown
|
||||
```
|
||||
alpha();
|
||||
```
|
||||
|
||||
Paragraph.
|
||||
|
||||
```
|
||||
bravo();
|
||||
```
|
||||
````
|
||||
|
||||
```text
|
||||
1:1-3:4: Code blocks should be indented
|
||||
7:1-9:4: Code blocks should be indented
|
||||
```
|
||||
|
||||
When this rule is `'fenced'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
````markdown
|
||||
<!-- This is also valid when `'consistent'` -->
|
||||
|
||||
```
|
||||
alpha();
|
||||
```
|
||||
|
||||
Paragraph.
|
||||
|
||||
```
|
||||
bravo();
|
||||
```
|
||||
````
|
||||
|
||||
When this rule is `'fenced'`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
alpha();
|
||||
|
||||
Paragraph.
|
||||
|
||||
bravo();
|
||||
```
|
||||
|
||||
```text
|
||||
1:1-1:13: Code blocks should be fenced
|
||||
5:1-5:13: Code blocks should be fenced
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
````markdown
|
||||
<!-- This is always invalid -->
|
||||
|
||||
alpha();
|
||||
|
||||
Paragraph.
|
||||
|
||||
```
|
||||
bravo();
|
||||
```
|
||||
````
|
||||
|
||||
```text
|
||||
7:1-9:4: Code blocks should be indented
|
||||
```
|
||||
|
||||
When `'invalid'` is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Invalid code block style `invalid`: use either `'consistent'`, `'fenced'`, or `'indented'`
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -21,38 +21,25 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = definitionCase;
|
||||
module.exports = rule('remark-lint:definition-case', definitionCase);
|
||||
|
||||
/* Expressions. */
|
||||
var LABEL = /^\s*\[((?:\\[\s\S]|[^[\]])+)]/;
|
||||
|
||||
/**
|
||||
* Warn when definitions are not placed at the end of the
|
||||
* file.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function definitionCase(ast, file) {
|
||||
function definitionCase(tree, file) {
|
||||
var contents = file.toString();
|
||||
|
||||
visit(ast, 'definition', validate);
|
||||
visit(ast, 'footnoteDefinition', validate);
|
||||
visit(tree, 'definition', validate);
|
||||
visit(tree, 'footnoteDefinition', validate);
|
||||
|
||||
return;
|
||||
|
||||
/**
|
||||
* Validate a node, either a normal definition or
|
||||
* a footnote definition.
|
||||
*
|
||||
* @param {Node} node - Node.
|
||||
*/
|
||||
/* Validate a node, either a normal definition or
|
||||
* a footnote definition. */
|
||||
function validate(node) {
|
||||
var start = position.start(node).offset;
|
||||
var end = position.end(node).offset;
|
29
packages/remark-lint-definition-case/package.json
Normal file
29
packages/remark-lint-definition-case/package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "remark-lint-definition-case",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when definition labels are not lower-case",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"definition",
|
||||
"case"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-definition-case",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
35
packages/remark-lint-definition-case/readme.md
Normal file
35
packages/remark-lint-definition-case/readme.md
Normal file
@ -0,0 +1,35 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-definition-case
|
||||
|
||||
Warn when definition labels are not lower-case.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-definition-case
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
[example]: http://example.com "Example Domain"
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
[Example]: http://example.com "Example Domain"
|
||||
```
|
||||
|
||||
```text
|
||||
1:1-1:47: Do not use upper-case characters in definition labels
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -21,38 +21,23 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = definitionSpacing;
|
||||
module.exports = rule('remark-lint:definition-spacing', definitionSpacing);
|
||||
|
||||
/* Expressions. */
|
||||
var LABEL = /^\s*\[((?:\\[\s\S]|[^[\]])+)]/;
|
||||
|
||||
/**
|
||||
* Warn when consecutive white space is used in a
|
||||
* definition.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function definitionSpacing(ast, file) {
|
||||
function definitionSpacing(tree, file) {
|
||||
var contents = file.toString();
|
||||
|
||||
visit(ast, 'definition', validate);
|
||||
visit(ast, 'footnoteDefinition', validate);
|
||||
visit(tree, 'definition', validate);
|
||||
visit(tree, 'footnoteDefinition', validate);
|
||||
|
||||
return;
|
||||
|
||||
/**
|
||||
* Validate a node, either a normal definition or
|
||||
* a footnote definition.
|
||||
*
|
||||
* @param {Node} node - Node.
|
||||
*/
|
||||
function validate(node) {
|
||||
var start = position.start(node).offset;
|
||||
var end = position.end(node).offset;
|
29
packages/remark-lint-definition-spacing/package.json
Normal file
29
packages/remark-lint-definition-spacing/package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "remark-lint-definition-spacing",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when consecutive white space is used in a definition",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"definition",
|
||||
"spacing"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-definition-spacing",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
35
packages/remark-lint-definition-spacing/readme.md
Normal file
35
packages/remark-lint-definition-spacing/readme.md
Normal file
@ -0,0 +1,35 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-definition-spacing
|
||||
|
||||
Warn when consecutive white space is used in a definition.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-definition-spacing
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
[example domain]: http://example.com "Example Domain"
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
[example domain]: http://example.com "Example Domain"
|
||||
```
|
||||
|
||||
```text
|
||||
1:1-1:57: Do not use consecutive white-space in definition labels
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -55,39 +55,29 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* eslint-env commonjs */
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = emphasisMarker;
|
||||
module.exports = rule('remark-lint:emphasis-marker', emphasisMarker);
|
||||
|
||||
/* Map of valid markers. */
|
||||
var MARKERS = {
|
||||
'*': true,
|
||||
_: true,
|
||||
null: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Warn when an `emphasis` node has an incorrect marker.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {string?} [preferred='consistent'] - Preferred
|
||||
* marker, either `'*'` or `'_'`, or `'consistent'`.
|
||||
*/
|
||||
function emphasisMarker(ast, file, preferred) {
|
||||
function emphasisMarker(tree, file, preferred) {
|
||||
preferred = typeof preferred !== 'string' || preferred === 'consistent' ? null : preferred;
|
||||
|
||||
if (MARKERS[preferred] !== true) {
|
||||
file.fail('Invalid emphasis marker `' + preferred + '`: use either `\'consistent\'`, `\'*\'`, or `\'_\'`');
|
||||
}
|
||||
|
||||
visit(ast, 'emphasis', function (node) {
|
||||
visit(tree, 'emphasis', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var marker = file.toString().charAt(position.start(node).offset);
|
||||
|
||||
if (generated(node)) {
|
||||
@ -101,5 +91,5 @@ function emphasisMarker(ast, file, preferred) {
|
||||
} else {
|
||||
preferred = marker;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
29
packages/remark-lint-emphasis-marker/package.json
Normal file
29
packages/remark-lint-emphasis-marker/package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "remark-lint-emphasis-marker",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when emphasis markers violate the given style",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"emphasis",
|
||||
"marker"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-emphasis-marker",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
80
packages/remark-lint-emphasis-marker/readme.md
Normal file
80
packages/remark-lint-emphasis-marker/readme.md
Normal file
@ -0,0 +1,80 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-emphasis-marker
|
||||
|
||||
Warn for violating emphasis markers.
|
||||
|
||||
Options: `string`, either `'consistent'`, `'*'`, or `'_'`,
|
||||
default: `'consistent'`.
|
||||
|
||||
The default value, `consistent`, detects the first used emphasis
|
||||
style, and will warn when a subsequent emphasis uses a different
|
||||
style.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-emphasis-marker
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is `'*'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
*foo*
|
||||
```
|
||||
|
||||
When this rule is `'*'`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
_foo_
|
||||
```
|
||||
|
||||
```text
|
||||
1:1-1:6: Emphasis should use `*` as a marker
|
||||
```
|
||||
|
||||
When this rule is `'_'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
_foo_
|
||||
```
|
||||
|
||||
When this rule is `'_'`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
*foo*
|
||||
```
|
||||
|
||||
```text
|
||||
1:1-1:6: Emphasis should use `_` as a marker
|
||||
```
|
||||
|
||||
When this rule is `'consistent'`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
<!-- This is never valid -->
|
||||
|
||||
*foo*
|
||||
_bar_
|
||||
```
|
||||
|
||||
```text
|
||||
4:1-4:6: Emphasis should use `*` as a marker
|
||||
```
|
||||
|
||||
When `'invalid'` is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Invalid emphasis marker `invalid`: use either `'consistent'`, `'*'`, or `'_'`
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -67,26 +67,16 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = fencedCodeFlag;
|
||||
module.exports = rule('remark-lint:fenced-code-flag', fencedCodeFlag);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
var end = position.end;
|
||||
|
||||
/**
|
||||
* Warn for fenced code blocks without language flag.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {Object|Array.<string>} [preferred] - List
|
||||
* of flags deemed valid.
|
||||
*/
|
||||
function fencedCodeFlag(ast, file, preferred) {
|
||||
var contents = file.toString();
|
||||
var allowEmpty = false;
|
||||
@ -102,7 +92,9 @@ function fencedCodeFlag(ast, file, preferred) {
|
||||
flags = String(preferred).split(',');
|
||||
}
|
||||
|
||||
visit(ast, 'code', function (node) {
|
||||
visit(ast, 'code', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var value = contents.slice(start(node).offset, end(node).offset);
|
||||
|
||||
if (generated(node)) {
|
||||
@ -116,5 +108,5 @@ function fencedCodeFlag(ast, file, preferred) {
|
||||
} else if (/^ {0,3}([~`])\1{2,}/.test(value) && !allowEmpty) {
|
||||
file.message('Missing code-language flag', node);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
31
packages/remark-lint-fenced-code-flag/package.json
Normal file
31
packages/remark-lint-fenced-code-flag/package.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "remark-lint-fenced-code-flag",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when fenced code blocks occur without language flag",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"fenced",
|
||||
"code",
|
||||
"flag",
|
||||
"infostring"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-fenced-code-flag",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
93
packages/remark-lint-fenced-code-flag/readme.md
Normal file
93
packages/remark-lint-fenced-code-flag/readme.md
Normal file
@ -0,0 +1,93 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-fenced-code-flag
|
||||
|
||||
Warn when fenced code blocks occur without language flag.
|
||||
|
||||
Options: `Array.<string>` or `Object`.
|
||||
|
||||
Providing an array, is a shortcut for just providing the `flags`
|
||||
property on the object.
|
||||
|
||||
The object can have an array of flags which are deemed valid.
|
||||
In addition it can have the property `allowEmpty` (`boolean`)
|
||||
which signifies whether or not to warn for fenced code-blocks without
|
||||
languge flags.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-fenced-code-flag
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
````markdown
|
||||
```alpha
|
||||
bravo();
|
||||
```
|
||||
````
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
````markdown
|
||||
```
|
||||
alpha();
|
||||
```
|
||||
````
|
||||
|
||||
```text
|
||||
1:1-3:4: Missing code-language flag
|
||||
```
|
||||
|
||||
When this rule is `{ allowEmpty: true }`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
````markdown
|
||||
```
|
||||
alpha();
|
||||
```
|
||||
````
|
||||
|
||||
When this rule is `{ allowEmpty: false }`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
````markdown
|
||||
```
|
||||
alpha();
|
||||
```
|
||||
````
|
||||
|
||||
```text
|
||||
1:1-3:4: Missing code-language flag
|
||||
```
|
||||
|
||||
When this rule is `[ 'alpha' ]`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
````markdown
|
||||
```alpha
|
||||
bravo();
|
||||
```
|
||||
````
|
||||
|
||||
When this rule is `[ 'charlie' ]`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
````markdown
|
||||
```alpha
|
||||
bravo();
|
||||
```
|
||||
````
|
||||
|
||||
```text
|
||||
1:1-3:4: Invalid code-language flag
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -12,6 +12,12 @@
|
||||
* marker style, and will warn when a subsequent fenced code uses a
|
||||
* different style.
|
||||
*
|
||||
* @example {"name": "valid.md"}
|
||||
*
|
||||
* Indented code blocks are not affected by this rule:
|
||||
*
|
||||
* bravo();
|
||||
*
|
||||
* @example {"name": "valid.md", "setting": "`"}
|
||||
*
|
||||
* <!-- This is also valid by default. -->
|
||||
@ -59,29 +65,19 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = fencedCodeMarker;
|
||||
module.exports = rule('remark-lint:fenced-code-marker', fencedCodeMarker);
|
||||
|
||||
/* Map of valid markers. */
|
||||
var MARKERS = {
|
||||
'`': true,
|
||||
'~': true,
|
||||
null: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Warn for violating fenced code markers.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {string?} [preferred='consistent'] - Preferred
|
||||
* marker, either `` '`' `` or `~`, or `'consistent'`.
|
||||
*/
|
||||
function fencedCodeMarker(ast, file, preferred) {
|
||||
var contents = file.toString();
|
||||
|
||||
@ -91,7 +87,9 @@ function fencedCodeMarker(ast, file, preferred) {
|
||||
file.fail('Invalid fenced code marker `' + preferred + '`: use either `\'consistent\'`, `` \'`\' ``, or `\'~\'`');
|
||||
}
|
||||
|
||||
visit(ast, 'code', function (node) {
|
||||
visit(ast, 'code', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var marker = contents.substr(position.start(node).offset, 4);
|
||||
|
||||
if (generated(node)) {
|
||||
@ -112,5 +110,5 @@ function fencedCodeMarker(ast, file, preferred) {
|
||||
} else {
|
||||
preferred = marker;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
30
packages/remark-lint-fenced-code-marker/package.json
Normal file
30
packages/remark-lint-fenced-code-marker/package.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "remark-lint-fenced-code-marker",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when fenced code markers violate the given style",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"fenced",
|
||||
"code",
|
||||
"marker"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-fenced-code-marker",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
87
packages/remark-lint-fenced-code-marker/readme.md
Normal file
87
packages/remark-lint-fenced-code-marker/readme.md
Normal file
@ -0,0 +1,87 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-fenced-code-marker
|
||||
|
||||
Warn for violating fenced code markers.
|
||||
|
||||
Options: `string`, either ``'`'``, or `'~'`, default: `'consistent'`.
|
||||
|
||||
The default value, `consistent`, detects the first used fenced code
|
||||
marker style, and will warn when a subsequent fenced code uses a
|
||||
different style.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-fenced-code-marker
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
Indented code blocks are not affected by this rule:
|
||||
|
||||
bravo();
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
````markdown
|
||||
<!-- This is always invalid. -->
|
||||
|
||||
```alpha
|
||||
bravo();
|
||||
```
|
||||
|
||||
~~~
|
||||
charlie();
|
||||
~~~
|
||||
````
|
||||
|
||||
```text
|
||||
7:1-9:4: Fenced code should use ` as a marker
|
||||
```
|
||||
|
||||
When this rule is ``'`'``, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
````markdown
|
||||
<!-- This is also valid by default. -->
|
||||
|
||||
```alpha
|
||||
bravo();
|
||||
```
|
||||
|
||||
```
|
||||
charlie();
|
||||
```
|
||||
````
|
||||
|
||||
When this rule is `'~'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!-- This is also valid by default. -->
|
||||
|
||||
~~~alpha
|
||||
bravo();
|
||||
~~~
|
||||
|
||||
~~~
|
||||
charlie();
|
||||
~~~
|
||||
```
|
||||
|
||||
When `'!'` is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Invalid fenced code marker `!`: use either `'consistent'`, `` '`' ``, or `'~'`
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -25,17 +25,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Expose. */
|
||||
module.exports = fileExtension;
|
||||
var rule = require('unified-lint-rule');
|
||||
|
||||
module.exports = rule('remark-lint:file-extension', fileExtension);
|
||||
|
||||
/**
|
||||
* Check file extensions.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {string?} [preferred='md'] - Expected file
|
||||
* extension.
|
||||
*/
|
||||
function fileExtension(ast, file, preferred) {
|
||||
var ext = file.extname;
|
||||
|
||||
@ -46,7 +39,6 @@ function fileExtension(ast, file, preferred) {
|
||||
preferred = typeof preferred === 'string' ? preferred : 'md';
|
||||
|
||||
if (ext && ext !== preferred) {
|
||||
console.log('e: ', [ext, preferred, file.extname], file);
|
||||
file.message('Invalid extension: use `' + preferred + '`');
|
||||
}
|
||||
}
|
27
packages/remark-lint-file-extension/package.json
Normal file
27
packages/remark-lint-file-extension/package.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "remark-lint-file-extension",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when the file’s extension violates the given style",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"file",
|
||||
"extension",
|
||||
"extname"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-file-extension",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0"
|
||||
},
|
||||
"xo": false
|
||||
}
|
50
packages/remark-lint-file-extension/readme.md
Normal file
50
packages/remark-lint-file-extension/readme.md
Normal file
@ -0,0 +1,50 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-file-extension
|
||||
|
||||
Warn when the document’s extension differs from the given preferred
|
||||
extension.
|
||||
|
||||
Does not warn when given documents have no file extensions (such as
|
||||
`AUTHORS` or `LICENSE`).
|
||||
|
||||
Options: `string`, default: `'md'` — Expected file extension.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-file-extension
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`readme.md` is ok:
|
||||
|
||||
```markdown
|
||||
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`readme` is ok:
|
||||
|
||||
```markdown
|
||||
|
||||
```
|
||||
|
||||
When turned on is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Invalid extension: use `md`
|
||||
```
|
||||
|
||||
When this rule is `'mkd'`, the following file
|
||||
`readme.mkd` is ok:
|
||||
|
||||
```markdown
|
||||
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -27,28 +27,21 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = finalDefinition;
|
||||
module.exports = rule('remark-lint:final-definition', finalDefinition);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
|
||||
/**
|
||||
* Warn when definitions are not placed at the end of
|
||||
* the file.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function finalDefinition(ast, file) {
|
||||
var last = null;
|
||||
|
||||
visit(ast, function (node) {
|
||||
visit(ast, visitor, true);
|
||||
|
||||
function visitor(node) {
|
||||
var line = start(node).line;
|
||||
|
||||
/* Ignore generated nodes. */
|
||||
@ -63,5 +56,5 @@ function finalDefinition(ast, file) {
|
||||
} else if (last === null) {
|
||||
last = line;
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
30
packages/remark-lint-final-definition/package.json
Normal file
30
packages/remark-lint-final-definition/package.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "remark-lint-final-definition",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when definitions are not placed at the end of the file",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"definition",
|
||||
"position",
|
||||
"final"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-final-definition",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
41
packages/remark-lint-final-definition/readme.md
Normal file
41
packages/remark-lint-final-definition/readme.md
Normal file
@ -0,0 +1,41 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-final-definition
|
||||
|
||||
Warn when definitions are not placed at the end of the file.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-final-definition
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
Paragraph.
|
||||
|
||||
[example]: http://example.com "Example Domain"
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
Paragraph.
|
||||
|
||||
[example]: http://example.com "Example Domain"
|
||||
|
||||
Another paragraph.
|
||||
```
|
||||
|
||||
```text
|
||||
3:1-3:47: Move definitions to the end of the file (after the node at line `5`)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -6,22 +6,18 @@
|
||||
* @fileoverview
|
||||
* Warn when a newline at the end of a file is missing.
|
||||
*
|
||||
* This rule allows empty files.
|
||||
*
|
||||
* See [StackExchange](http://unix.stackexchange.com/questions/18743) for
|
||||
* why.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Expose. */
|
||||
module.exports = finalNewline;
|
||||
var rule = require('unified-lint-rule');
|
||||
|
||||
module.exports = rule('remark-lint:final-newline', finalNewline);
|
||||
|
||||
/**
|
||||
* Warn when the list-item marker style of unordered lists
|
||||
* violate a given style.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function finalNewline(ast, file) {
|
||||
var contents = file.toString();
|
||||
var last = contents.length - 1;
|
27
packages/remark-lint-final-newline/package.json
Normal file
27
packages/remark-lint-final-newline/package.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "remark-lint-final-newline",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when a newline at the end of a file is missing",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"final",
|
||||
"newline",
|
||||
"unix"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-final-newline",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0"
|
||||
},
|
||||
"xo": false
|
||||
}
|
22
packages/remark-lint-final-newline/readme.md
Normal file
22
packages/remark-lint-final-newline/readme.md
Normal file
@ -0,0 +1,22 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-final-newline
|
||||
|
||||
Warn when a newline at the end of a file is missing.
|
||||
|
||||
This rule allows empty files.
|
||||
|
||||
See [StackExchange](http://unix.stackexchange.com/questions/18743) for
|
||||
why.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-final-newline
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -8,15 +8,11 @@
|
||||
*
|
||||
* Options: `number`, default: `1`.
|
||||
*
|
||||
* @example {"name": "valid.md", "setting": 1}
|
||||
* @example {"name": "valid.md"}
|
||||
*
|
||||
* <!-- Also valid by default. -->
|
||||
* # The default is to expect a level one heading
|
||||
*
|
||||
* # Alpha
|
||||
*
|
||||
* Paragraph.
|
||||
*
|
||||
* @example {"name": "invalid.md", "setting": 1, "label": "input"}
|
||||
* @example {"name": "invalid.md", "label": "input"}
|
||||
*
|
||||
* <!-- Also invalid by default. -->
|
||||
*
|
||||
@ -24,7 +20,7 @@
|
||||
*
|
||||
* Paragraph.
|
||||
*
|
||||
* @example {"name": "invalid.md", "setting": 1, "label": "output"}
|
||||
* @example {"name": "invalid.md", "label": "output"}
|
||||
*
|
||||
* 3:1-3:9: First heading level should be `1`
|
||||
*
|
||||
@ -47,24 +43,18 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = firstHeadingLevel;
|
||||
module.exports = rule('remark-lint:first-heading-level', firstHeadingLevel);
|
||||
|
||||
/**
|
||||
* Warn when the first heading has a level other than a specified value.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {number?} [preferred=1] - First heading level.
|
||||
*/
|
||||
function firstHeadingLevel(ast, file, preferred) {
|
||||
var style = preferred && preferred !== true ? preferred : 1;
|
||||
|
||||
visit(ast, 'heading', function (node) {
|
||||
visit(ast, 'heading', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
if (generated(node)) {
|
||||
return;
|
||||
}
|
||||
@ -74,5 +64,5 @@ function firstHeadingLevel(ast, file, preferred) {
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
30
packages/remark-lint-first-heading-level/package.json
Normal file
30
packages/remark-lint-first-heading-level/package.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "remark-lint-first-heading-level",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when the first heading has a level other than a specified value",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"first",
|
||||
"heading",
|
||||
"level",
|
||||
"depth"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-first-heading-level",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
63
packages/remark-lint-first-heading-level/readme.md
Normal file
63
packages/remark-lint-first-heading-level/readme.md
Normal file
@ -0,0 +1,63 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-first-heading-level
|
||||
|
||||
Warn when the first heading has a level other than a specified value.
|
||||
|
||||
Options: `number`, default: `1`.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-first-heading-level
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is `2`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
## Bravo
|
||||
|
||||
Paragraph.
|
||||
```
|
||||
|
||||
When this rule is `2`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
# Bravo
|
||||
|
||||
Paragraph.
|
||||
```
|
||||
|
||||
```text
|
||||
1:1-1:8: First heading level should be `2`
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
# The default is to expect a level one heading
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
<!-- Also invalid by default. -->
|
||||
|
||||
## Bravo
|
||||
|
||||
Paragraph.
|
||||
```
|
||||
|
||||
```text
|
||||
3:1-3:9: First heading level should be `1`
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -27,27 +27,19 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* eslint-env commonjs */
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = hardBreakSpaces;
|
||||
module.exports = rule('remark-lint:hard-break-spaces', hardBreakSpaces);
|
||||
|
||||
/**
|
||||
* Warn when too many spaces are used to create a
|
||||
* hard break.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function hardBreakSpaces(ast, file) {
|
||||
var contents = file.toString();
|
||||
|
||||
visit(ast, 'break', function (node) {
|
||||
visit(ast, 'break', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var start = position.start(node).offset;
|
||||
var end = position.end(node).offset;
|
||||
var value;
|
||||
@ -61,5 +53,5 @@ function hardBreakSpaces(ast, file) {
|
||||
if (value.length > 2) {
|
||||
file.message('Use two spaces for hard line breaks', node);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
31
packages/remark-lint-hard-break-spaces/package.json
Normal file
31
packages/remark-lint-hard-break-spaces/package.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "remark-lint-hard-break-spaces",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when blockquotes are either indented too much or too little",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"hard",
|
||||
"break",
|
||||
"spaces",
|
||||
"size"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-hard-break-spaces",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
41
packages/remark-lint-hard-break-spaces/readme.md
Normal file
41
packages/remark-lint-hard-break-spaces/readme.md
Normal file
@ -0,0 +1,41 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-hard-break-spaces
|
||||
|
||||
Warn when too many spaces are used to create a hard break.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-hard-break-spaces
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--Note: `·` represents ` `-->
|
||||
|
||||
Lorem ipsum··
|
||||
dolor sit amet
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
<!--Note: `·` represents ` `-->
|
||||
|
||||
Lorem ipsum···
|
||||
dolor sit amet.
|
||||
```
|
||||
|
||||
```text
|
||||
3:12-4:1: Use two spaces for hard line breaks
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -25,26 +25,18 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = headingIncrement;
|
||||
module.exports = rule('remark-lint:heading-increment', headingIncrement);
|
||||
|
||||
/**
|
||||
* Warn when headings increment with more than 1 level at
|
||||
* a time.
|
||||
*
|
||||
* Never warns for the first heading.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function headingIncrement(ast, file) {
|
||||
var prev = null;
|
||||
|
||||
visit(ast, 'heading', function (node) {
|
||||
visit(ast, 'heading', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var depth = node.depth;
|
||||
|
||||
if (generated(node)) {
|
||||
@ -56,5 +48,5 @@ function headingIncrement(ast, file) {
|
||||
}
|
||||
|
||||
prev = depth;
|
||||
});
|
||||
}
|
||||
}
|
29
packages/remark-lint-heading-increment/package.json
Normal file
29
packages/remark-lint-heading-increment/package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "remark-lint-heading-increment",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when headings increment with more than 1 level at a time",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"heading",
|
||||
"increment",
|
||||
"increase"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-heading-increment",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
39
packages/remark-lint-heading-increment/readme.md
Normal file
39
packages/remark-lint-heading-increment/readme.md
Normal file
@ -0,0 +1,39 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-heading-increment
|
||||
|
||||
Warn when headings increment with more than 1 level at a time.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-heading-increment
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
# Alpha
|
||||
|
||||
## Bravo
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
# Charlie
|
||||
|
||||
### Delta
|
||||
```
|
||||
|
||||
```text
|
||||
3:1-3:10: Heading levels should increment by one level at a time
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -64,34 +64,21 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* eslint-env commonjs */
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var style = require('mdast-util-heading-style');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = headingStyle;
|
||||
module.exports = rule('remark-lint:heading-style', headingStyle);
|
||||
|
||||
/* Types. */
|
||||
var TYPES = ['atx', 'atx-closed', 'setext'];
|
||||
|
||||
/**
|
||||
* Warn when a heading does not conform to a given style.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {string} [preferred='consistent'] - Preferred
|
||||
* style, one of `atx`, `atx-closed`, or `setext`.
|
||||
* Other values default to `'consistent'`, which will
|
||||
* detect the first used style.
|
||||
* @param {Function} done - Callback.
|
||||
*/
|
||||
function headingStyle(ast, file, preferred) {
|
||||
preferred = TYPES.indexOf(preferred) === -1 ? null : preferred;
|
||||
|
||||
visit(ast, 'heading', function (node) {
|
||||
visit(ast, 'heading', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
if (generated(node)) {
|
||||
return;
|
||||
}
|
||||
@ -103,5 +90,5 @@ function headingStyle(ast, file, preferred) {
|
||||
} else {
|
||||
preferred = style(node, preferred);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
31
packages/remark-lint-heading-style/package.json
Normal file
31
packages/remark-lint-heading-style/package.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "remark-lint-heading-style",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when heading style violates the given style",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"heading",
|
||||
"style",
|
||||
"atx",
|
||||
"setext"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-heading-style",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"mdast-util-heading-style": "^1.0.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
84
packages/remark-lint-heading-style/readme.md
Normal file
84
packages/remark-lint-heading-style/readme.md
Normal file
@ -0,0 +1,84 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-heading-style
|
||||
|
||||
Warn when a heading does not conform to a given style.
|
||||
|
||||
Options: `string`, either `'consistent'`, `'atx'`, `'atx-closed'`,
|
||||
or `'setext'`, default: `'consistent'`.
|
||||
|
||||
The default value, `consistent`, detects the first used heading
|
||||
style, and will warn when a subsequent heading uses a different
|
||||
style.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-heading-style
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is `'atx'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--Also valid when `consistent`-->
|
||||
|
||||
# Alpha
|
||||
|
||||
## Bravo
|
||||
|
||||
### Charlie
|
||||
```
|
||||
|
||||
When this rule is `'atx-closed'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--Also valid when `consistent`-->
|
||||
|
||||
# Delta ##
|
||||
|
||||
## Echo ##
|
||||
|
||||
### Foxtrot ###
|
||||
```
|
||||
|
||||
When this rule is `'setext'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--Also valid when `consistent`-->
|
||||
|
||||
Golf
|
||||
====
|
||||
|
||||
Hotel
|
||||
-----
|
||||
|
||||
### India
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
<!--Always invalid.-->
|
||||
|
||||
Juliett
|
||||
=======
|
||||
|
||||
## Kilo
|
||||
|
||||
### Lima ###
|
||||
```
|
||||
|
||||
```text
|
||||
6:1-6:8: Headings should use setext
|
||||
8:1-8:13: Headings should use setext
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -24,8 +24,8 @@
|
||||
*
|
||||
* <!--Also valid when `consistent`-->
|
||||
*
|
||||
* [Example](http://example.com 'Example Domain')
|
||||
* [Example](http://example.com 'Example Domain')
|
||||
* ![Example](http://example.com/image.png 'Example Domain')
|
||||
* ![Example](http://example.com/image.png 'Example Domain')
|
||||
*
|
||||
* @example {"name": "valid.md", "setting": "()"}
|
||||
*
|
||||
@ -34,6 +34,14 @@
|
||||
* [Example](http://example.com (Example Domain) )
|
||||
* [Example](http://example.com (Example Domain) )
|
||||
*
|
||||
* @example {"name": "invalid.md", "label": "input", "setting": "\""}
|
||||
*
|
||||
* [Example]: http://example.com 'Example Domain'
|
||||
*
|
||||
* @example {"name": "invalid.md", "label": "output", "setting": "\""}
|
||||
*
|
||||
* 1:47: Titles should use `"` as a quote
|
||||
*
|
||||
* @example {"name": "invalid.md", "label": "input"}
|
||||
*
|
||||
* <!--Always invalid-->
|
||||
@ -64,19 +72,16 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var vfileLocation = require('vfile-location');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = linkTitleStyle;
|
||||
module.exports = rule('remark-lint:link-title-style', linkTitleStyle);
|
||||
|
||||
/* Methods. */
|
||||
var end = position.end;
|
||||
|
||||
/* Map of valid markers. */
|
||||
var MARKERS = {
|
||||
'"': true,
|
||||
'\'': true,
|
||||
@ -84,14 +89,6 @@ var MARKERS = {
|
||||
null: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Warn for fenced code blocks without language flag.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {string?} [preferred='consistent'] - Preferred
|
||||
* marker, either `'"'`, `'\''`, `'()'`, or `'consistent'`.
|
||||
*/
|
||||
function linkTitleStyle(ast, file, preferred) {
|
||||
var contents = file.toString();
|
||||
var location = vfileLocation(file);
|
||||
@ -112,11 +109,6 @@ function linkTitleStyle(ast, file, preferred) {
|
||||
|
||||
return;
|
||||
|
||||
/**
|
||||
* Validate a single node.
|
||||
*
|
||||
* @param {Node} node - Node.
|
||||
*/
|
||||
function validate(node) {
|
||||
var last = end(node).offset - 1;
|
||||
var character;
|
32
packages/remark-lint-link-title-style/package.json
Normal file
32
packages/remark-lint-link-title-style/package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "remark-lint-link-title-style",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when link and definition titles occur with incorrect quotes",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"link",
|
||||
"image",
|
||||
"definition",
|
||||
"style"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-link-title-style",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1",
|
||||
"vfile-location": "^2.0.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
100
packages/remark-lint-link-title-style/readme.md
Normal file
100
packages/remark-lint-link-title-style/readme.md
Normal file
@ -0,0 +1,100 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-link-title-style
|
||||
|
||||
Warn when link and definition titles occur with incorrect quotes.
|
||||
|
||||
Options: `string`, either `'consistent'`, `'"'`, `'\''`, or
|
||||
`'()'`, default: `'consistent'`.
|
||||
|
||||
The default value, `consistent`, detects the first used quote
|
||||
style, and will warn when a subsequent titles use a different
|
||||
style.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-link-title-style
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is `'"'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--Also valid when `consistent`-->
|
||||
|
||||
[Example](http://example.com "Example Domain")
|
||||
[Example](http://example.com "Example Domain")
|
||||
```
|
||||
|
||||
When this rule is `'"'`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
[Example]: http://example.com 'Example Domain'
|
||||
```
|
||||
|
||||
```text
|
||||
1:47: Titles should use `"` as a quote
|
||||
```
|
||||
|
||||
When this rule is `'\''`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--Also valid when `consistent`-->
|
||||
|
||||
![Example](http://example.com/image.png 'Example Domain')
|
||||
![Example](http://example.com/image.png 'Example Domain')
|
||||
```
|
||||
|
||||
When this rule is `'()'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<!--Also valid when `consistent`-->
|
||||
|
||||
[Example](http://example.com (Example Domain) )
|
||||
[Example](http://example.com (Example Domain) )
|
||||
```
|
||||
|
||||
When this rule is `'()'`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
<!--Always invalid-->
|
||||
|
||||
[Example](http://example.com (Example Domain))
|
||||
[Example](http://example.com 'Example Domain')
|
||||
```
|
||||
|
||||
```text
|
||||
4:46: Titles should use `()` as a quote
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
<!--Always invalid-->
|
||||
|
||||
[Example](http://example.com "Example Domain")
|
||||
[Example](http://example.com#without-title)
|
||||
[Example](http://example.com 'Example Domain')
|
||||
```
|
||||
|
||||
```text
|
||||
5:46: Titles should use `"` as a quote
|
||||
```
|
||||
|
||||
When `'.'` is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Invalid link title style marker `.`: use either `'consistent'`, `'"'`, `'\''`, or `'()'`
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -28,50 +28,46 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
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 plural = require('plur');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = listItemBulletIndent;
|
||||
module.exports = rule('remark-lint:list-item-bullet-indent', listItemBulletIndent);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
|
||||
/**
|
||||
* Warn when list item bullets are indented.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function listItemBulletIndent(ast, file) {
|
||||
var contents = file.toString();
|
||||
|
||||
visit(ast, 'list', function (node) {
|
||||
visit(ast, 'list', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var items = node.children;
|
||||
|
||||
items.forEach(function (item) {
|
||||
var head = item.children[0];
|
||||
var initial = start(item).offset;
|
||||
var final = start(head).offset;
|
||||
var indent;
|
||||
items.forEach(visitItems);
|
||||
}
|
||||
|
||||
if (generated(node)) {
|
||||
return;
|
||||
}
|
||||
function visitItems(item) {
|
||||
var head = item.children[0];
|
||||
var initial = start(item).offset;
|
||||
var final = start(head).offset;
|
||||
var indent;
|
||||
|
||||
indent = contents.slice(initial, final).match(/^\s*/)[0].length;
|
||||
if (generated(item)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (indent !== 0) {
|
||||
initial = start(head);
|
||||
indent = contents.slice(initial, final).match(/^\s*/)[0].length;
|
||||
|
||||
file.message('Incorrect indentation before bullet: remove ' + indent + ' ' + plural('space', indent), {
|
||||
line: initial.line,
|
||||
column: initial.column - indent
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
if (indent !== 0) {
|
||||
initial = start(head);
|
||||
|
||||
file.message('Incorrect indentation before bullet: remove ' + indent + ' ' + plural('space', indent), {
|
||||
line: initial.line,
|
||||
column: initial.column - indent
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
31
packages/remark-lint-list-item-bullet-indent/package.json
Normal file
31
packages/remark-lint-list-item-bullet-indent/package.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "remark-lint-list-item-bullet-indent",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when list item bullets are indented",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"list",
|
||||
"item",
|
||||
"indent"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-list-item-bullet-indent",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"plur": "^2.1.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
42
packages/remark-lint-list-item-bullet-indent/readme.md
Normal file
42
packages/remark-lint-list-item-bullet-indent/readme.md
Normal file
@ -0,0 +1,42 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-list-item-bullet-indent
|
||||
|
||||
Warn when list item bullets are indented.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-list-item-bullet-indent
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
Paragraph.
|
||||
|
||||
* List item
|
||||
* List item
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
Paragraph.
|
||||
|
||||
* List item
|
||||
* List item
|
||||
```
|
||||
|
||||
```text
|
||||
3:3: Incorrect indentation before bullet: remove 1 space
|
||||
4:3: Incorrect indentation before bullet: remove 1 space
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -23,32 +23,27 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
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 plural = require('plur');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = listItemContentIndent;
|
||||
module.exports = rule('remark-lint:list-item-content-indent', listItemContentIndent);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
|
||||
/**
|
||||
* Warn when the content of a list item has mixed
|
||||
* indentation.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function listItemContentIndent(ast, file) {
|
||||
var contents = file.toString();
|
||||
|
||||
visit(ast, 'listItem', function (node) {
|
||||
visit(ast, 'listItem', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var style;
|
||||
|
||||
node.children.forEach(function (item, index) {
|
||||
node.children.forEach(visitItem);
|
||||
|
||||
function visitItem(item, index) {
|
||||
var begin = start(item);
|
||||
var column = begin.column;
|
||||
var char;
|
||||
@ -84,6 +79,7 @@ function listItemContentIndent(ast, file) {
|
||||
/* Warn for violating children. */
|
||||
if (column !== style) {
|
||||
diff = style - column;
|
||||
/* istanbul ignore next - hard to test, I couldn’t find it at least. */
|
||||
word = diff > 0 ? 'add' : 'remove';
|
||||
|
||||
diff = Math.abs(diff);
|
||||
@ -97,6 +93,6 @@ function listItemContentIndent(ast, file) {
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
32
packages/remark-lint-list-item-content-indent/package.json
Normal file
32
packages/remark-lint-list-item-content-indent/package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "remark-lint-list-item-content-indent",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when the content of a list item has mixed indentation",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"list",
|
||||
"item",
|
||||
"content",
|
||||
"indent"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-list-item-content-indent",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"plur": "^2.1.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
37
packages/remark-lint-list-item-content-indent/readme.md
Normal file
37
packages/remark-lint-list-item-content-indent/readme.md
Normal file
@ -0,0 +1,37 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-list-item-content-indent
|
||||
|
||||
Warn when the content of a list item has mixed indentation.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-list-item-content-indent
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
1. [x] Alpha
|
||||
1. Bravo
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
1. [x] Charlie
|
||||
1. Delta
|
||||
```
|
||||
|
||||
```text
|
||||
2:5: Don’t use mixed indentation for children, remove 1 space
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -10,7 +10,9 @@
|
||||
* Options: `string`, either `'tab-size'`, `'mixed'`, or `'space'`,
|
||||
* default: `'tab-size'`.
|
||||
*
|
||||
* @example {"name": "valid.md", "setting": "tab-size"}
|
||||
* @example {"name": "valid.md"}
|
||||
*
|
||||
* The below style is called `tab-size`.
|
||||
*
|
||||
* * List
|
||||
* item.
|
||||
@ -60,6 +62,32 @@
|
||||
* * List
|
||||
* item.
|
||||
*
|
||||
* @example {"name": "invalid.md", "setting": "space", "label": "input"}
|
||||
*
|
||||
* * List
|
||||
* item.
|
||||
*
|
||||
* @example {"name": "invalid.md", "setting": "space", "label": "output"}
|
||||
*
|
||||
* 1:5: Incorrect list-item indent: remove 2 spaces
|
||||
*
|
||||
* @example {"name": "invalid.md", "setting": "tab-size", "label": "input"}
|
||||
*
|
||||
* * List
|
||||
* item.
|
||||
*
|
||||
* @example {"name": "invalid.md", "setting": "tab-size", "label": "output"}
|
||||
*
|
||||
* 1:3: Incorrect list-item indent: add 2 spaces
|
||||
*
|
||||
* @example {"name": "invalid.md", "setting": "mixed", "label": "input"}
|
||||
*
|
||||
* * List item.
|
||||
*
|
||||
* @example {"name": "invalid.md", "setting": "mixed", "label": "output"}
|
||||
*
|
||||
* 1:5: Incorrect list-item indent: remove 2 spaces
|
||||
*
|
||||
* @example {"name": "invalid.md", "setting": "invalid", "label": "output", "config": {"positionless": true}}
|
||||
*
|
||||
* 1:1: Invalid list-item indent style `invalid`: use either `'tab-size'`, `'space'`, or `'mixed'`
|
||||
@ -67,38 +95,22 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* eslint-env commonjs */
|
||||
|
||||
/* Dependencies. */
|
||||
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 plural = require('plur');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = listItemIndent;
|
||||
module.exports = rule('remark-lint:list-item-indent', listItemIndent);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
|
||||
/* Styles. */
|
||||
var STYLES = {
|
||||
'tab-size': true,
|
||||
mixed: true,
|
||||
space: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Warn when the spacing between a list item’s bullet and
|
||||
* its content violates a given style.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {string?} [preferred='tab-size'] - Either
|
||||
* `'tab-size'`, `'space'`, or `'mixed'`, defaulting
|
||||
* to the first.
|
||||
* @param {Function} done - Callback.
|
||||
*/
|
||||
function listItemIndent(ast, file, preferred) {
|
||||
var contents = file.toString();
|
||||
|
||||
@ -108,14 +120,18 @@ function listItemIndent(ast, file, preferred) {
|
||||
file.fail('Invalid list-item indent style `' + preferred + '`: use either `\'tab-size\'`, `\'space\'`, or `\'mixed\'`');
|
||||
}
|
||||
|
||||
visit(ast, 'list', function (node) {
|
||||
visit(ast, 'list', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var items = node.children;
|
||||
|
||||
if (generated(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
items.forEach(function (item) {
|
||||
items.forEach(visitItem);
|
||||
|
||||
function visitItem(item) {
|
||||
var head = item.children[0];
|
||||
var initial = start(item).offset;
|
||||
var final = start(head).offset;
|
||||
@ -154,6 +170,6 @@ function listItemIndent(ast, file, preferred) {
|
||||
start(head)
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
31
packages/remark-lint-list-item-indent/package.json
Normal file
31
packages/remark-lint-list-item-indent/package.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "remark-lint-list-item-indent",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when the spacing between a list item’s bullet and its content violates a given style",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"list",
|
||||
"item",
|
||||
"indent"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-list-item-indent",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"plur": "^2.1.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
123
packages/remark-lint-list-item-indent/readme.md
Normal file
123
packages/remark-lint-list-item-indent/readme.md
Normal file
@ -0,0 +1,123 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-list-item-indent
|
||||
|
||||
Warn when the spacing between a list item’s bullet and its content
|
||||
violates a given style.
|
||||
|
||||
Options: `string`, either `'tab-size'`, `'mixed'`, or `'space'`,
|
||||
default: `'tab-size'`.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-list-item-indent
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
The below style is called `tab-size`.
|
||||
|
||||
* List
|
||||
item.
|
||||
|
||||
Paragraph.
|
||||
|
||||
11. List
|
||||
item.
|
||||
|
||||
Paragraph.
|
||||
|
||||
* List
|
||||
item.
|
||||
|
||||
* List
|
||||
item.
|
||||
```
|
||||
|
||||
When this rule is `'mixed'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
* List item.
|
||||
|
||||
Paragraph.
|
||||
|
||||
11. List item
|
||||
|
||||
Paragraph.
|
||||
|
||||
* List
|
||||
item.
|
||||
|
||||
* List
|
||||
item.
|
||||
```
|
||||
|
||||
When this rule is `'mixed'`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
* List item.
|
||||
```
|
||||
|
||||
```text
|
||||
1:5: Incorrect list-item indent: remove 2 spaces
|
||||
```
|
||||
|
||||
When this rule is `'space'`, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
* List item.
|
||||
|
||||
Paragraph.
|
||||
|
||||
11. List item
|
||||
|
||||
Paragraph.
|
||||
|
||||
* List
|
||||
item.
|
||||
|
||||
* List
|
||||
item.
|
||||
```
|
||||
|
||||
When this rule is `'space'`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
* List
|
||||
item.
|
||||
```
|
||||
|
||||
```text
|
||||
1:5: Incorrect list-item indent: remove 2 spaces
|
||||
```
|
||||
|
||||
When this rule is `'tab-size'`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
* List
|
||||
item.
|
||||
```
|
||||
|
||||
```text
|
||||
1:3: Incorrect list-item indent: add 2 spaces
|
||||
```
|
||||
|
||||
When `'invalid'` is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Invalid list-item indent style `invalid`: use either `'tab-size'`, `'space'`, or `'mixed'`
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -56,27 +56,20 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = listItemSpacing;
|
||||
module.exports = rule('remark-lint:list-item-spacing', listItemSpacing);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
var end = position.end;
|
||||
|
||||
/**
|
||||
* Warn when list items looseness is incorrect, such as
|
||||
* being tight when it should be loose, and vice versa.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function listItemSpacing(ast, file) {
|
||||
visit(ast, 'list', function (node) {
|
||||
visit(ast, 'list', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var items = node.children;
|
||||
var isTightList = true;
|
||||
var indent = start(node).column;
|
||||
@ -86,7 +79,13 @@ function listItemSpacing(ast, file) {
|
||||
return;
|
||||
}
|
||||
|
||||
items.forEach(function (item) {
|
||||
items.forEach(infer);
|
||||
|
||||
type = isTightList ? 'tight' : 'loose';
|
||||
|
||||
items.forEach(warn);
|
||||
|
||||
function infer(item) {
|
||||
var content = item.children;
|
||||
var head = content[0];
|
||||
var tail = content[content.length - 1];
|
||||
@ -95,11 +94,9 @@ function listItemSpacing(ast, file) {
|
||||
if (isLoose) {
|
||||
isTightList = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
type = isTightList ? 'tight' : 'loose';
|
||||
|
||||
items.forEach(function (item, index) {
|
||||
function warn(item, index) {
|
||||
var next = items[index + 1];
|
||||
var isTight = end(item).column > indent;
|
||||
|
||||
@ -123,6 +120,6 @@ function listItemSpacing(ast, file) {
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
31
packages/remark-lint-list-item-spacing/package.json
Normal file
31
packages/remark-lint-list-item-spacing/package.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "remark-lint-list-item-spacing",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when list looseness is incorrect",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"list",
|
||||
"item",
|
||||
"loose",
|
||||
"tight"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-list-item-spacing",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
70
packages/remark-lint-list-item-spacing/readme.md
Normal file
70
packages/remark-lint-list-item-spacing/readme.md
Normal file
@ -0,0 +1,70 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-list-item-spacing
|
||||
|
||||
Warn when list looseness is incorrect, such as being tight
|
||||
when it should be loose, and vice versa.
|
||||
|
||||
According to the [markdown-style-guide](http://www.cirosantilli.com/markdown-style-guide/),
|
||||
if one or more list-items in a list spans more than one line,
|
||||
the list is required to have blank lines between each item.
|
||||
And otherwise, there should not be blank lines between items.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-list-item-spacing
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
A tight list:
|
||||
|
||||
- item 1
|
||||
- item 2
|
||||
- item 3
|
||||
|
||||
A loose list:
|
||||
|
||||
- Wrapped
|
||||
item
|
||||
|
||||
- item 2
|
||||
|
||||
- item 3
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
A tight list:
|
||||
|
||||
- Wrapped
|
||||
item
|
||||
- item 2
|
||||
- item 3
|
||||
|
||||
A loose list:
|
||||
|
||||
- item 1
|
||||
|
||||
- item 2
|
||||
|
||||
- item 3
|
||||
```
|
||||
|
||||
```text
|
||||
4:9-5:1: Missing new line after list item
|
||||
5:11-6:1: Missing new line after list item
|
||||
11:1-12:1: Extraneous new line after list item
|
||||
13:1-14:1: Extraneous new line after list item
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -27,27 +27,19 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var toString = require('mdast-util-to-string');
|
||||
var generated = require('unist-util-generated');
|
||||
var toString = require('mdast-util-to-string');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = maximumHeadingLength;
|
||||
module.exports = rule('remark-lint:maximum-heading-length', maximumHeadingLength);
|
||||
|
||||
/**
|
||||
* Warn when headings are too long.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {number?} [preferred=60] - Maximum content
|
||||
* length.
|
||||
* @param {Function} done - Callback.
|
||||
*/
|
||||
function maximumHeadingLength(ast, file, preferred) {
|
||||
preferred = isNaN(preferred) || typeof preferred !== 'number' ? 60 : preferred;
|
||||
|
||||
visit(ast, 'heading', function (node) {
|
||||
visit(ast, 'heading', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
if (generated(node)) {
|
||||
return;
|
||||
}
|
||||
@ -55,5 +47,5 @@ function maximumHeadingLength(ast, file, preferred) {
|
||||
if (toString(node).length > preferred) {
|
||||
file.message('Use headings shorter than `' + preferred + '`', node);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
29
packages/remark-lint-maximum-heading-length/package.json
Normal file
29
packages/remark-lint-maximum-heading-length/package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "remark-lint-maximum-heading-length",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when headings are too long",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"heading",
|
||||
"length"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-maximum-heading-length",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"mdast-util-to-string": "^1.0.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
41
packages/remark-lint-maximum-heading-length/readme.md
Normal file
41
packages/remark-lint-maximum-heading-length/readme.md
Normal file
@ -0,0 +1,41 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-maximum-heading-length
|
||||
|
||||
Warn when headings are too long.
|
||||
|
||||
Options: `number`, default: `60`.
|
||||
|
||||
Ignores markdown syntax, only checks the plain text content.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-maximum-heading-length
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is `40`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
# Alpha bravo charlie delta echo foxtrot golf hotel
|
||||
```
|
||||
|
||||
```text
|
||||
1:1-1:52: Use headings shorter than `40`
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
# Alpha bravo charlie delta echo foxtrot golf hotel
|
||||
|
||||
# ![Alpha bravo charlie delta echo foxtrot golf hotel](http://example.com/nato.png)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -11,7 +11,7 @@
|
||||
* Ignores nodes which cannot be wrapped, such as heasings, tables,
|
||||
* code, link, images, and definitions.
|
||||
*
|
||||
* @example {"name": "valid.md", "setting": 80, "config": {"positionless": true}}
|
||||
* @example {"name": "valid.md", "config": {"positionless": true}}
|
||||
*
|
||||
* This line is simply not toooooooooooooooooooooooooooooooooooooooooooo
|
||||
* long.
|
||||
@ -58,27 +58,16 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = maximumLineLength;
|
||||
module.exports = rule('remark-lint:maximum-line-length', maximumLineLength);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
var end = position.end;
|
||||
|
||||
/**
|
||||
* Warn when lines are too long. This rule is forgiving
|
||||
* about lines which cannot be wrapped, such as code,
|
||||
* tables, and headings, or links at the enc of a line.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
* @param {number?} [preferred=80] - Maximum line length.
|
||||
*/
|
||||
function maximumLineLength(ast, file, preferred) {
|
||||
var style = preferred && preferred !== true ? preferred : 80;
|
||||
var content = file.toString();
|
||||
@ -88,17 +77,7 @@ function maximumLineLength(ast, file, preferred) {
|
||||
var lineLength;
|
||||
|
||||
/* Next, white list nodes which cannot be wrapped. */
|
||||
visit(ast, function (node) {
|
||||
var applicable = isIgnored(node);
|
||||
var initial = applicable && start(node).line;
|
||||
var final = applicable && end(node).line;
|
||||
|
||||
if (!applicable || generated(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
whitelist(initial - 1, final);
|
||||
});
|
||||
visit(ast, ignore);
|
||||
|
||||
visit(ast, 'link', validateLink);
|
||||
visit(ast, 'image', validateLink);
|
||||
@ -118,12 +97,19 @@ function maximumLineLength(ast, file, preferred) {
|
||||
|
||||
return;
|
||||
|
||||
/**
|
||||
* Whitelist from `initial` to `final`, zero-based.
|
||||
*
|
||||
* @param {number} initial - Start.
|
||||
* @param {number} final - End.
|
||||
*/
|
||||
function ignore(node) {
|
||||
var applicable = isIgnored(node);
|
||||
var initial = applicable && start(node).line;
|
||||
var final = applicable && end(node).line;
|
||||
|
||||
if (!applicable || generated(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
whitelist(initial - 1, final);
|
||||
}
|
||||
|
||||
/* Whitelist from `initial` to `final`, zero-based. */
|
||||
function whitelist(initial, final) {
|
||||
initial--;
|
||||
|
||||
@ -132,22 +118,18 @@ function maximumLineLength(ast, file, preferred) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finally, whitelist URLs, but only if they occur at
|
||||
/* Finally, whitelist URLs, but only if they occur at
|
||||
* or after the wrap. However, when they do, and
|
||||
* there’s white-space after it, they are not
|
||||
* whitelisted.
|
||||
*
|
||||
* @param {Node} node - Node.
|
||||
* @param {number} pos - Position of `node` in `parent`.
|
||||
* @param {Node} parent - Parent of `node`.
|
||||
*/
|
||||
* whitelisted. */
|
||||
function validateLink(node, pos, parent) {
|
||||
var next = parent.children[pos + 1];
|
||||
var initial = start(node);
|
||||
var final = end(node);
|
||||
|
||||
/* Nothing to whitelist when generated. */
|
||||
/* istanbul ignore if - Hard to test, as we only run this
|
||||
* case on `position: true` */
|
||||
if (generated(node)) {
|
||||
return;
|
||||
}
|
||||
@ -172,14 +154,8 @@ function maximumLineLength(ast, file, preferred) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if `node` is applicable, as in, if it should be
|
||||
* ignored.
|
||||
*
|
||||
* @param {Node} node - Node to test.
|
||||
* @return {boolean} - Whether or not `node` should be
|
||||
* ignored.
|
||||
*/
|
||||
/* Check if `node` is applicable, as in, if it should be
|
||||
* ignored. */
|
||||
function isIgnored(node) {
|
||||
return node.type === 'heading' ||
|
||||
node.type === 'table' ||
|
29
packages/remark-lint-maximum-line-length/package.json
Normal file
29
packages/remark-lint-maximum-line-length/package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "remark-lint-maximum-line-length",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when lines are too long",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"line",
|
||||
"length"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-maximum-line-length",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
72
packages/remark-lint-maximum-line-length/readme.md
Normal file
72
packages/remark-lint-maximum-line-length/readme.md
Normal file
@ -0,0 +1,72 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-maximum-line-length
|
||||
|
||||
Warn when lines are too long.
|
||||
|
||||
Options: `number`, default: `80`.
|
||||
|
||||
Ignores nodes which cannot be wrapped, such as heasings, tables,
|
||||
code, link, images, and definitions.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-maximum-line-length
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is `80`, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
This line is simply not tooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
long.
|
||||
|
||||
Just like thiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis one.
|
||||
|
||||
And this one is also very wrong: because the link starts aaaaaaafter the column: <http://line.com>
|
||||
|
||||
<http://this-long-url-with-a-long-domain-is-invalid.co.uk/a-long-path?query=variables> and such.
|
||||
```
|
||||
|
||||
```text
|
||||
4:86: Line must be at most 80 characters
|
||||
6:99: Line must be at most 80 characters
|
||||
8:97: Line must be at most 80 characters
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
This line is simply not toooooooooooooooooooooooooooooooooooooooooooo
|
||||
long.
|
||||
|
||||
This is also fine: <http://this-long-url-with-a-long-domain.co.uk/a-long-path?query=variables>
|
||||
|
||||
<http://this-link-is-fine.com>
|
||||
|
||||
[foo](http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables)
|
||||
|
||||
<http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables>
|
||||
|
||||
![foo](http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables)
|
||||
|
||||
| An | exception | is | line | length | in | long | tables | because | those | can’t | just |
|
||||
| -- | --------- | -- | ---- | ------ | -- | ---- | ------ | ------- | ----- | ----- | ---- |
|
||||
| be | helped | | | | | | | | | | . |
|
||||
|
||||
The following is also fine, because there is no white-space.
|
||||
|
||||
<http://this-long-url-with-a-long-domain-is-invalid.co.uk/a-long-path?query=variables>.
|
||||
|
||||
In addition, definitions are also fine:
|
||||
|
||||
[foo]: <http://this-long-url-with-a-long-domain-is-invalid.co.uk/a-long-path?query=variables>
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -23,38 +23,25 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* eslint-env commonjs */
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var toString = require('mdast-util-to-string');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
var toString = require('mdast-util-to-string');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = noAutoLinkWithoutProtocol;
|
||||
module.exports = rule('remark-lint:no-auto-link-without-protocol', noAutoLinkWithoutProtocol);
|
||||
|
||||
/* Methods. */
|
||||
var start = position.start;
|
||||
var end = position.end;
|
||||
|
||||
/**
|
||||
* Protocol expression.
|
||||
*
|
||||
* @type {RegExp}
|
||||
* @see http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax
|
||||
*/
|
||||
|
||||
/* Protocol expression. See:
|
||||
* http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax */
|
||||
var PROTOCOL = /^[a-z][a-z+.-]+:\/?/i;
|
||||
|
||||
/**
|
||||
* Warn for angle-bracketed links without protocol.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function noAutoLinkWithoutProtocol(ast, file) {
|
||||
visit(ast, 'link', function (node) {
|
||||
visit(ast, 'link', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var head = start(node.children[0]).column;
|
||||
var tail = end(node.children[node.children.length - 1]).column;
|
||||
var initial = start(node).column;
|
||||
@ -64,18 +51,8 @@ function noAutoLinkWithoutProtocol(ast, file) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (initial === head - 1 && final === tail + 1 && !hasProtocol(node)) {
|
||||
if (initial === head - 1 && final === tail + 1 && !PROTOCOL.test(toString(node))) {
|
||||
file.message('All automatic links must start with a protocol', node);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert `node`s reference starts with a protocol.
|
||||
*
|
||||
* @param {Node} node - Node to test.
|
||||
* @return {boolean} - Whether `node` has a protocol.
|
||||
*/
|
||||
function hasProtocol(node) {
|
||||
return PROTOCOL.test(toString(node));
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "remark-lint-no-auto-link-without-protocol",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn for angle-bracketed links without protocol",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"auto",
|
||||
"link",
|
||||
"protocol"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-auto-link-without-protocol",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"mdast-util-to-string": "^1.0.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
37
packages/remark-lint-no-auto-link-without-protocol/readme.md
Normal file
37
packages/remark-lint-no-auto-link-without-protocol/readme.md
Normal file
@ -0,0 +1,37 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-no-auto-link-without-protocol
|
||||
|
||||
Warn for angle-bracketed links without protocol.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-no-auto-link-without-protocol
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
<http://www.example.com>
|
||||
<mailto:foo@bar.com>
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
<www.example.com>
|
||||
<foo@bar.com>
|
||||
```
|
||||
|
||||
```text
|
||||
2:1-2:14: All automatic links must start with a protocol
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -25,28 +25,22 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var vfileLocation = require('vfile-location');
|
||||
var visit = require('unist-util-visit');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = noBlockquoteWithoutCaret;
|
||||
module.exports = rule('remark-lint:no-blockquote-without-caret', noBlockquoteWithoutCaret);
|
||||
|
||||
/**
|
||||
* Warn when blank lines without carets are found in a
|
||||
* blockquote.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function noBlockquoteWithoutCaret(ast, file) {
|
||||
var contents = file.toString();
|
||||
var location = vfileLocation(file);
|
||||
var last = contents.length;
|
||||
|
||||
visit(ast, 'blockquote', function (node) {
|
||||
visit(ast, 'blockquote', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var start = position.start(node).line;
|
||||
var indent = node.position && node.position.indent;
|
||||
|
||||
@ -54,7 +48,9 @@ function noBlockquoteWithoutCaret(ast, file) {
|
||||
return;
|
||||
}
|
||||
|
||||
indent.forEach(function (column, n) {
|
||||
indent.forEach(eachLine);
|
||||
|
||||
function eachLine(column, n) {
|
||||
var character;
|
||||
var line = start + n + 1;
|
||||
var offset = location.toOffset({
|
||||
@ -79,6 +75,6 @@ function noBlockquoteWithoutCaret(ast, file) {
|
||||
line: line,
|
||||
column: column
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "remark-lint-no-blockquote-without-caret",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when blank lines without carets are found in a blockquote",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"blockquote",
|
||||
"caret"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-blockquote-without-caret",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1",
|
||||
"vfile-location": "^2.0.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
39
packages/remark-lint-no-blockquote-without-caret/readme.md
Normal file
39
packages/remark-lint-no-blockquote-without-caret/readme.md
Normal file
@ -0,0 +1,39 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-no-blockquote-without-caret
|
||||
|
||||
Warn when blank lines without carets are found in a blockquote.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-no-blockquote-without-caret
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
> Foo...
|
||||
>
|
||||
> ...Bar.
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
> Foo...
|
||||
|
||||
> ...Bar.
|
||||
```
|
||||
|
||||
```text
|
||||
2:1: Missing caret in blockquote
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -36,30 +36,20 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* eslint-env commonjs */
|
||||
|
||||
/* Dependencies. */
|
||||
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 plural = require('plur');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = noConsecutiveBlankLines;
|
||||
module.exports = rule('remark-lint:no-consecutive-blank-lines', noConsecutiveBlankLines);
|
||||
|
||||
/* Constants. */
|
||||
var MAX = 2;
|
||||
|
||||
/**
|
||||
* Warn for too many consecutive blank lines. Knows
|
||||
* about the extra line needed between a list and
|
||||
* indented code, and two lists.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function noConsecutiveBlankLines(ast, file) {
|
||||
visit(ast, function (node) {
|
||||
visit(ast, visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var children = node.children;
|
||||
var head = children && children[0];
|
||||
var tail = children && children[children.length - 1];
|
||||
@ -73,41 +63,37 @@ function noConsecutiveBlankLines(ast, file) {
|
||||
compare(position.start(node), position.start(head), 0);
|
||||
|
||||
/* Compare between each child. */
|
||||
children.forEach(function (child, index) {
|
||||
var prev = children[index - 1];
|
||||
var max = MAX;
|
||||
|
||||
if (!prev || generated(prev) || generated(child)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(prev.type === 'list' && child.type === 'list') ||
|
||||
(child.type === 'code' && prev.type === 'list' && !child.lang)
|
||||
) {
|
||||
max++;
|
||||
}
|
||||
|
||||
compare(position.end(prev), position.start(child), max);
|
||||
});
|
||||
children.forEach(visitChild);
|
||||
|
||||
/* Compare parent and last child. */
|
||||
if (tail !== head && !generated(tail)) {
|
||||
compare(position.end(node), position.end(tail), 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function visitChild(child, index) {
|
||||
var prev = children[index - 1];
|
||||
var max = MAX;
|
||||
|
||||
if (!prev || generated(prev) || generated(child)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(prev.type === 'list' && child.type === 'list') ||
|
||||
(child.type === 'code' && prev.type === 'list' && !child.lang)
|
||||
) {
|
||||
max++;
|
||||
}
|
||||
|
||||
compare(position.end(prev), position.start(child), max);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
/**
|
||||
* Compare the difference between `start` and `end`,
|
||||
* and warn when that difference exceeds `max`.
|
||||
*
|
||||
* @param {Position} start - Initial.
|
||||
* @param {Position} end - Final.
|
||||
* @param {number} max - Threshold.
|
||||
*/
|
||||
/* Compare the difference between `start` and `end`,
|
||||
* and warn when that difference exceeds `max`. */
|
||||
function compare(start, end, max) {
|
||||
var diff = end.line - start.line;
|
||||
var word = diff > 0 ? 'before' : 'after';
|
30
packages/remark-lint-no-consecutive-blank-lines/package.json
Normal file
30
packages/remark-lint-no-consecutive-blank-lines/package.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "remark-lint-no-consecutive-blank-lines",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn for too many consecutive blank lines",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"blank",
|
||||
"lines"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-consecutive-blank-lines",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"plur": "^2.1.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
53
packages/remark-lint-no-consecutive-blank-lines/readme.md
Normal file
53
packages/remark-lint-no-consecutive-blank-lines/readme.md
Normal file
@ -0,0 +1,53 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-no-consecutive-blank-lines
|
||||
|
||||
Warn for too many consecutive blank lines. Knows about the extra line
|
||||
needed between a list and indented code, and two lists.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-no-consecutive-blank-lines
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
Foo...
|
||||
|
||||
...Bar.
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid-for-code.md` is ok:
|
||||
|
||||
```markdown
|
||||
Paragraph.
|
||||
|
||||
* List
|
||||
|
||||
|
||||
bravo();
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
Foo...
|
||||
|
||||
|
||||
...Bar.
|
||||
```
|
||||
|
||||
```text
|
||||
4:1: Remove 1 line before node
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -23,22 +23,13 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
var visit = require('unist-util-visit');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = noDuplicateDefinitions;
|
||||
module.exports = rule('remark-lint:no-duplicate-definitions', noDuplicateDefinitions);
|
||||
|
||||
/**
|
||||
* Warn when definitions with equal content are found.
|
||||
*
|
||||
* Matches case-insensitive.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function noDuplicateDefinitions(ast, file) {
|
||||
var map = {};
|
||||
|
||||
@ -47,11 +38,6 @@ function noDuplicateDefinitions(ast, file) {
|
||||
|
||||
return;
|
||||
|
||||
/**
|
||||
* Check `node`.
|
||||
*
|
||||
* @param {Node} node - Node.
|
||||
*/
|
||||
function validate(node) {
|
||||
var duplicate = map[node.identifier];
|
||||
var pos;
|
29
packages/remark-lint-no-duplicate-definitions/package.json
Normal file
29
packages/remark-lint-no-duplicate-definitions/package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "remark-lint-no-duplicate-definitions",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn on duplicate definitions",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"duplicate",
|
||||
"definition"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-duplicate-definitions",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
37
packages/remark-lint-no-duplicate-definitions/readme.md
Normal file
37
packages/remark-lint-no-duplicate-definitions/readme.md
Normal file
@ -0,0 +1,37 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-no-duplicate-definitions
|
||||
|
||||
Warn when duplicate definitions are found.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-no-duplicate-definitions
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
[foo]: bar
|
||||
[baz]: qux
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
[foo]: bar
|
||||
[foo]: qux
|
||||
```
|
||||
|
||||
```text
|
||||
2:1-2:11: Do not use definitions with the same identifier (1:1)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -41,21 +41,20 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
var visit = require('unist-util-visit');
|
||||
var toString = require('mdast-util-to-string');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = noDuplicateHeadingsInSection;
|
||||
module.exports = rule('remark-lint:no-duplicate-headings-in-section', noDuplicateHeadingsInSection);
|
||||
|
||||
/* Warn when headings with equal content are found in
|
||||
* a section. Case-insensitive. */
|
||||
function noDuplicateHeadingsInSection(tree, file) {
|
||||
var stack = [{}];
|
||||
|
||||
visit(tree, 'heading', function (node) {
|
||||
visit(tree, 'heading', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var depth = node.depth;
|
||||
var siblings = stack[depth - 1] || {};
|
||||
var value = toString(node).toUpperCase();
|
||||
@ -74,5 +73,5 @@ function noDuplicateHeadingsInSection(tree, file) {
|
||||
node
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "remark-lint-no-duplicate-headings-in-section",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn on duplicate headings in a section",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"duplicate",
|
||||
"heading",
|
||||
"section"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-duplicate-headings-in-section",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"mdast-util-to-string": "^1.0.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-no-duplicate-headings-in-section
|
||||
|
||||
Warn when duplicate headings are found,
|
||||
but only when on the same level, “in”
|
||||
the same section.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-no-duplicate-headings-in-section
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
## Alpha
|
||||
|
||||
### Bravo
|
||||
|
||||
## Charlie
|
||||
|
||||
### Bravo
|
||||
|
||||
### Delta
|
||||
|
||||
#### Bravo
|
||||
|
||||
#### Echo
|
||||
|
||||
##### Bravo
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
## Foxtrot
|
||||
|
||||
### Golf
|
||||
|
||||
### Golf
|
||||
```
|
||||
|
||||
```text
|
||||
5:1-5:9: Do not use headings with similar content per section (3:1)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -28,29 +28,20 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* eslint-env commonjs */
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var position = require('unist-util-position');
|
||||
var generated = require('unist-util-generated');
|
||||
var visit = require('unist-util-visit');
|
||||
var toString = require('mdast-util-to-string');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = noDuplicateHeadings;
|
||||
module.exports = rule('remark-lint:no-duplicate-headings', noDuplicateHeadings);
|
||||
|
||||
/**
|
||||
* Warn when headings with equal content are found.
|
||||
*
|
||||
* Matches case-insensitive.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function noDuplicateHeadings(ast, file) {
|
||||
var map = {};
|
||||
|
||||
visit(ast, 'heading', function (node) {
|
||||
visit(ast, 'heading', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
var value = toString(node).toUpperCase();
|
||||
var duplicate = map[value];
|
||||
var pos;
|
||||
@ -70,5 +61,5 @@ function noDuplicateHeadings(ast, file) {
|
||||
}
|
||||
|
||||
map[value] = node;
|
||||
});
|
||||
}
|
||||
}
|
30
packages/remark-lint-no-duplicate-headings/package.json
Normal file
30
packages/remark-lint-no-duplicate-headings/package.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "remark-lint-no-duplicate-headings",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn on duplicate headings",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"duplicate",
|
||||
"heading"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-duplicate-headings",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"mdast-util-to-string": "^1.0.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
42
packages/remark-lint-no-duplicate-headings/readme.md
Normal file
42
packages/remark-lint-no-duplicate-headings/readme.md
Normal file
@ -0,0 +1,42 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-no-duplicate-headings
|
||||
|
||||
Warn when duplicate headings are found.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-no-duplicate-headings
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
# Foo
|
||||
|
||||
## Bar
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
# Foo
|
||||
|
||||
## Foo
|
||||
|
||||
## [Foo](http://foo.com/bar)
|
||||
```
|
||||
|
||||
```text
|
||||
3:1-3:7: Do not use headings with similar content (1:1)
|
||||
5:1-5:29: Do not use headings with similar content (3:1)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -19,29 +19,28 @@
|
||||
*
|
||||
* Bar.
|
||||
*
|
||||
* __Qux__
|
||||
*
|
||||
* Quux.
|
||||
*
|
||||
* @example {"name": "invalid.md", "label": "output"}
|
||||
*
|
||||
* 1:1-1:6: Don’t use emphasis to introduce a section, use a heading
|
||||
* 5:1-5:8: Don’t use emphasis to introduce a section, use a heading
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Dependencies. */
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
/* Expose. */
|
||||
module.exports = noEmphasisAsHeading;
|
||||
module.exports = rule('remark-lint:no-emphasis-as-heading', noEmphasisAsHeading);
|
||||
|
||||
/**
|
||||
* Warn when a section (a new paragraph) is introduced
|
||||
* by emphasis (or strong) and a colon.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function noEmphasisAsHeading(ast, file) {
|
||||
visit(ast, 'paragraph', function (node, index, parent) {
|
||||
visit(ast, 'paragraph', visitor);
|
||||
|
||||
function visitor(node, index, parent) {
|
||||
var children = node.children;
|
||||
var child = children[0];
|
||||
var prev = parent.children[index - 1];
|
||||
@ -60,5 +59,5 @@ function noEmphasisAsHeading(ast, file) {
|
||||
) {
|
||||
file.message('Don’t use emphasis to introduce a section, use a heading', node);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
28
packages/remark-lint-no-emphasis-as-heading/package.json
Normal file
28
packages/remark-lint-no-emphasis-as-heading/package.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "remark-lint-no-emphasis-as-heading",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when emphasis or importance is used instead of a heading",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"emphasis",
|
||||
"heading"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-emphasis-as-heading",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
45
packages/remark-lint-no-emphasis-as-heading/readme.md
Normal file
45
packages/remark-lint-no-emphasis-as-heading/readme.md
Normal file
@ -0,0 +1,45 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-no-emphasis-as-heading
|
||||
|
||||
Warn when emphasis (including strong), instead of a heading, introduces
|
||||
a paragraph.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-no-emphasis-as-heading
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
# Foo
|
||||
|
||||
Bar.
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
*Foo*
|
||||
|
||||
Bar.
|
||||
|
||||
__Qux__
|
||||
|
||||
Quux.
|
||||
```
|
||||
|
||||
```text
|
||||
1:1-1:6: Don’t use emphasis to introduce a section, use a heading
|
||||
5:1-5:8: Don’t use emphasis to introduce a section, use a heading
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -26,14 +26,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var rule = require('unified-lint-rule');
|
||||
var visit = require('unist-util-visit');
|
||||
var generated = require('unist-util-generated');
|
||||
|
||||
module.exports = noEmptyLinkURL;
|
||||
module.exports = rule('remark-lint:no-empty-url', noEmptyURL);
|
||||
|
||||
var types = ['link', 'image'];
|
||||
|
||||
function noEmptyLinkURL(tree, file) {
|
||||
function noEmptyURL(tree, file) {
|
||||
visit(tree, visitor);
|
||||
|
||||
function visitor(node) {
|
33
packages/remark-lint-no-empty-url/package.json
Normal file
33
packages/remark-lint-no-empty-url/package.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "remark-lint-no-empty-url",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn on empty URLs in links and images",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"empty",
|
||||
"url",
|
||||
"link",
|
||||
"image"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-empty-url",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"mdast-util-to-string": "^1.0.2",
|
||||
"plur": "^2.1.2",
|
||||
"unified-lint-rule": "0.0.0",
|
||||
"unist-util-generated": "^1.1.0",
|
||||
"unist-util-position": "^3.0.0",
|
||||
"unist-util-visit": "^1.1.1"
|
||||
},
|
||||
"xo": false
|
||||
}
|
40
packages/remark-lint-no-empty-url/readme.md
Normal file
40
packages/remark-lint-no-empty-url/readme.md
Normal file
@ -0,0 +1,40 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-no-empty-url
|
||||
|
||||
Warn for empty URLs in links and images.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-no-empty-url
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`valid.md` is ok:
|
||||
|
||||
```markdown
|
||||
[alpha](http://bravo.com).
|
||||
|
||||
![charlie](http://delta.com/echo.png "foxtrott").
|
||||
```
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`invalid.md` is **not** ok:
|
||||
|
||||
```markdown
|
||||
[golf]().
|
||||
|
||||
![hotel]().
|
||||
```
|
||||
|
||||
```text
|
||||
1:1-1:9: Don’t use links without URL
|
||||
3:1-3:11: Don’t use images without URL
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -27,15 +27,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Expose. */
|
||||
module.exports = noFileNameArticles;
|
||||
var rule = require('unified-lint-rule');
|
||||
|
||||
module.exports = rule('remark-lint:no-file-name-articles', noFileNameArticles);
|
||||
|
||||
/**
|
||||
* Warn when file name start with an article.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function noFileNameArticles(ast, file) {
|
||||
var match = file.stem && file.stem.match(/^(the|teh|an?)\b/i);
|
||||
|
28
packages/remark-lint-no-file-name-articles/package.json
Normal file
28
packages/remark-lint-no-file-name-articles/package.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "remark-lint-no-file-name-articles",
|
||||
"version": "0.0.0",
|
||||
"description": "remark-lint rule to warn when file name start with an article",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"remark",
|
||||
"lint",
|
||||
"rule",
|
||||
"file",
|
||||
"name",
|
||||
"basename",
|
||||
"article"
|
||||
],
|
||||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-file-name-articles",
|
||||
"bugs": "https://github.com/wooorm/remark-lint/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unified-lint-rule": "0.0.0"
|
||||
},
|
||||
"xo": false
|
||||
}
|
48
packages/remark-lint-no-file-name-articles/readme.md
Normal file
48
packages/remark-lint-no-file-name-articles/readme.md
Normal file
@ -0,0 +1,48 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-no-file-name-articles
|
||||
|
||||
Warn when file name start with an article.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save remark-lint-no-file-name-articles
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
When this rule is turned on, the following file
|
||||
`title.md` is ok:
|
||||
|
||||
```markdown
|
||||
|
||||
```
|
||||
|
||||
When turned on is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Do not start file names with `a`
|
||||
```
|
||||
|
||||
When turned on is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Do not start file names with `the`
|
||||
```
|
||||
|
||||
When turned on is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Do not start file names with `teh`
|
||||
```
|
||||
|
||||
When turned on is passed in, the following error is given:
|
||||
|
||||
```text
|
||||
1:1: Do not start file names with `an`
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
|
@ -15,15 +15,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Expose. */
|
||||
module.exports = noFileNameConsecutiveDashes;
|
||||
var rule = require('unified-lint-rule');
|
||||
|
||||
module.exports = rule('remark-lint:no-file-name-consecutive-dashes', noFileNameConsecutiveDashes);
|
||||
|
||||
/**
|
||||
* Warn when file names contain consecutive dashes.
|
||||
*
|
||||
* @param {Node} ast - Root node.
|
||||
* @param {File} file - Virtual file.
|
||||
*/
|
||||
function noFileNameConsecutiveDashes(ast, file) {
|
||||
if (file.stem && /-{2,}/.test(file.stem)) {
|
||||
file.message('Do not use consecutive dashes in a file name');
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user