diff --git a/.gitignore b/.gitignore index 385631c9..85fa4eab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store *.log coverage/ +.nyc_output/ node_modules/ remark-lint.js remark-lint.min.js diff --git a/.remarkignore b/.remarkignore deleted file mode 100644 index 9daeafb9..00000000 --- a/.remarkignore +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/.travis.yml b/.travis.yml index dfc4322a..7ba89596 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ node_js: - '4.0' - '5.0' - '6.0' -sudo: false after_success: - bash <(curl -s https://codecov.io/bash) deploy: diff --git a/doc/external.md b/doc/external.md new file mode 100644 index 00000000..85c4ba93 --- /dev/null +++ b/doc/external.md @@ -0,0 +1,207 @@ +# 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 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. + +Alternatively, load 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" + ] + } + } +} +``` + +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']}) + .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.warn( + '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(); + }); +} +``` + + + +[root]: https://github.com/wooorm/mdast#root + +[vfile]: https://github.com/wooorm/vfile + +[comments]: https://github.com/wooorm/remark-lint#configuring-remark-lint diff --git a/doc/rules.md b/doc/rules.md index d9e5680c..27eff913 100644 --- a/doc/rules.md +++ b/doc/rules.md @@ -1,1297 +1,2468 @@ + + # List of Rules -This document describes all available rules, what they -check for, examples of what they warn for, and how to -fix their warnings. - -See the readme for a [list of external rules](https://github.com/wooorm/remark-lint#list-of-external-rules). - -## Rules - -Remember that rules can always be turned off by -passing false. In addition, when reset is given, values can -be null or undefined in order to be ignored. - -### Table of Contents - -* [external](#external) -* [reset](#reset) -* [blockquote-indentation](#blockquote-indentation) -* [checkbox-character-style](#checkbox-character-style) -* [checkbox-content-indent](#checkbox-content-indent) -* [code-block-style](#code-block-style) -* [definition-case](#definition-case) -* [definition-spacing](#definition-spacing) -* [emphasis-marker](#emphasis-marker) -* [fenced-code-flag](#fenced-code-flag) -* [fenced-code-marker](#fenced-code-marker) -* [file-extension](#file-extension) -* [final-definition](#final-definition) -* [final-newline](#final-newline) -* [first-heading-level](#first-heading-level) -* [hard-break-spaces](#hard-break-spaces) -* [heading-increment](#heading-increment) -* [heading-style](#heading-style) -* [link-title-style](#link-title-style) -* [list-item-bullet-indent](#list-item-bullet-indent) -* [list-item-content-indent](#list-item-content-indent) -* [list-item-indent](#list-item-indent) -* [list-item-spacing](#list-item-spacing) -* [maximum-heading-length](#maximum-heading-length) -* [maximum-line-length](#maximum-line-length) -* [no-auto-link-without-protocol](#no-auto-link-without-protocol) -* [no-blockquote-without-caret](#no-blockquote-without-caret) -* [no-consecutive-blank-lines](#no-consecutive-blank-lines) -* [no-duplicate-definitions](#no-duplicate-definitions) -* [no-duplicate-headings](#no-duplicate-headings) -* [no-emphasis-as-heading](#no-emphasis-as-heading) -* [no-file-name-articles](#no-file-name-articles) -* [no-file-name-consecutive-dashes](#no-file-name-consecutive-dashes) -* [no-file-name-irregular-characters](#no-file-name-irregular-characters) -* [no-file-name-mixed-case](#no-file-name-mixed-case) -* [no-file-name-outer-dashes](#no-file-name-outer-dashes) -* [no-heading-content-indent](#no-heading-content-indent) -* [no-heading-indent](#no-heading-indent) -* [no-heading-punctuation](#no-heading-punctuation) -* [no-html](#no-html) -* [no-inline-padding](#no-inline-padding) -* [no-literal-urls](#no-literal-urls) -* [no-missing-blank-lines](#no-missing-blank-lines) -* [no-multiple-toplevel-headings](#no-multiple-toplevel-headings) -* [no-shell-dollars](#no-shell-dollars) -* [no-shortcut-reference-image](#no-shortcut-reference-image) -* [no-shortcut-reference-link](#no-shortcut-reference-link) -* [no-table-indentation](#no-table-indentation) -* [no-tabs](#no-tabs) -* [no-undefined-references](#no-undefined-references) -* [no-unused-definitions](#no-unused-definitions) -* [ordered-list-marker-style](#ordered-list-marker-style) -* [ordered-list-marker-value](#ordered-list-marker-value) -* [rule-style](#rule-style) -* [strong-marker](#strong-marker) -* [table-cell-padding](#table-cell-padding) -* [table-pipe-alignment](#table-pipe-alignment) -* [table-pipes](#table-pipes) -* [unordered-list-marker-style](#unordered-list-marker-style) - -### external - -````md - - ```json - { - "external": ["foo", "bar", "baz"] - } - ``` -```` +This document describes all (57) +available rules, what they check for, examples of +what they warn for, and how to fix their warnings. + +Note: both camel-cased and dash-cases versions of rule id’s +are supported in configuration objects: + +```json +{ + "final-newline": false +} +``` + +...is treated the same as: + +```json +{ + "finalNewline": false +} +``` + +## Table of Contents + +- [reset](#reset) +- [external](#external) +- [blockquote-indentation](#blockquote-indentation) +- [checkbox-character-style](#checkbox-character-style) +- [checkbox-content-indent](#checkbox-content-indent) +- [code-block-style](#code-block-style) +- [definition-case](#definition-case) +- [definition-spacing](#definition-spacing) +- [emphasis-marker](#emphasis-marker) +- [fenced-code-flag](#fenced-code-flag) +- [fenced-code-marker](#fenced-code-marker) +- [file-extension](#file-extension) +- [final-definition](#final-definition) +- [final-newline](#final-newline) +- [first-heading-level](#first-heading-level) +- [hard-break-spaces](#hard-break-spaces) +- [heading-increment](#heading-increment) +- [heading-style](#heading-style) +- [link-title-style](#link-title-style) +- [list-item-bullet-indent](#list-item-bullet-indent) +- [list-item-content-indent](#list-item-content-indent) +- [list-item-indent](#list-item-indent) +- [list-item-spacing](#list-item-spacing) +- [maximum-heading-length](#maximum-heading-length) +- [maximum-line-length](#maximum-line-length) +- [no-auto-link-without-protocol](#no-auto-link-without-protocol) +- [no-blockquote-without-caret](#no-blockquote-without-caret) +- [no-consecutive-blank-lines](#no-consecutive-blank-lines) +- [no-duplicate-definitions](#no-duplicate-definitions) +- [no-duplicate-headings](#no-duplicate-headings) +- [no-emphasis-as-heading](#no-emphasis-as-heading) +- [no-file-name-articles](#no-file-name-articles) +- [no-file-name-consecutive-dashes](#no-file-name-consecutive-dashes) +- [no-file-name-irregular-characters](#no-file-name-irregular-characters) +- [no-file-name-mixed-case](#no-file-name-mixed-case) +- [no-file-name-outer-dashes](#no-file-name-outer-dashes) +- [no-heading-content-indent](#no-heading-content-indent) +- [no-heading-indent](#no-heading-indent) +- [no-heading-punctuation](#no-heading-punctuation) +- [no-html](#no-html) +- [no-inline-padding](#no-inline-padding) +- [no-literal-urls](#no-literal-urls) +- [no-missing-blank-lines](#no-missing-blank-lines) +- [no-multiple-toplevel-headings](#no-multiple-toplevel-headings) +- [no-shell-dollars](#no-shell-dollars) +- [no-shortcut-reference-image](#no-shortcut-reference-image) +- [no-shortcut-reference-link](#no-shortcut-reference-link) +- [no-table-indentation](#no-table-indentation) +- [no-tabs](#no-tabs) +- [no-undefined-references](#no-undefined-references) +- [no-unused-definitions](#no-unused-definitions) +- [ordered-list-marker-style](#ordered-list-marker-style) +- [ordered-list-marker-value](#ordered-list-marker-value) +- [rule-style](#rule-style) +- [strong-marker](#strong-marker) +- [table-cell-padding](#table-cell-padding) +- [table-pipe-alignment](#table-pipe-alignment) +- [table-pipes](#table-pipes) +- [unordered-list-marker-style](#unordered-list-marker-style) + +## `reset` + +By default, all rules are turned on unless explicitly +set to `false`. When `reset: true`, the opposite is +`true`: all rules are turned off, unless when given a +non-nully and non-false value. + +Options: `boolean`, default: `false`. + +Explicitly activate rules: + +```json +{ + "reset": true, + "final-newline": true +} +``` + +## `external` -External contains a list of extra rules to load. -These are, or refer to, an object mapping `ruleId`s to rules. +External contains a list of extra rules to load. These are, +or refer to, an object mapping `ruleId`s to rules. -Note that in node.js, a string can be given (a module -name or a file), but in the browser an object must be passed in. +Note that in Node.js, a `string` can be given (a module name +or a file path), but in the browser an object must be passed +in. -When using a globally installed remark-lint, globally installed external -rules are also loaded. +When using a globally installed remark-lint, globally installed +external rules are also loaded. The prefix `remark-lint-` can be omitted. -### reset +```js +{ + external: ['no-empty-sections', './a-local-file.js'] +} +``` -````md - - ```json - { - "reset": true, - "final-newline": true - } - ``` -```` +Read more about external rules in +[`doc/external.md`](./external.md). -By default, all rules are turned on unless explicitly set to `false`. -When `reset: true`, the opposite is true: all rules are turned off, -unless when given a non-nully and non-false value. +## `blockquote-indentation` -Options: `boolean`, default: `false`. +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. + +When this rule is `2`, the following file +`valid.md` is ok: -### blockquote-indentation +```markdown + -```md - - > Hello - ... - > World +> Hello - - > Hello - ... - > World +Paragraph. - - > Hello - ... - > World +> World ``` - Warn when blockquotes are either indented too much or too little. +When this rule is `4`, the following file +`valid.md` is ok: - Options: `number`, default: `'consistent'`. +```markdown + - The default value, `consistent`, detects the first used indentation - and will warn when other blockquotes use a different indentation. +> Hello -### checkbox-character-style +Paragraph. -```md - +> World +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: - - - [x] List item - - [x] List item +```markdown +> Hello - - - [X] List item - - [X] List item +Paragraph. - - - [ ] List item - - [ ] List item +> World - - - [»···] List item - - [»···] List item +Paragraph. - - - [x] List item - - [X] List item - - [ ] List item - - [»···] List item +> World ``` - Warn when list item checkboxes violate a given style. +```text +5:3: Remove 1 space between blockquote and content +9:3: Add 1 space between blockquote and content +``` - The default value, `consistent`, detects the first used checked - and unchecked checkbox styles, and will warn when a subsequent - checkboxes uses a different style. +## `checkbox-character-style` - These values can also be passed in as an object, such as: +Warn when list item checkboxes violate a given style. -```json -{ - "checked": "x", - "unchecked": " " -} +The default value, `consistent`, detects the first used checked +and unchecked checkbox styles, and will warn when a subsequent +checkboxes uses a different style. + +These values can also be passed in as an object, such as: + +```js +{checked: 'x', unchecked: ' '} ``` -### checkbox-content-indent +When this rule is `{ checked: 'x' }`, the following file +`valid.md` is ok: -```md - - - [ ] List item - + [x] List item - * [X] List item - - [ ] List item +```markdown + - - - [ ] List item - + [x] List item - * [X] List item - - [ ] List item +- [x] List item +- [x] List item ``` - Warn when list item checkboxes are followed by too much white-space. +When this rule is `{ checked: 'X' }`, the following file +`valid.md` is ok: -### code-block-style +```markdown + -````md - - Hello +- [X] List item +- [X] List item +``` - ... +When this rule is `{ unchecked: ' ' }`, the following file +`valid.md` is ok: - World +```markdown + - - ``` - Hello - ``` - ... - ```bar - World - ``` +- [ ] List item +- [ ] List item +- [ ]·· +- [ ] +``` - - Hello - ... - ``` - World - ``` -```` +When this rule is `{ unchecked: '\t' }`, the following file +`valid.md` is ok: - Warn when code-blocks do not adhere to a given style. +```markdown + - Options: `string`, either `'consistent'`, `'fenced'`, or `'indented'`, - default: `'consistent'`. +- [»] List item +- [»] List item +``` - The default value, `consistent`, detects the first used code-block - style, and will warn when a subsequent code-block uses a different - style. +When this rule is turned on, the following file +`invalid.md` is **not** ok: -### definition-case +```markdown + -```md - - [example] http://example.com "Example Domain" +- [x] List item +- [X] List item +- [ ] List item +- [»] List item +``` - - ![Example] http://example.com/favicon.ico "Example image" +```text +4:4-4:5: Checked checkboxes should use `x` as a marker +6:4-6:5: Unchecked checkboxes should use ` ` as a marker ``` - Warn when definition labels are not lower-case. +When `{ unchecked: '!' }` is passed in, the following error is given: -### definition-spacing +```text +1:1: Invalid unchecked checkbox marker `!`: use either `'\t'`, or `' '` +``` -```md - - [example domain] http://example.com "Example Domain" +When `{ checked: '!' }` is passed in, the following error is given: - - ![example image] http://example.com/favicon.ico "Example image" +```text +1:1: Invalid checked checkbox marker `!`: use either `'x'`, or `'X'` ``` - Warn when consecutive white space is used in a definition. +## `checkbox-content-indent` + +Warn when list item checkboxes are followed by too much white-space. + +When this rule is turned on, the following file +`valid.md` is ok: -### emphasis-marker +```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: -```md - - *foo* - *bar* +```markdown +- [ ] List item ++ [x] List item +* [X] List item +- [ ] List item +``` - - _foo_ - _bar_ +```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 ``` - Warn for violating emphasis markers. +## `code-block-style` + +Warn when code-blocks do not adhere to a given style. - Options: `string`, either `'consistent'`, `'*'`, or `'_'`, - default: `'consistent'`. +Options: `string`, either `'consistent'`, `'fenced'`, or `'indented'`, +default: `'consistent'`. - The default value, `consistent`, detects the first used emphasis - style, and will warn when a subsequent emphasis uses a different - style. +The default value, `consistent`, detects the first used code-block +style, and will warn when a subsequent code-block uses a different +style. -### fenced-code-flag +When this rule is `'indented'`, the following file +`valid.md` is ok: -````md - - ```hello - world(); - ``` +```markdown + + + alpha(); + +Paragraph. + + bravo(); +``` - - Hello +When this rule is `'indented'`, the following file +`invalid.md` is **not** ok: - - ``` - world(); - ``` +````markdown + ``` + alpha(); + ``` - - ``` - world(); - ``` + Paragraph. - - ```hello - world(); - ``` + ``` + bravo(); + ``` ```` - Warn when fenced code blocks occur without language flag. +```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 + + + ``` + alpha(); + ``` - Options: `Array.` or `Object`. + Paragraph. - Providing an array, is a shortcut for just providing the `flags` - property on the object. + ``` + bravo(); + ``` +```` + +When this rule is `'fenced'`, the following file +`invalid.md` is **not** ok: - 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. +```markdown + alpha(); -### fenced-code-marker +Paragraph. + + bravo(); +``` -````md - - ```foo - bar(); - ``` +```text +1:1-1:13: Code blocks should be fenced +5:1-5:13: Code blocks should be fenced +``` - ``` - baz(); - ``` +When this rule is turned on, the following file +`invalid.md` is **not** ok: - - ~~~foo - bar(); - ~~~ +````markdown + - ~~~ - baz(); - ~~~ + alpha(); - - ~~~foo - bar(); - ~~~ + Paragraph. - ``` - baz(); - ``` + ``` + bravo(); + ``` ```` - Warn for violating fenced code markers. +```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'` +``` - Options: `string`, either ``'`'``, or `'~'`, default: `'consistent'`. +## `definition-case` - The default value, `consistent`, detects the first used fenced code - marker style, and will warn when a subsequent fenced code uses a - different style. +Warn when definition labels are not lower-case. -### file-extension +When this rule is turned on, the following file +`valid.md` is ok: -```md - Invalid (when `'md'`): readme.mkd, readme.markdown, etc. - Valid (when `'md'`): readme, readme.md +```markdown +[example]: http://example.com "Example Domain" ``` - Warn when the document’s extension differs from the given preferred - extension. +When this rule is turned on, the following file +`invalid.md` is **not** ok: - Does not warn when given documents have no file extensions (such as - `AUTHORS` or `LICENSE`). +```markdown +[Example]: http://example.com "Example Domain" +``` - Options: `string`, default: `'md'` — Expected file extension. +```text +1:1-1:47: Do not use upper-case characters in definition labels +``` -### final-definition +## `definition-spacing` -```md - - ... +Warn when consecutive white space is used in a definition. - [example] http://example.com "Example Domain" +When this rule is turned on, the following file +`valid.md` is ok: - - ... +```markdown +[example domain]: http://example.com "Example Domain" +``` - [example] http://example.com "Example Domain" +When this rule is turned on, the following file +`invalid.md` is **not** ok: - A trailing paragraph. +```markdown +[example domain]: http://example.com "Example Domain" ``` - Warn when definitions are not placed at the end of the file. +```text +1:1-1:57: Do not use consecutive white-space in definition labels +``` -### final-newline +## `emphasis-marker` - Warn when a newline at the end of a file is missing. +Warn for violating emphasis markers. - See [StackExchange](http://unix.stackexchange.com/questions/18743) for - why. +Options: `string`, either `'consistent'`, `'*'`, or `'_'`, +default: `'consistent'`. -### first-heading-level +The default value, `consistent`, detects the first used emphasis +style, and will warn when a subsequent emphasis uses a different +style. -```md - - # Foo +When this rule is `'*'`, the following file +`valid.md` is ok: - ## Bar +```markdown +*foo* +``` - - ## Foo +When this rule is `'*'`, the following file +`invalid.md` is **not** ok: - # Bar +```markdown +_foo_ ``` - Warn when the first heading has a level other than a specified value. +```text +1:1-1:6: Emphasis should use `*` as a marker +``` - Options: `number`, default: `1`. +When this rule is `'_'`, the following file +`valid.md` is ok: -### hard-break-spaces +```markdown +_foo_ +``` -```md - +When this rule is `'_'`, the following file +`invalid.md` is **not** ok: - - Lorem ipsum·· - dolor sit amet +```markdown +*foo* +``` - - Lorem ipsum··· - dolor sit amet. +```text +1:1-1:6: Emphasis should use `_` as a marker ``` - Warn when too many spaces are used to create a hard break. +When this rule is `'consistent'`, the following file +`invalid.md` is **not** ok: -### heading-increment +```markdown + -```md - - # Foo +*foo* +_bar_ +``` - ## Bar +```text +4:1-4:6: Emphasis should use `*` as a marker +``` - - # Foo +When `'invalid'` is passed in, the following error is given: - ### Bar +```text +1:1: Invalid emphasis marker `invalid`: use either `'consistent'`, `'*'`, or `'_'` ``` - Warn when headings increment with more than 1 level at a time. +## `fenced-code-flag` + +Warn when fenced code blocks occur without language flag. -### heading-style +Options: `Array.` or `Object`. -```md - - # Foo +Providing an array, is a shortcut for just providing the `flags` +property on the object. - ## Bar +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. - ### Baz +When this rule is turned on, the following file +`valid.md` is ok: - - # Foo # +````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(); + ``` +```` - ## Bar # +When this rule is `{ allowEmpty: false }`, the following file +`invalid.md` is **not** ok: - ### Baz ### +````markdown + ``` + alpha(); + ``` +```` - - Foo - === +```text +1:1-3:4: Missing code-language flag +``` - Bar - --- +When this rule is `[ 'alpha' ]`, the following file +`valid.md` is ok: - ### Baz +````markdown + ```alpha + bravo(); + ``` +```` - - Foo - === +When this rule is `[ 'charlie' ]`, the following file +`invalid.md` is **not** ok: - ## Bar +````markdown + ```alpha + bravo(); + ``` +```` - ### Baz ### +```text +1:1-3:4: Invalid code-language flag ``` - Warn when a heading does not conform to a given style. +## `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. - Options: `string`, either `'consistent'`, `'atx'`, `'atx-closed'`, - or `'setext'`, default: `'consistent'`. +When this rule is ``'`'``, the following file +`valid.md` is ok: - The default value, `consistent`, detects the first used heading - style, and will warn when a subsequent heading uses a different - style. +````markdown + -### link-title-style + ```alpha + bravo(); + ``` -```md - - [Example](http://example.com "Example Domain") - [Example](http://example.com "Example Domain") + ``` + charlie(); + ``` +```` + +When this rule is `'~'`, the following file +`valid.md` is ok: - - [Example](http://example.com 'Example Domain') - [Example](http://example.com 'Example Domain') +```markdown + - - [Example](http://example.com (Example Domain)) - [Example](http://example.com (Example Domain)) + ~~~alpha + bravo(); + ~~~ - - [Example](http://example.com "Example Domain") - [Example](http://example.com 'Example Domain') - [Example](http://example.com (Example Domain)) + ~~~ + charlie(); + ~~~ ``` - Warn when link and definition titles occur with incorrect quotes. +When this rule is turned on, the following file +`invalid.md` is **not** ok: - Options: `string`, either `'consistent'`, `'"'`, `'\''`, or - `'()'`, default: `'consistent'`. +````markdown + - The default value, `consistent`, detects the first used quote - style, and will warn when a subsequent titles use a different - style. + ```alpha + bravo(); + ``` + + ~~~ + charlie(); + ~~~ +```` -### list-item-bullet-indent +```text +7:1-9:4: Fenced code should use ` as a marker +``` -```md - - * List item - * List item +When `'!'` is passed in, the following error is given: - - * List item - * List item +```text +1:1: Invalid fenced code marker `!`: use either `'consistent'`, `` '`' ``, or `'~'` ``` - Warn when list item bullets are indented. +## `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. -### list-item-content-indent +When this rule is turned on, the following file +`readme.md` is ok: -```md - - * List item +```markdown - * Nested list item indented by 4 spaces +``` + +When this rule is turned on, the following file +`readme` is ok: + +```markdown + +``` - - * List item +When turned on is passed in, the following error is given: - * Nested list item indented by 3 spaces +```text +1:1: Invalid extension: use `md` ``` - Warn when the content of a list item has mixed indentation. +When this rule is `'mkd'`, the following file +`readme.mkd` is ok: -### list-item-indent +```markdown -```md - - * List - item. +``` - 11. List - item. +## `final-definition` - - * List item. +Warn when definitions are not placed at the end of the file. - 11. List item +When this rule is turned on, the following file +`valid.md` is ok: - * List - item. +```markdown +Paragraph. - 11. List - item. +[example]: http://example.com "Example Domain" +``` - - * List item. +When this rule is turned on, the following file +`invalid.md` is **not** ok: - 11. List item +```markdown +Paragraph. - * List - item. +[example]: http://example.com "Example Domain" - 11. List - item. +Another paragraph. ``` - Warn when the spacing between a list item’s bullet and its content - violates a given style. +```text +3:1-3:47: Move definitions to the end of the file (after the node at line `5`) +``` + +## `final-newline` + +Warn when a newline at the end of a file is missing. + +See [StackExchange](http://unix.stackexchange.com/questions/18743) for +why. - Options: `string`, either `'tab-size'`, `'mixed'`, or `'space'`, - default: `'tab-size'`. +## `first-heading-level` -### list-item-spacing +Warn when the first heading has a level other than a specified value. -```md - - - Wrapped - item +Options: `number`, default: `1`. - - item 2 +When this rule is `1`, the following file +`valid.md` is ok: - - item 3 +```markdown + - - - item 1 - - item 2 - - item 3 +# Alpha - - - Wrapped - item - - item 2 - - item 3 +Paragraph. +``` + +When this rule is `1`, the following file +`invalid.md` is **not** ok: - - - item 1 +```markdown + - - item 2 +## Bravo - - item 3 +Paragraph. ``` - Warn when list looseness is incorrect, such as being tight - when it should be loose, and vice versa. +```text +3:1-3:9: First heading level should be `1` +``` -### maximum-heading-length +When this rule is `2`, the following file +`valid.md` is ok: -```md - - # Alpha bravo charlie delta echo - # ![Alpha bravo charlie delta echo](http://example.com/nato.png) +```markdown +## Bravo - - # Alpha bravo charlie delta echo foxtrot +Paragraph. ``` - Warn when headings are too long. +When this rule is `2`, the following file +`invalid.md` is **not** ok: + +```markdown +# Bravo - Options: `number`, default: `60`. +Paragraph. +``` + +```text +1:1-1:8: First heading level should be `2` +``` - Ignores markdown syntax, only checks the plain text content. +## `hard-break-spaces` -### maximum-line-length +Warn when too many spaces are used to create a hard break. -```md - - Alpha bravo charlie delta echo. +When this rule is turned on, the following file +`valid.md` is ok: - Alpha bravo charlie delta echo [foxtrot](./foxtrot.html). +```markdown + - # Alpha bravo charlie delta echo foxtrot golf hotel. +Lorem ipsum·· +dolor sit amet +``` - # Alpha bravo charlie delta echo foxtrot golf hotel. +When this rule is turned on, the following file +`invalid.md` is **not** ok: - | A | B | C | D | E | F | F | H | - | ----- | ----- | ------- | ----- | ---- | ------- | ---- | ----- | - | Alpha | bravo | charlie | delta | echo | foxtrot | golf | hotel | +```markdown + - - Alpha bravo charlie delta echo foxtrot golf. +Lorem ipsum··· +dolor sit amet. +``` - Alpha bravo charlie delta echo [foxtrot](./foxtrot.html) golf. +```text +3:12-4:1: Use two spaces for hard line breaks ``` - Warn when lines are too long. +## `heading-increment` + +Warn when headings increment with more than 1 level at a time. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +# Alpha - Options: `number`, default: `80`. +## Bravo +``` - Ignores nodes which cannot be wrapped, such as heasings, tables, - code, link, images, and definitions. +When this rule is turned on, the following file +`invalid.md` is **not** ok: -### no-auto-link-without-protocol +```markdown +# Charlie -```md - - - +### Delta +``` - - - +```text +3:1-3:10: Heading levels should increment by one level at a time ``` - Warn for angle-bracketed links without protocol. +## `heading-style` + +Warn when a heading does not conform to a given style. + +Options: `string`, either `'consistent'`, `'atx'`, `'atx-closed'`, +or `'setext'`, default: `'consistent'`. -### no-blockquote-without-caret +The default value, `consistent`, detects the first used heading +style, and will warn when a subsequent heading uses a different +style. -```md - - > Foo... - > - > ...Bar. +When this rule is `'atx'`, the following file +`valid.md` is ok: - - > Foo... +```markdown + - > ...Bar. +# Alpha + +## Bravo + +### Charlie ``` - Warn when blank lines without carets are found in a blockquote. +When this rule is `'atx-closed'`, the following file +`valid.md` is ok: + +```markdown + + +# Delta ## -### no-consecutive-blank-lines +## Echo ## -```md - - Foo... +### Foxtrot ### +``` + +When this rule is `'setext'`, the following file +`valid.md` is ok: - ...Bar. +```markdown + - - Foo... +Golf +==== +Hotel +----- - ...Bar. +### India ``` - Warn for too many consecutive blank lines. Knows about the extra line - needed between a list and indented code, and two lists. +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown + + +Juliett +======= -### no-duplicate-definitions +## Kilo -```md - - [foo]: bar - [baz]: qux +### Lima ### +``` - - [foo]: bar - [foo]: qux +```text +6:1-6:8: Headings should use setext +8:1-8:13: Headings should use setext ``` - Warn when duplicate definitions are found. +## `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. -### no-duplicate-headings +When this rule is `'"'`, the following file +`valid.md` is ok: -```md - - # Foo +```markdown + - ## Bar +[Example](http://example.com "Example Domain") +[Example](http://example.com "Example Domain") +``` - - # Foo +When this rule is `'\''`, the following file +`valid.md` is ok: - ## Foo +```markdown + - ## [Foo](http://foo.com/bar) +[Example](http://example.com 'Example Domain') +[Example](http://example.com 'Example Domain') ``` - Warn when duplicate headings are found. +When this rule is `'()'`, the following file +`valid.md` is ok: + +```markdown + -### no-emphasis-as-heading +[Example](http://example.com (Example Domain) ) +[Example](http://example.com (Example Domain) ) +``` -```md - - # Foo +When this rule is `'()'`, the following file +`invalid.md` is **not** ok: - Bar. +```markdown + - - *Foo* +[Example](http://example.com (Example Domain)) +[Example](http://example.com 'Example Domain') +``` - Bar. +```text +4:46: Titles should use `()` as a quote ``` - Warn when emphasis (including strong), instead of a heading, introduces - a paragraph. +When this rule is turned on, the following file +`invalid.md` is **not** ok: -### no-file-name-articles +```markdown + -```md - Valid: article.md - Invalid: an-article.md, a-article.md, , the-article.md +[Example](http://example.com "Example Domain") +[Example](http://example.com#without-title) +[Example](http://example.com 'Example Domain') ``` - Warn when file name start with an article. +```text +5:46: Titles should use `"` as a quote +``` -### no-file-name-consecutive-dashes +When `'.'` is passed in, the following error is given: -```md - Invalid: docs/plug--ins.md - Valid: docs/plug-ins.md +```text +1:1: Invalid link title style marker `.`: use either `'consistent'`, `'"'`, `'\''`, or `'()'` ``` - Warn when file names contain consecutive dashes. +## `list-item-bullet-indent` + +Warn when list item bullets are indented. -### no-file-name-irregular-characters +When this rule is turned on, the following file +`valid.md` is ok: -```md - Invalid: plug_ins.md, plug ins.md. - Valid: plug-ins.md, plugins.md. +```markdown +Paragraph. + +* List item +* List item ``` - Warn when file names contain irregular characters: characters other - than alpha-numericals, dashes, and dots (full-stops). +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +Paragraph. - Options: `RegExp` or `string`, default: `'\\.a-zA-Z0-9-'`. + * List item + * List item +``` + +```text +3:3: Incorrect indentation before bullet: remove 1 space +4:3: Incorrect indentation before bullet: remove 1 space +``` - If a string is given, it will be wrapped in - `new RegExp('[^' + preferred + ']')`. +## `list-item-content-indent` - Any match by the wrapped or given expressions triggers a - warning. +Warn when the content of a list item has mixed indentation. -### no-file-name-mixed-case +When this rule is turned on, the following file +`valid.md` is ok: -```md - Invalid: Readme.md - Valid: README.md, readme.md +```markdown +1. [x] Alpha + 1. Bravo ``` - Warn when a file name uses mixed case: both upper- and lower case - characters. +When this rule is turned on, the following file +`invalid.md` is **not** ok: -### no-file-name-outer-dashes +```markdown +1. [x] Charlie + 1. Delta +``` -```md - Invalid: -readme.md, readme-.md - Valid: readme.md +```text +2:5: Don’t use mixed indentation for children, remove 1 space ``` - Warn when file names contain initial or final dashes. +## `list-item-indent` -### no-heading-content-indent +Warn when the spacing between a list item’s bullet and its content +violates a given style. -```md - - - #··Foo +Options: `string`, either `'tab-size'`, `'mixed'`, or `'space'`, +default: `'tab-size'`. - ## Bar··## +When this rule is `'tab-size'`, the following file +`valid.md` is ok: - ##··Baz +```markdown +* List + item. + +Paragraph. + +11. List + item. - - #·Foo +Paragraph. - ## Bar·## +* List + item. - ##·Baz +* List + item. ``` - Warn when a heading’s content is indented. +When this rule is `'mixed'`, the following file +`valid.md` is ok: + +```markdown +* List item. + +Paragraph. + +11. List item + +Paragraph. + +* List + item. + +* List + item. +``` -### no-heading-indent +When this rule is `'space'`, the following file +`valid.md` is ok: -```md - - - ···# Hello world +```markdown +* List item. - ·Foo - ----- +Paragraph. - ·# Hello world # +11. List item - ···Bar - ===== +Paragraph. - - # Hello world +* List + item. - Foo - ----- +* List + item. +``` - # Hello world # +When `'invalid'` is passed in, the following error is given: - Bar - ===== +```text +1:1: Invalid list-item indent style `invalid`: use either `'tab-size'`, `'space'`, or `'mixed'` ``` - Warn when a heading is indented. +## `list-item-spacing` -### no-heading-punctuation +Warn when list looseness is incorrect, such as being tight +when it should be loose, and vice versa. -```md - - # Hello: +When this rule is turned on, the following file +`valid.md` is ok: - # Hello? +```markdown +A tight list: - # Hello! +- item 1 +- item 2 +- item 3 - # Hello, +A loose list: - # Hello; +- Wrapped + item - - # Hello +- item 2 + +- item 3 ``` - Warn when a heading ends with a a group of characters. - Defaults to `'.,;:!?'`. +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +A tight list: - Options: `string`, default: `'.,;:!?'`. +- Wrapped + item +- item 2 +- item 3 - Note that these are added to a regex, in a group (`'[' + char + ']'`), - be careful for escapes and dashes. +A loose list: -### no-html +- item 1 -```md - -

Hello

+- item 2 + +- item 3 +``` - - # Hello +```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 ``` - Warn when HTML nodes are used. +## `maximum-heading-length` - Ignores comments, because they are used by this tool, remark, and - because markdown doesn’t have native comments. +Warn when headings are too long. -### no-inline-padding +Options: `number`, default: `60`. -```md - - * Hello *, [ world ](http://foo.bar/baz) +Ignores markdown syntax, only checks the plain text content. - - *Hello*, [world](http://foo.bar/baz) +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) ``` - Warn when inline nodes are padded with spaces between markers and - content. +## `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. + +When this rule is `80`, the following file +`valid.md` is ok: + +```markdown +This line is simply not toooooooooooooooooooooooooooooooooooooooooooo +long. + +This is also fine: + + + +[foo](http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables) + + - Warns for emphasis, strong, delete, image, and link. +![foo](http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables) -### no-literal-urls +| An | exception | is | line | length | in | long | tables | because | those | can’t | just | +| -- | --------- | -- | ---- | ------ | -- | ---- | ------ | ------- | ----- | ----- | ---- | +| be | helped | | | | | | | | | | . | -```md - - http://foo.bar/baz +The following is also fine, because there is no white-space. - - +. + +In addition, definitions are also fine: + +[foo]: ``` - Warn when URLs without angle-brackets are used. +When this rule is `80`, the following file +`invalid.md` is **not** ok: -### no-missing-blank-lines +```markdown +This line is simply not tooooooooooooooooooooooooooooooooooooooooooooooooooooooo +long. -```md - - # Foo - ## Bar +Just like thiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis one. - - # Foo +And this one is also very wrong: because the link starts aaaaaaafter the column: + + and such. +``` - ## Bar +```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 ``` - Warn for missing blank lines before a block node. +## `no-auto-link-without-protocol` -### no-multiple-toplevel-headings +Warn for angle-bracketed links without protocol. -```md - - # Foo +When this rule is turned on, the following file +`valid.md` is ok: - # Bar +```markdown + + +``` - - # Foo +When this rule is turned on, the following file +`invalid.md` is **not** ok: - ## Bar +```markdown + + ``` - Warn when multiple top-level headings are used. +```text +2:1-2:14: All automatic links must start with a protocol +``` - Options: `number`, default: `1`. +## `no-blockquote-without-caret` -### no-shell-dollars +Warn when blank lines without carets are found in a blockquote. -````md - - ```bash - $ echo a - $ echo a > file - ``` +When this rule is turned on, the following file +`valid.md` is ok: - - ```sh - echo a - echo a > file - ``` +```markdown +> Foo... +> +> ...Bar. +``` - - ```zsh - $ echo a - a - $ echo a > file - ``` -```` +When this rule is turned on, the following file +`invalid.md` is **not** ok: - Warn when shell code is prefixed by dollar-characters. +```markdown +> Foo... - Ignored indented code blocks and fenced code blocks without language - flag. +> ...Bar. +``` + +```text +2:1: Missing caret in blockquote +``` -### no-shortcut-reference-image +## `no-consecutive-blank-lines` -```md - - ![foo] +Warn for too many consecutive blank lines. Knows about the extra line +needed between a list and indented code, and two lists. - [foo]: http://foo.bar/baz.png +When this rule is turned on, the following file +`valid.md` is ok: - - ![foo][] +```markdown +Foo... - [foo]: http://foo.bar/baz.png +...Bar. ``` - Warn when shortcut reference images are used. +When this rule is turned on, the following file +`valid-for-code.md` is ok: + +```markdown +Paragraph. + +* List + + + bravo(); +``` -### no-shortcut-reference-link +When this rule is turned on, the following file +`invalid.md` is **not** ok: -```md - - [foo] +```markdown +Foo... - [foo]: http://foo.bar/baz - - [foo][] +...Bar. +``` - [foo]: http://foo.bar/baz +```text +4:1: Remove 1 line before node ``` - Warn when shortcut reference links are used. +## `no-duplicate-definitions` + +Warn when duplicate definitions are found. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +[foo]: bar +[baz]: qux +``` -### no-table-indentation +When this rule is turned on, the following file +`invalid.md` is **not** ok: -```md - - | A | B | - | ----- | ----- | - | Alpha | Bravo | +```markdown +[foo]: bar +[foo]: qux +``` - - | A | B | - | ----- | ----- | - | Alpha | Bravo | +```text +2:1-2:11: Do not use definitions with the same identifier (1:1) ``` - Warn when tables are indented. +## `no-duplicate-headings` + +Warn when duplicate headings are found. + +When this rule is turned on, the following file +`valid.md` is ok: -### no-tabs +```markdown +# Foo -```md - - - Foo»Bar +## Bar +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: - »···Foo +```markdown +# Foo - - Foo Bar +## Foo + +## [Foo](http://foo.com/bar) +``` - Foo +```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) ``` - Warn when hard-tabs instead of spaces +## `no-emphasis-as-heading` + +Warn when emphasis (including strong), instead of a heading, introduces +a paragraph. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +# Foo + +Bar. +``` -### no-undefined-references +When this rule is turned on, the following file +`invalid.md` is **not** ok: -```md - - [foo][] +```markdown +*Foo* - [foo]: https://example.com +Bar. +``` - - [bar][] +```text +1:1-1:6: Don’t use emphasis to introduce a section, use a heading ``` - Warn when references to undefined definitions are found. +## `no-file-name-articles` -### no-unused-definitions +Warn when file name start with an article. -```md - - [foo][] +When this rule is turned on, the following file +`title.md` is ok: - [foo]: https://example.com +```markdown - - [bar]: https://example.com ``` - Warn when unused definitions are found. +When turned on is passed in, the following error is given: -### ordered-list-marker-style +```text +1:1: Do not start file names with `a` +``` -```md - - 1. Foo +When turned on is passed in, the following error is given: - 2. Bar +```text +1:1: Do not start file names with `the` +``` - - 1) Foo +When turned on is passed in, the following error is given: - 2) Bar +```text +1:1: Do not start file names with `an` ``` - Warn when the list-item marker style of ordered lists violate a given - style. +## `no-file-name-consecutive-dashes` + +Warn when file names contain consecutive dashes. + +When this rule is turned on, the following file +`plug-ins.md` is ok: + +```markdown + +``` - Options: `string`, either `'consistent'`, `'.'`, or `')'`, - default: `'consistent'`. +When turned on is passed in, the following error is given: - Note that `)` is only supported in CommonMark. +```text +1:1: Do not use consecutive dashes in a file name +``` - The default value, `consistent`, detects the first used list - style, and will warn when a subsequent list uses a different - style. +## `no-file-name-irregular-characters` -### ordered-list-marker-value +Warn when file names contain irregular characters: characters other +than alpha-numericals, dashes, and dots (full-stops). -```md - - 1. Foo - 1. Bar - 1. Baz +Options: `RegExp` or `string`, default: `'\\.a-zA-Z0-9-'`. - 1. Alpha - 1. Bravo - 1. Charlie +If a string is given, it will be wrapped in +`new RegExp('[^' + preferred + ']')`. - - 1. Foo - 1. Bar - 1. Baz +Any match by the wrapped or given expressions triggers a +warning. - 3. Alpha - 3. Bravo - 3. Charlie +When this rule is turned on, the following file +`plug-ins.md` is ok: - - 1. Foo - 2. Bar - 3. Baz +```markdown - 3. Alpha - 4. Bravo - 5. Charlie ``` - Warn when the list-item marker values of ordered lists violate a - given style. +When this rule is turned on, the following file +`plugins.md` is ok: - Options: `string`, either `'single'`, `'one'`, or `'ordered'`, - default: `'ordered'`. +```markdown + +``` - When set to `'ordered'`, list-item bullets should increment by one, - relative to the starting point. When set to `'single'`, bullets should - be the same as the relative starting point. When set to `'one'`, bullets - should always be `1`. +When turned on is passed in, the following error is given: -### rule-style +```text +1:1: Do not use `_` in a file name +``` -```md - - * * * +When turned on is passed in, the following error is given: - * * * +```text +1:1: Do not use ` ` in a file name +``` - - _______ +When `'\\.a-z0-9'` is passed in, the following error is given: - _______ +```text +1:1: Do not use `R` in a file name ``` - Warn when the horizontal rules violate a given or detected style. +## `no-file-name-mixed-case` + +Warn when a file name uses mixed case: both upper- and lower case +characters. + +When this rule is turned on, the following file +`README.md` is ok: - Note that horizontal rules are also called “thematic break”. +```markdown - Options: `string`, either a valid markdown rule, or `consistent`, - default: `'consistent'`. +``` + +When this rule is turned on, the following file +`readme.md` is ok: -### strong-marker +```markdown + +``` -```md - - **foo** - **bar** +When turned on is passed in, the following error is given: - - __foo__ - __bar__ +```text +1:1: Do not mix casing in file names ``` - Warn for violating strong markers. +## `no-file-name-outer-dashes` - Options: `string`, either `'consistent'`, `'*'`, or `'_'`, - default: `'consistent'`. +Warn when file names contain initial or final dashes. - The default value, `consistent`, detects the first used strong - style, and will warn when a subsequent strong uses a different - style. +When this rule is turned on, the following file +`readme.md` is ok: -### table-cell-padding +```markdown -```md - - | A | B | - | ----- | ----- | - | Alpha | Bravo | +``` + +When turned on is passed in, the following error is given: + +```text +1:1: Do not use initial or final dashes in a file name +``` - - |A |B | - |-----|-----| - |Alpha|Bravo| +When turned on is passed in, the following error is given: - - | A | B | - | -----| -----| - | Alpha| Bravo| +```text +1:1: Do not use initial or final dashes in a file name ``` - Warn when table cells are incorrectly padded. +## `no-heading-content-indent` - Options: `string`, either `'consistent'`, `'padded'`, or `'compact'`, - default: `'consistent'`. +Warn when a heading’s content is indented. - The default value, `consistent`, detects the first used cell padding - style, and will warn when a subsequent cells uses a different - style. +When this rule is turned on, the following file +`valid.md` is ok: -### table-pipe-alignment +```markdown + -```md - - | A | B | - | ----- | ----- | - | Alpha | Bravo | +#·Foo - - | A | B | - | -- | -- | - | Alpha | Bravo | +## Bar·## + + ##·Baz ``` - Warn when table pipes are not aligned. +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown + -### table-pipes +#··Foo -```md - - | A | B | - | ----- | ----- | - | Alpha | Bravo | +## Bar··## + + ##··Baz +``` - - A | B - ----- | ----- - Alpha | Bravo +```text +3:4: Remove 1 space before this heading’s content +5:7: Remove 1 space after this heading’s content +7:7: Remove 1 space before this heading’s content ``` - Warn when table rows are not fenced with pipes. +When this rule is turned on, the following file +`empty-heading.md` is ok: -### unordered-list-marker-style +```markdown +#·· +``` -```md - - - Foo - - Bar +When this rule is turned on, the following file +`tight.md` is **not** ok: - - * Foo - * Bar +```markdown +In pedantic mode, headings without spacing can also be detected: - - + Foo - + Bar +##No spacing left, too much right··## +``` - - + Foo - - Bar +```text +3:3: Add 1 space before this heading’s content +3:34: Remove 1 space after this heading’s content ``` - Warn when the list-item marker style of unordered lists violate a given - style. +## `no-heading-indent` + +Warn when a heading is indented. + +When this rule is turned on, the following file +`valid.md` is ok: - Options: `string`, either `'consistent'`, `'-'`, `'*'`, or `'*'`, - default: `'consistent'`. +```markdown + - The default value, `consistent`, detects the first used list - style, and will warn when a subsequent list uses a different - style. +#·Hello world + +Foo +----- + +#·Hello world·# + +Bar +===== +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown + + +···# Hello world + +·Foo +----- + +·# Hello world # + +···Bar +===== +``` + +```text +3:4: Remove 3 spaces before this heading +5:2: Remove 1 space before this heading +8:2: Remove 1 space before this heading +10:4: Remove 3 spaces before this heading +``` + +## `no-heading-punctuation` + +Warn when a heading ends with a a group of characters. +Defaults to `'.,;:!?'`. + +Options: `string`, default: `'.,;:!?'`. + +Note that these are added to a regex, in a group (`'[' + char + ']'`), +be careful for escapes and dashes. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +# Hello +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +# Hello: + +# Hello? + +# Hello! + +# Hello, + +# Hello; +``` + +```text +1:1-1:9: Don’t add a trailing `:` to headings +3:1-3:9: Don’t add a trailing `?` to headings +5:1-5:9: Don’t add a trailing `!` to headings +7:1-7:9: Don’t add a trailing `,` to headings +9:1-9:9: Don’t add a trailing `;` to headings +``` + +When this rule is `',;:!?'`, the following file +`valid.md` is ok: + +```markdown +# Hello... +``` + +## `no-html` + +Warn when HTML nodes are used. + +Ignores comments, because they are used by this tool, remark, and +because markdown doesn’t have native comments. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +# Hello + + +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +

Hello

+``` + +```text +1:1-1:15: Do not use HTML in markdown +``` + +## `no-inline-padding` + +Warn when inline nodes are padded with spaces between markers and +content. + +Warns for emphasis, strong, delete, image, and link. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +Alpha, *bravo*, _charlie_, [delta](http://echo.fox/trot) +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +Alpha, * bravo *, _ charlie _, [ delta ](http://echo.fox/trot) +``` + +```text +1:8-1:17: Don’t pad `emphasis` with inner spaces +1:19-1:30: Don’t pad `emphasis` with inner spaces +1:32-1:63: Don’t pad `link` with inner spaces +``` + +## `no-literal-urls` + +Warn when URLs without angle-brackets are used. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown + + +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +http://foo.bar/baz + +mailto:qux@quux.com +``` + +```text +1:1-1:19: Don’t use literal URLs without angle brackets +``` + +## `no-missing-blank-lines` + +Warn for missing blank lines before a block node. + +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-2:7: Missing blank line before block node +``` + +## `no-multiple-toplevel-headings` + +Warn when multiple top-level headings are used. + +Options: `number`, default: `1`. + +When this rule is `1`, the following file +`valid.md` is ok: + +```markdown +# Foo + +## Bar +``` + +When this rule is `1`, the following file +`invalid.md` is **not** ok: + +```markdown +# Foo + +# Bar +``` + +```text +3:1-3:6: Don’t use multiple top level headings (3:1) +``` + +## `no-shell-dollars` + +Warn when shell code is prefixed by dollar-characters. + +Ignored indented code blocks and fenced code blocks without language +flag. + +When this rule is turned on, the following file +`valid.md` is ok: + +````markdown + ```sh + echo a + echo a > file + ``` + + ```zsh + $ echo a + a + $ echo a > file + ``` +```` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +````markdown + ```bash + $ echo a + $ echo a > file + ``` +```` + +```text +1:1-4:4: Do not use dollar signs before shell-commands +``` + +## `no-shortcut-reference-image` + +Warn when shortcut reference images are used. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +![foo][] + +[foo]: http://foo.bar/baz.png +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +![foo] + +[foo]: http://foo.bar/baz.png +``` + +```text +1:1-1:7: Use the trailing [] on reference images +``` + +## `no-shortcut-reference-link` + +Warn when shortcut reference links are used. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +[foo][] + +[foo]: http://foo.bar/baz +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +[foo] + +[foo]: http://foo.bar/baz +``` + +```text +1:1-1:6: Use the trailing [] on reference links +``` + +## `no-table-indentation` + +Warn when tables are indented. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +Paragraph. + +| A | B | +| ----- | ----- | +| Alpha | Bravo | +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +Paragraph. + + | A | B | + | ----- | ----- | + | Alpha | Bravo | +``` + +```text +3:1-3:21: Do not indent table rows +5:1-5:21: Do not indent table rows +``` + +## `no-tabs` + +Warn when hard-tabs instead of spaces + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +Foo Bar + + Foo +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown + + +»Here's one before a code block. + +Here's a tab:», and here is another:». + +And this is in `inline»code`. + +>»This is in a block quote. + +*»And... + +»1.»in a list. + +And this is a tab as the last character.» +``` + +```text +3:1: Use spaces instead of hard-tabs +5:14: Use spaces instead of hard-tabs +5:37: Use spaces instead of hard-tabs +7:23: Use spaces instead of hard-tabs +9:2: Use spaces instead of hard-tabs +11:2: Use spaces instead of hard-tabs +13:1: Use spaces instead of hard-tabs +13:4: Use spaces instead of hard-tabs +15:41: Use spaces instead of hard-tabs +``` + +## `no-undefined-references` + +Warn when references to undefined definitions are found. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +[foo][] + +[foo]: https://example.com +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +[bar][] +``` + +```text +1:1-1:8: Found reference to undefined definition +``` + +## `no-unused-definitions` + +Warn when unused definitions are found. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +[foo][] + +[foo]: https://example.com +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +[bar]: https://example.com +``` + +```text +1:1-1:27: Found unused definition +``` + +## `ordered-list-marker-style` + +Warn when the list-item marker style of ordered lists violate a given +style. + +Options: `string`, either `'consistent'`, `'.'`, or `')'`, +default: `'consistent'`. + +Note that `)` is only supported in CommonMark. + +The default value, `consistent`, detects the first used list +style, and will warn when a subsequent list uses a different +style. + +When this rule is `'.'`, the following file +`valid.md` is ok: + +```markdown + + +1. Foo + +2. Bar +``` + +When this rule is `')'`, the following file +`valid.md` is ok: + +```markdown + + +1) Foo + +2) Bar +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +1. Foo + +2) Bar +``` + +```text +3:1-3:8: Marker style should be `.` +``` + +When `'!'` is passed in, the following error is given: + +```text +1:1: Invalid ordered list-item marker style `!`: use either `'.'` or `')'` +``` + +## `ordered-list-marker-value` + +Warn when the list-item marker values of ordered lists violate a +given style. + +Options: `string`, either `'single'`, `'one'`, or `'ordered'`, +default: `'ordered'`. + +When set to `'ordered'`, list-item bullets should increment by one, +relative to the starting point. When set to `'single'`, bullets should +be the same as the relative starting point. When set to `'one'`, bullets +should always be `1`. + +When this rule is `'one'`, the following file +`valid.md` is ok: + +```markdown +1. Foo +1. Bar +1. Baz + +Paragraph. + +1. Alpha +1. Bravo +1. Charlie +``` + +When this rule is `'one'`, the following file +`invalid.md` is **not** ok: + +```markdown +1. Foo +2. Bar +``` + +```text +2:1-2:8: Marker should be `1`, was `2` +``` + +When this rule is `'single'`, the following file +`valid.md` is ok: + +```markdown +1. Foo +1. Bar +1. Baz + +Paragraph. + +3. Alpha +3. Bravo +3. Charlie +``` + +When this rule is `'ordered'`, the following file +`valid.md` is ok: + +```markdown +1. Foo +2. Bar +3. Baz + +Paragraph. + +3. Alpha +4. Bravo +5. Charlie +``` + +When this rule is `'ordered'`, the following file +`invalid.md` is **not** ok: + +```markdown +1. Foo +1. Bar +``` + +```text +2:1-2:8: Marker should be `2`, was `1` +``` + +When `'invalid'` is passed in, the following error is given: + +```text +1:1: Invalid ordered list-item marker value `invalid`: use either `'ordered'` or `'one'` +``` + +## `rule-style` + +Warn when the horizontal rules violate a given or detected style. + +Note that horizontal rules are also called “thematic break”. + +Options: `string`, either a valid markdown rule, or `consistent`, +default: `'consistent'`. + +When this rule is `'* * *'`, the following file +`valid.md` is ok: + +```markdown + + +* * * + +* * * +``` + +When this rule is `'_______'`, the following file +`valid.md` is ok: + +```markdown + + +_______ + +_______ +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown + + +*** + +* * * +``` + +```text +5:1-5:6: Rules should use `***` +``` + +When `'!!!'` is passed in, the following error is given: + +```text +1:1: Invalid preferred rule-style: provide a valid markdown rule, or `'consistent'` +``` + +## `strong-marker` + +Warn for violating strong markers. + +Options: `string`, either `'consistent'`, `'*'`, or `'_'`, +default: `'consistent'`. + +The default value, `consistent`, detects the first used strong +style, and will warn when a subsequent strong uses a different +style. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +**foo** and **bar**. +``` + +When this rule is turned on, the following file +`also-valid.md` is ok: + +```markdown +__foo__ and __bar__. +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +**foo** and __bar__. +``` + +```text +1:13-1:20: Strong 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 +`valid.md` is ok: + +```markdown +__foo__. +``` + +When `'!'` is passed in, the following error is given: + +```text +1:1: Invalid strong marker `!`: use either `'consistent'`, `'*'`, or `'_'` +``` + +## `table-cell-padding` + +Warn when table cells are incorrectly padded. + +Options: `string`, either `'consistent'`, `'padded'`, or `'compact'`, +default: `'consistent'`. + +The default value, `consistent`, detects the first used cell padding +style, and will warn when a subsequent cells uses a different +style. + +When this rule is `'padded'`, the following file +`valid.md` is ok: + +```markdown + + +| A | B | +| ----- | ----- | +| Alpha | Bravo | +``` + +When this rule is `'compact'`, the following file +`valid.md` is ok: + +```markdown + + +|A |B | +|-----|-----| +|Alpha|Bravo| +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown + + +| A | B | +| -----| -----| +| Alpha| Bravo| +``` + +```text +3:5: Cell should be padded, isn’t +3:9: Cell should be padded, isn’t +3:16: Cell should be padded, isn’t +``` + +When `'invalid'` is passed in, the following error is given: + +```text +1:1: Invalid table-cell-padding style `invalid` +``` + +## `table-pipe-alignment` + +Warn when table pipes are not aligned. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +| A | B | +| ----- | ----- | +| Alpha | Bravo | +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +| A | B | +| -- | -- | +| Alpha | Bravo | +``` + +```text +3:9-3:10: Misaligned table fence +3:17-3:18: Misaligned table fence +``` + +## `table-pipes` + +Warn when table rows are not fenced with pipes. + +When this rule is turned on, the following file +`valid.md` is ok: + +```markdown +| A | B | +| ----- | ----- | +| Alpha | Bravo | +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +A | B +----- | ----- +Alpha | Bravo +``` + +```text +1:1: Missing initial pipe in table fence +1:10: Missing final pipe in table fence +3:1: Missing initial pipe in table fence +3:14: Missing final pipe in table fence +``` + +## `unordered-list-marker-style` + +Warn when the list-item marker style of unordered lists violate a given +style. + +Options: `string`, either `'consistent'`, `'-'`, `'*'`, or `'*'`, +default: `'consistent'`. + +The default value, `consistent`, detects the first used list +style, and will warn when a subsequent list uses a different +style. + +When this rule is `'*'`, the following file +`valid.md` is ok: + +```markdown +* Foo +``` + +When this rule is `'-'`, the following file +`valid.md` is ok: + +```markdown +- Foo +``` + +When this rule is `'+'`, the following file +`valid.md` is ok: + +```markdown ++ Foo +``` + +When this rule is turned on, the following file +`invalid.md` is **not** ok: + +```markdown +* Foo +- Bar ++ Baz +``` + +```text +2:1-2:6: Marker style should be `*` +3:1-3:6: Marker style should be `*` +``` + +When `'!'` is passed in, the following error is given: + +```text +1:1: Invalid unordered list-item marker style `!`: use either `'-'`, `'*'`, or `'+'` +``` diff --git a/history.md b/history.md index bce0174b..e34b4386 100644 --- a/history.md +++ b/history.md @@ -124,68 +124,3 @@ 1.0.0 / 2015-08-17 ================== - -* Update dependencies ([`4936d35`](https://github.com/wooorm/remark-lint/commit/4936d35)) - -0.4.5 / 2015-08-08 -================== - -* Fix typo in definition-case warning ([`490ac16`](https://github.com/wooorm/remark-lint/commit/490ac16)) - -0.4.4 / 2015-08-05 -================== - -* Remove maximum-line-length warnings on definitions ([`1119ca8`](https://github.com/wooorm/remark-lint/commit/1119ca8)) -* Add `linter-markdown` to `readme.md` ([`7de8847`](https://github.com/wooorm/remark-lint/commit/7de8847)) - -0.4.3 / 2015-08-04 -================== - -* Fix block-quotes without children ([`a9aaff7`](https://github.com/wooorm/remark-lint/commit/a9aaff7)) -* Update mdast dev-dependency ([`34df79c`](https://github.com/wooorm/remark-lint/commit/34df79c)) -* Add vfile as a dev-dependency ([`84d1ce3`](https://github.com/wooorm/remark-lint/commit/84d1ce3)) - -0.4.2 / 2015-07-12 -================== - -* Remove peer-dependencies ([`8d70fcf`](https://github.com/wooorm/remark-lint/commit/8d70fcf)) - -0.4.1 / 2015-07-05 -================== - -* Remove component support ([`58d7e6b`](https://github.com/wooorm/remark-lint/commit/58d7e6b)) -* Refactor to externalise `lib/utilities/` ([`eb78529`](https://github.com/wooorm/remark-lint/commit/eb78529)) - -0.4.0 / 2015-06-29 -================== - -* Add gap support ([`136e760`](https://github.com/wooorm/remark-lint/commit/136e760)) -* Update mdast ([`2d122e4`](https://github.com/wooorm/remark-lint/commit/2d122e4)) - -0.3.0 / 2015-06-20 -================== - -* Add checkbox-content-indent rule ([`7b55519`](https://github.com/wooorm/remark-lint/commit/7b55519)) -* Fix dot-files from being read as fixtures ([`ecbec2c`](https://github.com/wooorm/remark-lint/commit/ecbec2c)) -* Add checkbox-character-style rule ([`7ed4579`](https://github.com/wooorm/remark-lint/commit/7ed4579)) -* Fix tests for invalid position given my mdast-range ([`55d1128`](https://github.com/wooorm/remark-lint/commit/55d1128)) -* Add missing jsdoc comment ([`63b83b9`](https://github.com/wooorm/remark-lint/commit/63b83b9)) -* Update eslint ([`a3b0829`](https://github.com/wooorm/remark-lint/commit/a3b0829)) -* Update mdast, mdast-yaml-config ([`52bac04`](https://github.com/wooorm/remark-lint/commit/52bac04)) - -0.2.0 / 2015-06-13 -================== - -* Remove mdast-usage, add mdast-yaml-config as dependencies ([`053674f`](https://github.com/wooorm/remark-lint/commit/053674f)) -* Add images to blacklist for maximum-line-length ([`ba6d270`](https://github.com/wooorm/remark-lint/commit/ba6d270)) -* Refactor to use rawgit references to images in `readme.md` ([`3f6344c`](https://github.com/wooorm/remark-lint/commit/3f6344c)) -* Add support for external rules ([`5162a09`](https://github.com/wooorm/remark-lint/commit/5162a09)) -* Refactor additional, fileless, rules support ([`6d2ba65`](https://github.com/wooorm/remark-lint/commit/6d2ba65)) -* Adds support for automatic doc generation for file-less rules ([`29965a3`](https://github.com/wooorm/remark-lint/commit/29965a3)) -* Add `reset` docs to rule generation script ([`77b8bfd`](https://github.com/wooorm/remark-lint/commit/77b8bfd)) -* Adds `reset` rule to docs ([`90a5f8a`](https://github.com/wooorm/remark-lint/commit/90a5f8a)) -* Update wording re rules in `readme.md` ([`00d9ba4`](https://github.com/wooorm/remark-lint/commit/00d9ba4)) -* Update rule count in `readme.md` ([`f937cf4`](https://github.com/wooorm/remark-lint/commit/f937cf4)) - -0.1.0 / 2015-06-11 -================== diff --git a/lib/index.js b/lib/index.js index 85eb6503..818e6eb9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -165,9 +165,7 @@ function ruleFactory(id, rule, options) { var scope = file.namespace('remark-lint'); /* Track new messages per file. */ - if (scope.index === undefined || scope.index === null) { - scope.index = file.messages.length; - } + scope.index = file.messages.length; fn(ast, file, options, function (err) { var messages = file.messages; diff --git a/lib/rules.js b/lib/rules.js new file mode 100644 index 00000000..dd4d986f --- /dev/null +++ b/lib/rules.js @@ -0,0 +1,61 @@ +/* This file is generated. */ +'use strict'; +module.exports = { + 'blockquote-indentation': require('./rules/blockquote-indentation.js'), + 'checkbox-character-style': require('./rules/checkbox-character-style.js'), + 'checkbox-content-indent': require('./rules/checkbox-content-indent.js'), + 'code-block-style': require('./rules/code-block-style.js'), + 'definition-case': require('./rules/definition-case.js'), + 'definition-spacing': require('./rules/definition-spacing.js'), + 'emphasis-marker': require('./rules/emphasis-marker.js'), + 'fenced-code-flag': require('./rules/fenced-code-flag.js'), + 'fenced-code-marker': require('./rules/fenced-code-marker.js'), + 'file-extension': require('./rules/file-extension.js'), + 'final-definition': require('./rules/final-definition.js'), + 'final-newline': require('./rules/final-newline.js'), + 'first-heading-level': require('./rules/first-heading-level.js'), + 'hard-break-spaces': require('./rules/hard-break-spaces.js'), + 'heading-increment': require('./rules/heading-increment.js'), + 'heading-style': require('./rules/heading-style.js'), + 'link-title-style': require('./rules/link-title-style.js'), + 'list-item-bullet-indent': require('./rules/list-item-bullet-indent.js'), + 'list-item-content-indent': require('./rules/list-item-content-indent.js'), + 'list-item-indent': require('./rules/list-item-indent.js'), + 'list-item-spacing': require('./rules/list-item-spacing.js'), + 'maximum-heading-length': require('./rules/maximum-heading-length.js'), + 'maximum-line-length': require('./rules/maximum-line-length.js'), + 'no-auto-link-without-protocol': require('./rules/no-auto-link-without-protocol.js'), + 'no-blockquote-without-caret': require('./rules/no-blockquote-without-caret.js'), + 'no-consecutive-blank-lines': require('./rules/no-consecutive-blank-lines.js'), + 'no-duplicate-definitions': require('./rules/no-duplicate-definitions.js'), + 'no-duplicate-headings': require('./rules/no-duplicate-headings.js'), + 'no-emphasis-as-heading': require('./rules/no-emphasis-as-heading.js'), + 'no-file-name-articles': require('./rules/no-file-name-articles.js'), + 'no-file-name-consecutive-dashes': require('./rules/no-file-name-consecutive-dashes.js'), + 'no-file-name-irregular-characters': require('./rules/no-file-name-irregular-characters.js'), + 'no-file-name-mixed-case': require('./rules/no-file-name-mixed-case.js'), + 'no-file-name-outer-dashes': require('./rules/no-file-name-outer-dashes.js'), + 'no-heading-content-indent': require('./rules/no-heading-content-indent.js'), + 'no-heading-indent': require('./rules/no-heading-indent.js'), + 'no-heading-punctuation': require('./rules/no-heading-punctuation.js'), + 'no-html': require('./rules/no-html.js'), + 'no-inline-padding': require('./rules/no-inline-padding.js'), + 'no-literal-urls': require('./rules/no-literal-urls.js'), + 'no-missing-blank-lines': require('./rules/no-missing-blank-lines.js'), + 'no-multiple-toplevel-headings': require('./rules/no-multiple-toplevel-headings.js'), + 'no-shell-dollars': require('./rules/no-shell-dollars.js'), + 'no-shortcut-reference-image': require('./rules/no-shortcut-reference-image.js'), + 'no-shortcut-reference-link': require('./rules/no-shortcut-reference-link.js'), + 'no-table-indentation': require('./rules/no-table-indentation.js'), + 'no-tabs': require('./rules/no-tabs.js'), + 'no-undefined-references': require('./rules/no-undefined-references.js'), + 'no-unused-definitions': require('./rules/no-unused-definitions.js'), + 'ordered-list-marker-style': require('./rules/ordered-list-marker-style.js'), + 'ordered-list-marker-value': require('./rules/ordered-list-marker-value.js'), + 'rule-style': require('./rules/rule-style.js'), + 'strong-marker': require('./rules/strong-marker.js'), + 'table-cell-padding': require('./rules/table-cell-padding.js'), + 'table-pipe-alignment': require('./rules/table-pipe-alignment.js'), + 'table-pipes': require('./rules/table-pipes.js'), + 'unordered-list-marker-style': require('./rules/unordered-list-marker-style.js') +}; diff --git a/lib/rules/blockquote-indentation.js b/lib/rules/blockquote-indentation.js index 63810e85..0f640f75 100644 --- a/lib/rules/blockquote-indentation.js +++ b/lib/rules/blockquote-indentation.js @@ -10,21 +10,43 @@ * * The default value, `consistent`, detects the first used indentation * and will warn when other blockquotes use a different indentation. - * @example - * + * + * @example {"name": "valid.md", "setting": 4} + * + * + * * > Hello - * ... + * + * Paragraph. + * * > World * - * + * @example {"name": "valid.md", "setting": 2} + * + * + * * > Hello - * ... + * + * Paragraph. + * * > World * - * - * > Hello - * ... + * @example {"name": "invalid.md", "label": "input"} + * + * > Hello + * + * Paragraph. + * * > World + * + * Paragraph. + * + * > World + * + * @example {"name": "invalid.md", "label": "output"} + * + * 5:3: Remove 1 space between blockquote and content + * 9:3: Add 1 space between blockquote and content */ 'use strict'; diff --git a/lib/rules/checkbox-character-style.js b/lib/rules/checkbox-character-style.js index 24d6bc9a..43c95ee5 100644 --- a/lib/rules/checkbox-character-style.js +++ b/lib/rules/checkbox-character-style.js @@ -12,36 +12,61 @@ * * These values can also be passed in as an object, such as: * - * ```json - * { - * "checked": "x", - * "unchecked": " " - * } + * ```js + * {checked: 'x', unchecked: ' '} * ``` - * @example - * * - * + * @example {"name": "valid.md", "setting": {"checked": "x"}} + * + * + * * - [x] List item * - [x] List item * - * + * @example {"name": "valid.md", "setting": {"checked": "X"}} + * + * + * * - [X] List item * - [X] List item * - * + * @example {"name": "valid.md", "setting": {"unchecked": " "}} + * + * + * * - [ ] List item * - [ ] List item + * - [ ]·· + * - [ ] + * + * @example {"name": "valid.md", "setting": {"unchecked": "\t"}} + * + * * - * - * - [»···] List item - * - [»···] List item + * - [»] List item + * - [»] List item + * + * @example {"name": "invalid.md", "label": "input"} + * + * * - * * - [x] List item * - [X] List item * - [ ] List item - * - [»···] List item + * - [»] List item + * + * @example {"name": "invalid.md", "label": "output"} + * + * 4:4-4:5: Checked checkboxes should use `x` as a marker + * 6:4-6:5: Unchecked checkboxes should use ` ` as a marker + * + * @example {"setting": {"unchecked": "!"}, "name": "invalid.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Invalid unchecked checkbox marker `!`: use either `'\t'`, or `' '` + * + * @example {"setting": {"checked": "!"}, "name": "invalid.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Invalid checked checkbox marker `!`: use either `'x'`, or `'X'` */ 'use strict'; diff --git a/lib/rules/checkbox-content-indent.js b/lib/rules/checkbox-content-indent.js index 11cdd2e9..4f74fba2 100644 --- a/lib/rules/checkbox-content-indent.js +++ b/lib/rules/checkbox-content-indent.js @@ -5,18 +5,26 @@ * @module checkbox-content-indent * @fileoverview * Warn when list item checkboxes are followed by too much white-space. - * @example - * + * + * @example {"name": "valid.md"} + * * - [ ] List item * + [x] List item * * [X] List item * - [ ] List item * - * + * @example {"name": "invalid.md", "label": "input"} + * * - [ ] List item * + [x] List item * * [X] List item * - [ ] List item + * + * @example {"name": "invalid.md", "label": "output"} + * + * 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 */ 'use strict'; diff --git a/lib/rules/code-block-style.js b/lib/rules/code-block-style.js index c4efdc60..2d293555 100644 --- a/lib/rules/code-block-style.js +++ b/lib/rules/code-block-style.js @@ -12,29 +12,80 @@ * The default value, `consistent`, detects the first used code-block * style, and will warn when a subsequent code-block uses a different * style. - * @example - * - * Hello * - * ... + * @example {"setting": "indented", "name": "valid.md"} * - * World + * + * + * alpha(); + * + * Paragraph. + * + * bravo(); + * + * @example {"setting": "indented", "name": "invalid.md", "label": "input"} * - * * ``` - * Hello + * alpha(); * ``` - * ... - * ```bar - * World + * + * Paragraph. + * + * ``` + * bravo(); * ``` * - * - * Hello - * ... + * @example {"setting": "indented", "name": "invalid.md", "label": "output"} + * + * 1:1-3:4: Code blocks should be indented + * 7:1-9:4: Code blocks should be indented + * + * @example {"setting": "fenced", "name": "valid.md"} + * + * + * + * ``` + * alpha(); + * ``` + * + * Paragraph. + * * ``` - * World - * ``` + * bravo(); + * ``` + * + * @example {"setting": "fenced", "name": "invalid.md", "label": "input"} + * + * alpha(); + * + * Paragraph. + * + * bravo(); + * + * @example {"setting": "fenced", "name": "invalid.md", "label": "output"} + * + * 1:1-1:13: Code blocks should be fenced + * 5:1-5:13: Code blocks should be fenced + * + * @example {"name": "invalid.md", "label": "input"} + * + * + * + * alpha(); + * + * Paragraph. + * + * ``` + * bravo(); + * ``` + * + * @example {"name": "invalid.md", "label": "output"} + * + * 7:1-9:4: Code blocks should be indented + * + * @example {"setting": "invalid", "name": "invalid.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Invalid code block style `invalid`: use either `'consistent'`, `'fenced'`, or `'indented'` */ 'use strict'; diff --git a/lib/rules/definition-case.js b/lib/rules/definition-case.js index ee71ce2d..714170b9 100644 --- a/lib/rules/definition-case.js +++ b/lib/rules/definition-case.js @@ -5,12 +5,18 @@ * @module definition-case * @fileoverview * Warn when definition labels are not lower-case. - * @example - * - * [example] http://example.com "Example Domain" * - * - * ![Example] http://example.com/favicon.ico "Example image" + * @example {"name": "valid.md"} + * + * [example]: http://example.com "Example Domain" + * + * @example {"name": "invalid.md", "label": "input"} + * + * [Example]: http://example.com "Example Domain" + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-1:47: Do not use upper-case characters in definition labels */ 'use strict'; diff --git a/lib/rules/definition-spacing.js b/lib/rules/definition-spacing.js index b5a6705d..01f9cebd 100644 --- a/lib/rules/definition-spacing.js +++ b/lib/rules/definition-spacing.js @@ -5,12 +5,18 @@ * @module definition-spacing * @fileoverview * Warn when consecutive white space is used in a definition. - * @example - * - * [example domain] http://example.com "Example Domain" * - * - * ![example image] http://example.com/favicon.ico "Example image" + * @example {"name": "valid.md"} + * + * [example domain]: http://example.com "Example Domain" + * + * @example {"name": "invalid.md", "label": "input"} + * + * [example domain]: http://example.com "Example Domain" + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-1:57: Do not use consecutive white-space in definition labels */ 'use strict'; diff --git a/lib/rules/emphasis-marker.js b/lib/rules/emphasis-marker.js index d579feca..ba1672e8 100644 --- a/lib/rules/emphasis-marker.js +++ b/lib/rules/emphasis-marker.js @@ -12,14 +12,45 @@ * The default value, `consistent`, detects the first used emphasis * style, and will warn when a subsequent emphasis uses a different * style. - * @example - * + * + * @example {"setting": "*", "name": "valid.md"} + * * *foo* - * *bar* * - * + * @example {"setting": "*", "name": "invalid.md", "label": "input"} + * * _foo_ + * + * @example {"setting": "*", "name": "invalid.md", "label": "output"} + * + * 1:1-1:6: Emphasis should use `*` as a marker + * + * @example {"setting": "_", "name": "valid.md"} + * + * _foo_ + * + * @example {"setting": "_", "name": "invalid.md", "label": "input"} + * + * *foo* + * + * @example {"setting": "_", "name": "invalid.md", "label": "output"} + * + * 1:1-1:6: Emphasis should use `_` as a marker + * + * @example {"setting": "consistent", "name": "invalid.md", "label": "input"} + * + * + * + * *foo* * _bar_ + * + * @example {"setting": "consistent", "name": "invalid.md", "label": "output"} + * + * 4:1-4:6: Emphasis should use `*` as a marker + * + * @example {"setting": "invalid", "name": "invalid.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Invalid emphasis marker `invalid`: use either `'consistent'`, `'*'`, or `'_'` */ 'use strict'; diff --git a/lib/rules/fenced-code-flag.js b/lib/rules/fenced-code-flag.js index 1535439d..c0a00e2f 100644 --- a/lib/rules/fenced-code-flag.js +++ b/lib/rules/fenced-code-flag.js @@ -15,29 +15,54 @@ * In addition it can have the property `allowEmpty` (`boolean`) * which signifies whether or not to warn for fenced code-blocks without * languge flags. - * @example - * - * ```hello - * world(); + * + * @example {"name": "valid.md"} + * + * ```alpha + * bravo(); * ``` * - * - * Hello + * @example {"name": "invalid.md", "label": "input"} * - * * ``` - * world(); + * alpha(); * ``` * - * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-3:4: Missing code-language flag + * + * @example {"name": "valid.md", "setting": {"allowEmpty": true}} + * * ``` - * world(); + * alpha(); * ``` * - * - * ```hello - * world(); + * @example {"name": "invalid.md", "setting": {"allowEmpty": false}, "label": "input"} + * + * ``` + * alpha(); * ``` + * + * @example {"name": "invalid.md", "setting": {"allowEmpty": false}, "label": "output"} + * + * 1:1-3:4: Missing code-language flag + * + * @example {"name": "valid.md", "setting": ["alpha"]} + * + * ```alpha + * bravo(); + * ``` + * + * @example {"name": "invalid.md", "setting": ["charlie"], "label": "input"} + * + * ```alpha + * bravo(); + * ``` + * + * @example {"name": "invalid.md", "setting": ["charlie"], "label": "output"} + * + * 1:1-3:4: Invalid code-language flag */ 'use strict'; diff --git a/lib/rules/fenced-code-marker.js b/lib/rules/fenced-code-marker.js index 9ffadacb..eb116889 100644 --- a/lib/rules/fenced-code-marker.js +++ b/lib/rules/fenced-code-marker.js @@ -11,33 +11,50 @@ * The default value, `consistent`, detects the first used fenced code * marker style, and will warn when a subsequent fenced code uses a * different style. - * @example - * - * ```foo - * bar(); + * + * @example {"name": "valid.md", "setting": "`"} + * + * + * + * ```alpha + * bravo(); * ``` * * ``` - * baz(); + * charlie(); * ``` * - * - * ~~~foo - * bar(); + * @example {"name": "valid.md", "setting": "~"} + * + * + * + * ~~~alpha + * bravo(); * ~~~ * * ~~~ - * baz(); + * charlie(); * ~~~ * - * - * ~~~foo - * bar(); - * ~~~ + * @example {"name": "invalid.md", "label": "input"} * + * + * + * ```alpha + * bravo(); * ``` - * baz(); - * ``` + * + * ~~~ + * charlie(); + * ~~~ + * + * @example {"name": "invalid.md", "label": "output"} + * + * 7:1-9:4: Fenced code should use ` as a marker + * + * @example {"name": "invalid.md", "setting": "!", "label": "output", "config": {"positionless": true}} + * + * 1:1: Invalid fenced code marker `!`: use either `'consistent'`, `` '`' ``, or `'~'` */ 'use strict'; diff --git a/lib/rules/file-extension.js b/lib/rules/file-extension.js index 17fd7065..9450fc06 100644 --- a/lib/rules/file-extension.js +++ b/lib/rules/file-extension.js @@ -11,9 +11,16 @@ * `AUTHORS` or `LICENSE`). * * Options: `string`, default: `'md'` — Expected file extension. - * @example - * Invalid (when `'md'`): readme.mkd, readme.markdown, etc. - * Valid (when `'md'`): readme, readme.md + * + * @example {"name": "readme.md"} + * + * @example {"name": "readme"} + * + * @example {"name": "readme.mkd", "label": "output", "config": {"positionless": true}} + * + * 1:1: Invalid extension: use `md` + * + * @example {"name": "readme.mkd", "setting": "mkd"} */ 'use strict'; diff --git a/lib/rules/final-definition.js b/lib/rules/final-definition.js index 2d568216..69ddf7cf 100644 --- a/lib/rules/final-definition.js +++ b/lib/rules/final-definition.js @@ -5,18 +5,24 @@ * @module final-definition * @fileoverview * Warn when definitions are not placed at the end of the file. - * @example - * - * ... * - * [example] http://example.com "Example Domain" + * @example {"name": "valid.md"} * - * - * ... + * Paragraph. * - * [example] http://example.com "Example Domain" + * [example]: http://example.com "Example Domain" * - * A trailing paragraph. + * @example {"name": "invalid.md", "label": "input"} + * + * Paragraph. + * + * [example]: http://example.com "Example Domain" + * + * Another paragraph. + * + * @example {"name": "invalid.md", "label": "output"} + * + * 3:1-3:47: Move definitions to the end of the file (after the node at line `5`) */ 'use strict'; diff --git a/lib/rules/final-newline.js b/lib/rules/final-newline.js index 641e8aed..16cef824 100644 --- a/lib/rules/final-newline.js +++ b/lib/rules/final-newline.js @@ -26,7 +26,7 @@ function finalNewline(ast, file) { var contents = file.toString(); var last = contents.length - 1; - if (last > 0 && contents.charAt(last) !== '\n') { + if (last > -1 && contents.charAt(last) !== '\n') { file.warn('Missing newline character at end of file'); } } diff --git a/lib/rules/first-heading-level.js b/lib/rules/first-heading-level.js index e001fd33..e889c5bf 100644 --- a/lib/rules/first-heading-level.js +++ b/lib/rules/first-heading-level.js @@ -7,16 +7,42 @@ * Warn when the first heading has a level other than a specified value. * * Options: `number`, default: `1`. - * @example - * - * # Foo * - * ## Bar + * @example {"name": "valid.md", "setting": 1} * - * - * ## Foo + * * - * # Bar + * # Alpha + * + * Paragraph. + * + * @example {"name": "invalid.md", "setting": 1, "label": "input"} + * + * + * + * ## Bravo + * + * Paragraph. + * + * @example {"name": "invalid.md", "setting": 1, "label": "output"} + * + * 3:1-3:9: First heading level should be `1` + * + * @example {"name": "valid.md", "setting": 2} + * + * ## Bravo + * + * Paragraph. + * + * @example {"name": "invalid.md", "setting": 2, "label": "input"} + * + * # Bravo + * + * Paragraph. + * + * @example {"name": "invalid.md", "setting": 2, "label": "output"} + * + * 1:1-1:8: First heading level should be `2` */ 'use strict'; diff --git a/lib/rules/hard-break-spaces.js b/lib/rules/hard-break-spaces.js index 8be63ccd..a4ab926f 100644 --- a/lib/rules/hard-break-spaces.js +++ b/lib/rules/hard-break-spaces.js @@ -5,16 +5,24 @@ * @module hard-break-spaces * @fileoverview * Warn when too many spaces are used to create a hard break. - * @example - * * - * + * @example {"name": "valid.md"} + * + * + * * Lorem ipsum·· * dolor sit amet * - * + * @example {"name": "invalid.md", "label": "input"} + * + * + * * Lorem ipsum··· * dolor sit amet. + * + * @example {"name": "invalid.md", "label": "output"} + * + * 3:12-4:1: Use two spaces for hard line breaks */ 'use strict'; diff --git a/lib/rules/heading-increment.js b/lib/rules/heading-increment.js index 3e4abe93..a1b65efc 100644 --- a/lib/rules/heading-increment.js +++ b/lib/rules/heading-increment.js @@ -5,16 +5,22 @@ * @module heading-increment * @fileoverview * Warn when headings increment with more than 1 level at a time. - * @example - * - * # Foo * - * ## Bar + * @example {"name": "valid.md"} * - * - * # Foo + * # Alpha * - * ### Bar + * ## Bravo + * + * @example {"name": "invalid.md", "label": "input"} + * + * # Charlie + * + * ### Delta + * + * @example {"name": "invalid.md", "label": "output"} + * + * 3:1-3:10: Heading levels should increment by one level at a time */ 'use strict'; diff --git a/lib/rules/heading-style.js b/lib/rules/heading-style.js index 30e2ff39..4a7cdc22 100644 --- a/lib/rules/heading-style.js +++ b/lib/rules/heading-style.js @@ -12,37 +12,54 @@ * The default value, `consistent`, detects the first used heading * style, and will warn when a subsequent heading uses a different * style. - * @example - * - * # Foo * - * ## Bar + * @example {"name": "valid.md", "setting": "atx"} * - * ### Baz + * * - * - * # Foo # + * # Alpha * - * ## Bar # + * ## Bravo * - * ### Baz ### + * ### Charlie * - * - * Foo - * === + * @example {"name": "valid.md", "setting": "atx-closed"} * - * Bar - * --- + * * - * ### Baz + * # Delta ## * - * - * Foo - * === + * ## Echo ## * - * ## Bar + * ### Foxtrot ### * - * ### Baz ### + * @example {"name": "valid.md", "setting": "setext"} + * + * + * + * Golf + * ==== + * + * Hotel + * ----- + * + * ### India + * + * @example {"name": "invalid.md", "label": "input"} + * + * + * + * Juliett + * ======= + * + * ## Kilo + * + * ### Lima ### + * + * @example {"name": "invalid.md", "label": "output"} + * + * 6:1-6:8: Headings should use setext + * 8:1-8:13: Headings should use setext */ 'use strict'; diff --git a/lib/rules/index.js b/lib/rules/index.js deleted file mode 100644 index c6365ee5..00000000 --- a/lib/rules/index.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module Rules - * @fileoverview Map of rule id’s to rules. - */ - -'use strict'; - -/* Expose. */ -module.exports = { - 'no-auto-link-without-protocol': require('./no-auto-link-without-protocol'), - 'no-literal-urls': require('./no-literal-urls'), - 'no-consecutive-blank-lines': require('./no-consecutive-blank-lines'), - 'no-missing-blank-lines': require('./no-missing-blank-lines'), - 'blockquote-indentation': require('./blockquote-indentation'), - 'no-blockquote-without-caret': require('./no-blockquote-without-caret'), - 'code-block-style': require('./code-block-style'), - 'checkbox-content-indent': require('./checkbox-content-indent'), - 'checkbox-character-style': require('./checkbox-character-style'), - 'definition-case': require('./definition-case'), - 'definition-spacing': require('./definition-spacing'), - 'no-emphasis-as-heading': require('./no-emphasis-as-heading'), - 'emphasis-marker': require('./emphasis-marker'), - 'fenced-code-flag': require('./fenced-code-flag'), - 'fenced-code-marker': require('./fenced-code-marker'), - 'file-extension': require('./file-extension'), - 'final-newline': require('./final-newline'), - 'no-file-name-articles': require('./no-file-name-articles'), - 'no-file-name-consecutive-dashes': require('./no-file-name-consecutive-dashes'), - 'no-file-name-irregular-characters': require('./no-file-name-irregular-characters'), - 'no-file-name-mixed-case': require('./no-file-name-mixed-case'), - 'no-file-name-outer-dashes': require('./no-file-name-outer-dashes'), - 'final-definition': require('./final-definition'), - 'hard-break-spaces': require('./hard-break-spaces'), - 'heading-increment': require('./heading-increment'), - 'no-heading-content-indent': require('./no-heading-content-indent'), - 'no-heading-indent': require('./no-heading-indent'), - 'first-heading-level': require('./first-heading-level'), - 'maximum-heading-length': require('./maximum-heading-length'), - 'no-heading-punctuation': require('./no-heading-punctuation'), - 'heading-style': require('./heading-style'), - 'no-multiple-toplevel-headings': require('./no-multiple-toplevel-headings'), - 'no-duplicate-headings': require('./no-duplicate-headings'), - 'no-duplicate-definitions': require('./no-duplicate-definitions'), - 'no-html': require('./no-html'), - 'no-inline-padding': require('./no-inline-padding'), - 'maximum-line-length': require('./maximum-line-length'), - 'link-title-style': require('./link-title-style'), - 'list-item-bullet-indent': require('./list-item-bullet-indent'), - 'list-item-content-indent': require('./list-item-content-indent'), - 'list-item-indent': require('./list-item-indent'), - 'list-item-spacing': require('./list-item-spacing'), - 'ordered-list-marker-style': require('./ordered-list-marker-style'), - 'ordered-list-marker-value': require('./ordered-list-marker-value'), - 'no-shortcut-reference-image': require('./no-shortcut-reference-image'), - 'no-shortcut-reference-link': require('./no-shortcut-reference-link'), - 'rule-style': require('./rule-style'), - 'no-shell-dollars': require('./no-shell-dollars'), - 'strong-marker': require('./strong-marker'), - 'no-table-indentation': require('./no-table-indentation'), - 'table-pipe-alignment': require('./table-pipe-alignment'), - 'table-cell-padding': require('./table-cell-padding'), - 'table-pipes': require('./table-pipes'), - 'no-tabs': require('./no-tabs'), - 'unordered-list-marker-style': require('./unordered-list-marker-style'), - 'no-undefined-references': require('./no-undefined-references.js'), - 'no-unused-definitions': require('./no-unused-definitions.js') -}; diff --git a/lib/rules/link-title-style.js b/lib/rules/link-title-style.js index fe3ef063..33177280 100644 --- a/lib/rules/link-title-style.js +++ b/lib/rules/link-title-style.js @@ -12,23 +12,54 @@ * The default value, `consistent`, detects the first used quote * style, and will warn when a subsequent titles use a different * style. - * @example - * + * + * @example {"name": "valid.md", "setting": "\""} + * + * + * * [Example](http://example.com "Example Domain") * [Example](http://example.com "Example Domain") * - * + * @example {"name": "valid.md", "setting": "'"} + * + * + * * [Example](http://example.com 'Example Domain') * [Example](http://example.com 'Example Domain') * - * - * [Example](http://example.com (Example Domain)) - * [Example](http://example.com (Example Domain)) + * @example {"name": "valid.md", "setting": "()"} + * + * + * + * [Example](http://example.com (Example Domain) ) + * [Example](http://example.com (Example Domain) ) + * + * @example {"name": "invalid.md", "label": "input"} + * + * * - * * [Example](http://example.com "Example Domain") + * [Example](http://example.com#without-title) * [Example](http://example.com 'Example Domain') + * + * @example {"name": "invalid.md", "label": "output"} + * + * 5:46: Titles should use `"` as a quote + * + * @example {"name": "invalid.md", "label": "input", "setting": "()"} + * + * + * * [Example](http://example.com (Example Domain)) + * [Example](http://example.com 'Example Domain') + * + * @example {"name": "invalid.md", "label": "output", "setting": "()"} + * + * 4:46: Titles should use `()` as a quote + * + * @example {"name": "invalid.md", "setting": ".", "label": "output", "config": {"positionless": true}} + * + * 1:1: Invalid link title style marker `.`: use either `'consistent'`, `'"'`, `'\''`, or `'()'` */ 'use strict'; diff --git a/lib/rules/list-item-bullet-indent.js b/lib/rules/list-item-bullet-indent.js index 797d3e8d..e47bc085 100644 --- a/lib/rules/list-item-bullet-indent.js +++ b/lib/rules/list-item-bullet-indent.js @@ -5,14 +5,25 @@ * @module list-item-bullet-indent * @fileoverview * Warn when list item bullets are indented. - * @example - * + * + * @example {"name": "valid.md"} + * + * Paragraph. + * * * List item * * List item * - * - * * List item - * * List item + * @example {"name": "invalid.md", "label": "input"} + * + * Paragraph. + * + * * List item + * * List item + * + * @example {"name": "invalid.md", "label": "output"} + * + * 3:3: Incorrect indentation before bullet: remove 1 space + * 4:3: Incorrect indentation before bullet: remove 1 space */ 'use strict'; diff --git a/lib/rules/list-item-content-indent.js b/lib/rules/list-item-content-indent.js index 2721b9e3..64568266 100644 --- a/lib/rules/list-item-content-indent.js +++ b/lib/rules/list-item-content-indent.js @@ -5,16 +5,20 @@ * @module list-item-content-indent * @fileoverview * Warn when the content of a list item has mixed indentation. - * @example - * - * * List item * - * * Nested list item indented by 4 spaces + * @example {"name": "valid.md"} * - * - * * List item + * 1. [x] Alpha + * 1. Bravo * - * * Nested list item indented by 3 spaces + * @example {"name": "invalid.md", "label": "input"} + * + * 1. [x] Charlie + * 1. Delta + * + * @example {"name": "invalid.md", "label": "output"} + * + * 2:5: Don’t use mixed indentation for children, remove 1 space */ 'use strict'; diff --git a/lib/rules/list-item-indent.js b/lib/rules/list-item-indent.js index ec94cb2c..0fb57dc2 100644 --- a/lib/rules/list-item-indent.js +++ b/lib/rules/list-item-indent.js @@ -9,35 +9,60 @@ * * Options: `string`, either `'tab-size'`, `'mixed'`, or `'space'`, * default: `'tab-size'`. - * @example - * + * + * @example {"name": "valid.md", "setting": "tab-size"} + * * * List * item. * + * Paragraph. + * * 11. List * item. * - * + * Paragraph. + * + * * List + * item. + * + * * List + * item. + * + * @example {"name": "valid.md", "setting": "mixed"} + * * * List item. * + * Paragraph. + * * 11. List item * + * Paragraph. + * * * List * item. * - * 11. List + * * List * item. * - * + * @example {"name": "valid.md", "setting": "space"} + * * * List item. * + * Paragraph. + * * 11. List item * + * Paragraph. + * * * List * item. * - * 11. List - * item. + * * List + * item. + * + * @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'` */ 'use strict'; diff --git a/lib/rules/list-item-spacing.js b/lib/rules/list-item-spacing.js index 3734534b..1ebadf46 100644 --- a/lib/rules/list-item-spacing.js +++ b/lib/rules/list-item-spacing.js @@ -6,8 +6,17 @@ * @fileoverview * Warn when list looseness is incorrect, such as being tight * when it should be loose, and vice versa. - * @example - * + * + * @example {"name": "valid.md"} + * + * A tight list: + * + * - item 1 + * - item 2 + * - item 3 + * + * A loose list: + * * - Wrapped * item * @@ -15,23 +24,29 @@ * * - item 3 * - * - * - item 1 - * - item 2 - * - item 3 + * @example {"name": "invalid.md", "label": "input"} + * + * A tight list: * - * * - Wrapped * item * - item 2 * - item 3 * - * + * A loose list: + * * - item 1 * * - item 2 * * - item 3 + * + * @example {"name": "invalid.md", "label": "output"} + * + * 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 */ 'use strict'; diff --git a/lib/rules/maximum-heading-length.js b/lib/rules/maximum-heading-length.js index 65776c49..9c7a230d 100644 --- a/lib/rules/maximum-heading-length.js +++ b/lib/rules/maximum-heading-length.js @@ -9,13 +9,20 @@ * Options: `number`, default: `60`. * * Ignores markdown syntax, only checks the plain text content. - * @example - * - * # Alpha bravo charlie delta echo - * # ![Alpha bravo charlie delta echo](http://example.com/nato.png) * - * - * # Alpha bravo charlie delta echo foxtrot + * @example {"name": "valid.md"} + * + * # Alpha bravo charlie delta echo foxtrot golf hotel + * + * # ![Alpha bravo charlie delta echo foxtrot golf hotel](http://example.com/nato.png) + * + * @example {"name": "invalid.md", "setting": 40, "label": "input"} + * + * # Alpha bravo charlie delta echo foxtrot golf hotel + * + * @example {"name": "invalid.md", "setting": 40, "label": "output"} + * + * 1:1-1:52: Use headings shorter than `40` */ 'use strict'; diff --git a/lib/rules/maximum-line-length.js b/lib/rules/maximum-line-length.js index 21173cdd..1314247e 100644 --- a/lib/rules/maximum-line-length.js +++ b/lib/rules/maximum-line-length.js @@ -10,24 +10,50 @@ * * Ignores nodes which cannot be wrapped, such as heasings, tables, * code, link, images, and definitions. - * @example - * - * Alpha bravo charlie delta echo. * - * Alpha bravo charlie delta echo [foxtrot](./foxtrot.html). + * @example {"name": "valid.md", "setting": 80, "config": {"positionless": true}} * - * # Alpha bravo charlie delta echo foxtrot golf hotel. + * This line is simply not toooooooooooooooooooooooooooooooooooooooooooo + * long. * - * # Alpha bravo charlie delta echo foxtrot golf hotel. + * This is also fine: * - * | A | B | C | D | E | F | F | H | - * | ----- | ----- | ------- | ----- | ---- | ------- | ---- | ----- | - * | Alpha | bravo | charlie | delta | echo | foxtrot | golf | hotel | + * * - * - * Alpha bravo charlie delta echo foxtrot golf. + * [foo](http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables) * - * Alpha bravo charlie delta echo [foxtrot](./foxtrot.html) golf. + * + * + * ![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. + * + * . + * + * In addition, definitions are also fine: + * + * [foo]: + * + * @example {"name": "invalid.md", "setting": 80, "label": "input", "config": {"positionless": true}} + * + * 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: + * + * and such. + * + * @example {"name": "invalid.md", "setting": 80, "label": "output", "config": {"positionless": true}} + * + * 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 */ 'use strict'; diff --git a/lib/rules/no-auto-link-without-protocol.js b/lib/rules/no-auto-link-without-protocol.js index d2623103..bb5bb68a 100644 --- a/lib/rules/no-auto-link-without-protocol.js +++ b/lib/rules/no-auto-link-without-protocol.js @@ -5,14 +5,20 @@ * @module no-auto-link-without-protocol * @fileoverview * Warn for angle-bracketed links without protocol. - * @example - * + * + * @example {"name": "valid.md"} + * * * * - * + * @example {"name": "invalid.md", "label": "input"} + * * * + * + * @example {"name": "invalid.md", "label": "output"} + * + * 2:1-2:14: All automatic links must start with a protocol */ 'use strict'; diff --git a/lib/rules/no-blockquote-without-caret.js b/lib/rules/no-blockquote-without-caret.js index 343bcc7d..9fe63527 100644 --- a/lib/rules/no-blockquote-without-caret.js +++ b/lib/rules/no-blockquote-without-caret.js @@ -5,16 +5,22 @@ * @module no-blockquote-without-caret * @fileoverview * Warn when blank lines without carets are found in a blockquote. - * @example - * + * + * @example {"name": "valid.md"} + * * > Foo... * > * > ...Bar. * - * + * @example {"name": "invalid.md", "label": "input"} + * * > Foo... * * > ...Bar. + * + * @example {"name": "invalid.md", "label": "output"} + * + * 2:1: Missing caret in blockquote */ 'use strict'; diff --git a/lib/rules/no-consecutive-blank-lines.js b/lib/rules/no-consecutive-blank-lines.js index 4511da95..4bd4987e 100644 --- a/lib/rules/no-consecutive-blank-lines.js +++ b/lib/rules/no-consecutive-blank-lines.js @@ -6,17 +6,32 @@ * @fileoverview * Warn for too many consecutive blank lines. Knows about the extra line * needed between a list and indented code, and two lists. - * @example - * + * + * @example {"name": "valid.md"} + * * Foo... * * ...Bar. * - * + * @example {"name": "valid-for-code.md"} + * + * Paragraph. + * + * * List + * + * + * bravo(); + * + * @example {"name": "invalid.md", "label": "input"} + * * Foo... * * * ...Bar. + * + * @example {"name": "invalid.md", "label": "output"} + * + * 4:1: Remove 1 line before node */ 'use strict'; diff --git a/lib/rules/no-duplicate-definitions.js b/lib/rules/no-duplicate-definitions.js index ba333de1..8fc92898 100644 --- a/lib/rules/no-duplicate-definitions.js +++ b/lib/rules/no-duplicate-definitions.js @@ -5,14 +5,20 @@ * @module no-duplicate-definitions * @fileoverview * Warn when duplicate definitions are found. - * @example - * + * + * @example {"name": "valid.md"} + * * [foo]: bar * [baz]: qux * - * + * @example {"name": "invalid.md", "label": "input"} + * * [foo]: bar * [foo]: qux + * + * @example {"name": "invalid.md", "label": "output"} + * + * 2:1-2:11: Do not use definitions with the same identifier (1:1) */ 'use strict'; diff --git a/lib/rules/no-duplicate-headings.js b/lib/rules/no-duplicate-headings.js index 6c814f74..2ea2dfef 100644 --- a/lib/rules/no-duplicate-headings.js +++ b/lib/rules/no-duplicate-headings.js @@ -5,18 +5,25 @@ * @module no-duplicate-headings * @fileoverview * Warn when duplicate headings are found. - * @example - * + * + * @example {"name": "valid.md"} + * * # Foo * * ## Bar * - * + * @example {"name": "invalid.md", "label": "input"} + * * # Foo * * ## Foo * * ## [Foo](http://foo.com/bar) + * + * @example {"name": "invalid.md", "label": "output"} + * + * 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) */ 'use strict'; diff --git a/lib/rules/no-emphasis-as-heading.js b/lib/rules/no-emphasis-as-heading.js index 8964cc40..3a479b4d 100644 --- a/lib/rules/no-emphasis-as-heading.js +++ b/lib/rules/no-emphasis-as-heading.js @@ -6,16 +6,22 @@ * @fileoverview * Warn when emphasis (including strong), instead of a heading, introduces * a paragraph. - * @example - * + * + * @example {"name": "valid.md"} + * * # Foo * * Bar. * - * + * @example {"name": "invalid.md", "label": "input"} + * * *Foo* * * Bar. + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-1:6: Don’t use emphasis to introduce a section, use a heading */ 'use strict'; diff --git a/lib/rules/no-file-name-articles.js b/lib/rules/no-file-name-articles.js index ee77432a..38057dd2 100644 --- a/lib/rules/no-file-name-articles.js +++ b/lib/rules/no-file-name-articles.js @@ -5,9 +5,20 @@ * @module no-file-name-articles * @fileoverview * Warn when file name start with an article. - * @example - * Valid: article.md - * Invalid: an-article.md, a-article.md, , the-article.md + * + * @example {"name": "title.md"} + * + * @example {"name": "a-title.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Do not start file names with `a` + * + * @example {"name": "the-title.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Do not start file names with `the` + * + * @example {"name": "an-article.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Do not start file names with `an` */ 'use strict'; diff --git a/lib/rules/no-file-name-consecutive-dashes.js b/lib/rules/no-file-name-consecutive-dashes.js index 2a99d15d..e8c7d724 100644 --- a/lib/rules/no-file-name-consecutive-dashes.js +++ b/lib/rules/no-file-name-consecutive-dashes.js @@ -5,9 +5,12 @@ * @module no-file-name-consecutive-dashes * @fileoverview * Warn when file names contain consecutive dashes. - * @example - * Invalid: docs/plug--ins.md - * Valid: docs/plug-ins.md + * + * @example {"name": "plug-ins.md"} + * + * @example {"name": "plug--ins.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Do not use consecutive dashes in a file name */ 'use strict'; diff --git a/lib/rules/no-file-name-irregular-characters.js b/lib/rules/no-file-name-irregular-characters.js index 2582a032..f6316ee2 100644 --- a/lib/rules/no-file-name-irregular-characters.js +++ b/lib/rules/no-file-name-irregular-characters.js @@ -14,9 +14,22 @@ * * Any match by the wrapped or given expressions triggers a * warning. - * @example - * Invalid: plug_ins.md, plug ins.md. - * Valid: plug-ins.md, plugins.md. + * + * @example {"name": "plug-ins.md"} + * + * @example {"name": "plugins.md"} + * + * @example {"name": "plug_ins.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Do not use `_` in a file name + * + * @example {"name": "README.md", "label": "output", "setting": "\\.a-z0-9", "config": {"positionless": true}} + * + * 1:1: Do not use `R` in a file name + * + * @example {"name": "plug ins.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Do not use ` ` in a file name */ 'use strict'; @@ -36,7 +49,7 @@ module.exports = noFileNameIrregularCharacters; * characters which should not be allowed. */ function noFileNameIrregularCharacters(ast, file, preferred) { - var expression = preferred || /[^\\.a-zA-Z0-9-]/; + var expression = preferred || /[^\\\.a-zA-Z0-9-]/; var match; if (typeof expression === 'string') { diff --git a/lib/rules/no-file-name-mixed-case.js b/lib/rules/no-file-name-mixed-case.js index a311bd4a..f9eb33cd 100644 --- a/lib/rules/no-file-name-mixed-case.js +++ b/lib/rules/no-file-name-mixed-case.js @@ -6,9 +6,14 @@ * @fileoverview * Warn when a file name uses mixed case: both upper- and lower case * characters. - * @example - * Invalid: Readme.md - * Valid: README.md, readme.md + * + * @example {"name": "README.md"} + * + * @example {"name": "readme.md"} + * + * @example {"name": "Readme.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Do not mix casing in file names */ 'use strict'; diff --git a/lib/rules/no-file-name-outer-dashes.js b/lib/rules/no-file-name-outer-dashes.js index c2a9bcf7..53fc0d6c 100644 --- a/lib/rules/no-file-name-outer-dashes.js +++ b/lib/rules/no-file-name-outer-dashes.js @@ -5,9 +5,16 @@ * @module no-file-name-outer-dashes * @fileoverview * Warn when file names contain initial or final dashes. - * @example - * Invalid: -readme.md, readme-.md - * Valid: readme.md + * + * @example {"name": "readme.md"} + * + * @example {"name": "-readme.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Do not use initial or final dashes in a file name + * + * @example {"name": "readme-.md", "label": "output", "config": {"positionless": true}} + * + * 1:1: Do not use initial or final dashes in a file name */ 'use strict'; diff --git a/lib/rules/no-heading-content-indent.js b/lib/rules/no-heading-content-indent.js index 11575cce..0e356974 100644 --- a/lib/rules/no-heading-content-indent.js +++ b/lib/rules/no-heading-content-indent.js @@ -5,21 +5,47 @@ * @module no-heading-content-indent * @fileoverview * Warn when a heading’s content is indented. - * @example + * + * @example {"name": "valid.md"} + * + * + * + * #·Foo + * + * ## Bar·## + * + * ##·Baz + * + * @example {"name": "invalid.md", "label": "input"} + * * - * + * * #··Foo * * ## Bar··## * * ##··Baz * - * - * #·Foo + * @example {"name": "invalid.md", "label": "output"} * - * ## Bar·## + * 3:4: Remove 1 space before this heading’s content + * 5:7: Remove 1 space after this heading’s content + * 7:7: Remove 1 space before this heading’s content * - * ##·Baz + * @example {"name": "empty-heading.md"} + * + * #·· + * + * @example {"name": "tight.md", "config":{"pedantic":true}, "label": "input"} + * + * In pedantic mode, headings without spacing can also be detected: + * + * ##No spacing left, too much right··## + * + * @example {"name": "tight.md", "label": "output"} + * + * 3:3: Add 1 space before this heading’s content + * 3:34: Remove 1 space after this heading’s content */ 'use strict'; @@ -74,7 +100,7 @@ function noHeadingContentIndent(ast, file) { char = contents.charAt(index); } - /* CR/LF bug: wooorm/remark#195. */ + /* istanbul ignore if - CR/LF bug: wooorm/remark#195. */ if (!char) { return; } diff --git a/lib/rules/no-heading-indent.js b/lib/rules/no-heading-indent.js index 73e6c4ea..d8b5cf14 100644 --- a/lib/rules/no-heading-indent.js +++ b/lib/rules/no-heading-indent.js @@ -5,29 +5,41 @@ * @module no-heading-indent * @fileoverview * Warn when a heading is indented. - * @example + * + * @example {"name": "valid.md"} + * * - * - * ···# Hello world * - * ·Foo + * #·Hello world + * + * Foo * ----- * - * ·# Hello world # + * #·Hello world·# * - * ···Bar + * Bar * ===== * - * - * # Hello world + * @example {"name": "invalid.md", "label": "input"} * - * Foo + * + * + * ···# Hello world + * + * ·Foo * ----- * - * # Hello world # + * ·# Hello world # * - * Bar + * ···Bar * ===== + * + * @example {"name": "invalid.md", "label": "output"} + * + * 3:4: Remove 3 spaces before this heading + * 5:2: Remove 1 space before this heading + * 8:2: Remove 1 space before this heading + * 10:4: Remove 3 spaces before this heading */ 'use strict'; diff --git a/lib/rules/no-heading-punctuation.js b/lib/rules/no-heading-punctuation.js index c54676a8..0aa6c1ec 100644 --- a/lib/rules/no-heading-punctuation.js +++ b/lib/rules/no-heading-punctuation.js @@ -11,8 +11,17 @@ * * Note that these are added to a regex, in a group (`'[' + char + ']'`), * be careful for escapes and dashes. - * @example - * + * + * @example {"name": "valid.md"} + * + * # Hello + * + * @example {"name": "valid.md", "setting": ",;:!?"} + * + * # Hello... + * + * @example {"name": "invalid.md", "label": "input"} + * * # Hello: * * # Hello? @@ -23,8 +32,13 @@ * * # Hello; * - * - * # Hello + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-1:9: Don’t add a trailing `:` to headings + * 3:1-3:9: Don’t add a trailing `?` to headings + * 5:1-5:9: Don’t add a trailing `!` to headings + * 7:1-7:9: Don’t add a trailing `,` to headings + * 9:1-9:9: Don’t add a trailing `;` to headings */ 'use strict'; diff --git a/lib/rules/no-html.js b/lib/rules/no-html.js index 577423fd..66cb51a6 100644 --- a/lib/rules/no-html.js +++ b/lib/rules/no-html.js @@ -8,12 +8,20 @@ * * Ignores comments, because they are used by this tool, remark, and * because markdown doesn’t have native comments. - * @example - * - *

Hello

* - * + * @example {"name": "valid.md"} + * * # Hello + * + * + * + * @example {"name": "invalid.md", "label": "input"} + * + *

Hello

+ * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-1:15: Do not use HTML in markdown */ 'use strict'; diff --git a/lib/rules/no-inline-padding.js b/lib/rules/no-inline-padding.js index f69d22d2..477c4cab 100644 --- a/lib/rules/no-inline-padding.js +++ b/lib/rules/no-inline-padding.js @@ -8,12 +8,20 @@ * content. * * Warns for emphasis, strong, delete, image, and link. - * @example - * - * * Hello *, [ world ](http://foo.bar/baz) * - * - * *Hello*, [world](http://foo.bar/baz) + * @example {"name": "valid.md"} + * + * Alpha, *bravo*, _charlie_, [delta](http://echo.fox/trot) + * + * @example {"name": "invalid.md", "label": "input"} + * + * Alpha, * bravo *, _ charlie _, [ delta ](http://echo.fox/trot) + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:8-1:17: Don’t pad `emphasis` with inner spaces + * 1:19-1:30: Don’t pad `emphasis` with inner spaces + * 1:32-1:63: Don’t pad `link` with inner spaces */ 'use strict'; diff --git a/lib/rules/no-literal-urls.js b/lib/rules/no-literal-urls.js index 6edc9c2e..65729f5c 100644 --- a/lib/rules/no-literal-urls.js +++ b/lib/rules/no-literal-urls.js @@ -5,12 +5,21 @@ * @module no-literal-urls * @fileoverview * Warn when URLs without angle-brackets are used. - * @example - * - * http://foo.bar/baz * - * + * @example {"name": "valid.md"} + * * + * + * + * @example {"name": "invalid.md", "label": "input"} + * + * http://foo.bar/baz + * + * mailto:qux@quux.com + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-1:19: Don’t use literal URLs without angle brackets */ 'use strict'; @@ -51,7 +60,7 @@ function noLiteralURLs(ast, file) { if ( initial === head && final === tail && - (value === node.url || value == MAILTO + node.url) + (node.url === MAILTO + value || node.url === value) ) { file.warn('Don’t use literal URLs without angle brackets', node); } diff --git a/lib/rules/no-missing-blank-lines.js b/lib/rules/no-missing-blank-lines.js index ddd1ab21..36cd7404 100644 --- a/lib/rules/no-missing-blank-lines.js +++ b/lib/rules/no-missing-blank-lines.js @@ -5,15 +5,21 @@ * @module no-missing-blank-lines * @fileoverview * Warn for missing blank lines before a block node. - * @example - * + * + * @example {"name": "valid.md"} + * * # Foo + * * ## Bar * - * - * # Foo + * @example {"name": "invalid.md", "label": "input"} * + * # Foo * ## Bar + * + * @example {"name": "invalid.md", "label": "output"} + * + * 2:1-2:7: Missing blank line before block node */ 'use strict'; diff --git a/lib/rules/no-multiple-toplevel-headings.js b/lib/rules/no-multiple-toplevel-headings.js index d0224d40..54b1f1c7 100644 --- a/lib/rules/no-multiple-toplevel-headings.js +++ b/lib/rules/no-multiple-toplevel-headings.js @@ -7,16 +7,22 @@ * Warn when multiple top-level headings are used. * * Options: `number`, default: `1`. - * @example - * - * # Foo * - * # Bar + * @example {"name": "valid.md", "setting": 1} * - * * # Foo * * ## Bar + * + * @example {"name": "invalid.md", "setting": 1, "label": "input"} + * + * # Foo + * + * # Bar + * + * @example {"name": "invalid.md", "setting": 1, "label": "output"} + * + * 3:1-3:6: Don’t use multiple top level headings (3:1) */ 'use strict'; diff --git a/lib/rules/no-shell-dollars.js b/lib/rules/no-shell-dollars.js index b54c9f91..a6e7caa9 100644 --- a/lib/rules/no-shell-dollars.js +++ b/lib/rules/no-shell-dollars.js @@ -8,25 +8,30 @@ * * Ignored indented code blocks and fenced code blocks without language * flag. - * @example - * - * ```bash - * $ echo a - * $ echo a > file - * ``` * - * + * @example {"name": "valid.md"} + * * ```sh * echo a * echo a > file * ``` * - * * ```zsh * $ echo a * a * $ echo a > file * ``` + * + * @example {"name": "invalid.md", "label": "input"} + * + * ```bash + * $ echo a + * $ echo a > file + * ``` + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-4:4: Do not use dollar signs before shell-commands */ 'use strict'; diff --git a/lib/rules/no-shortcut-reference-image.js b/lib/rules/no-shortcut-reference-image.js index ba2f29ae..31e2c10b 100644 --- a/lib/rules/no-shortcut-reference-image.js +++ b/lib/rules/no-shortcut-reference-image.js @@ -5,16 +5,22 @@ * @module no-shortcut-reference-image * @fileoverview * Warn when shortcut reference images are used. - * @example - * - * ![foo] * - * [foo]: http://foo.bar/baz.png + * @example {"name": "valid.md"} * - * * ![foo][] * * [foo]: http://foo.bar/baz.png + * + * @example {"name": "invalid.md", "label": "input"} + * + * ![foo] + * + * [foo]: http://foo.bar/baz.png + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-1:7: Use the trailing [] on reference images */ 'use strict'; diff --git a/lib/rules/no-shortcut-reference-link.js b/lib/rules/no-shortcut-reference-link.js index 032dd320..dde1dd2a 100644 --- a/lib/rules/no-shortcut-reference-link.js +++ b/lib/rules/no-shortcut-reference-link.js @@ -5,16 +5,22 @@ * @module no-shortcut-reference-link * @fileoverview * Warn when shortcut reference links are used. - * @example - * - * [foo] * - * [foo]: http://foo.bar/baz + * @example {"name": "valid.md"} * - * * [foo][] * * [foo]: http://foo.bar/baz + * + * @example {"name": "invalid.md", "label": "input"} + * + * [foo] + * + * [foo]: http://foo.bar/baz + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-1:6: Use the trailing [] on reference links */ 'use strict'; diff --git a/lib/rules/no-table-indentation.js b/lib/rules/no-table-indentation.js index 7aff0a12..549c86f6 100644 --- a/lib/rules/no-table-indentation.js +++ b/lib/rules/no-table-indentation.js @@ -5,16 +5,27 @@ * @module no-table-indentation * @fileoverview * Warn when tables are indented. - * @example - * - * | A | B | - * | ----- | ----- | - * | Alpha | Bravo | * - * + * @example {"name": "valid.md"} + * + * Paragraph. + * * | A | B | * | ----- | ----- | * | Alpha | Bravo | + * + * @example {"name": "invalid.md", "label": "input"} + * + * Paragraph. + * + * | A | B | + * | ----- | ----- | + * | Alpha | Bravo | + * + * @example {"name": "invalid.md", "label": "output"} + * + * 3:1-3:21: Do not indent table rows + * 5:1-5:21: Do not indent table rows */ 'use strict'; diff --git a/lib/rules/no-tabs.js b/lib/rules/no-tabs.js index 8de0683b..898a012b 100644 --- a/lib/rules/no-tabs.js +++ b/lib/rules/no-tabs.js @@ -5,17 +5,42 @@ * @module no-tabs * @fileoverview * Warn when hard-tabs instead of spaces - * @example - * - * - * Foo»Bar * - * »···Foo + * @example {"name": "valid.md"} * - * * Foo Bar * * Foo + * + * @example {"name": "invalid.md", "label": "input", "config": {"positionless": true}} + * + * + * + * »Here's one before a code block. + * + * Here's a tab:», and here is another:». + * + * And this is in `inline»code`. + * + * >»This is in a block quote. + * + * *»And... + * + * »1.»in a list. + * + * And this is a tab as the last character.» + * + * @example {"name": "invalid.md", "label": "output"} + * + * 3:1: Use spaces instead of hard-tabs + * 5:14: Use spaces instead of hard-tabs + * 5:37: Use spaces instead of hard-tabs + * 7:23: Use spaces instead of hard-tabs + * 9:2: Use spaces instead of hard-tabs + * 11:2: Use spaces instead of hard-tabs + * 13:1: Use spaces instead of hard-tabs + * 13:4: Use spaces instead of hard-tabs + * 15:41: Use spaces instead of hard-tabs */ 'use strict'; diff --git a/lib/rules/no-undefined-references.js b/lib/rules/no-undefined-references.js index 65eb329e..984aef96 100644 --- a/lib/rules/no-undefined-references.js +++ b/lib/rules/no-undefined-references.js @@ -2,17 +2,23 @@ * @author Titus Wormer * @copyright 2016 Titus Wormer * @license MIT - * @module no-unused-definitions + * @module no-undefined-references * @fileoverview * Warn when references to undefined definitions are found. - * @example - * + * + * @example {"name": "valid.md"} + * * [foo][] * * [foo]: https://example.com * - * + * @example {"name": "invalid.md", "label": "input"} + * * [bar][] + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-1:8: Found reference to undefined definition */ 'use strict'; diff --git a/lib/rules/no-unused-definitions.js b/lib/rules/no-unused-definitions.js index 692d88f1..d86f60c5 100644 --- a/lib/rules/no-unused-definitions.js +++ b/lib/rules/no-unused-definitions.js @@ -5,14 +5,20 @@ * @module no-unused-definitions * @fileoverview * Warn when unused definitions are found. - * @example - * + * + * @example {"name": "valid.md"} + * * [foo][] * * [foo]: https://example.com * - * + * @example {"name": "invalid.md", "label": "input"} + * * [bar]: https://example.com + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1-1:27: Found unused definition */ 'use strict'; diff --git a/lib/rules/ordered-list-marker-style.js b/lib/rules/ordered-list-marker-style.js index 4a8168ae..9953f98f 100644 --- a/lib/rules/ordered-list-marker-style.js +++ b/lib/rules/ordered-list-marker-style.js @@ -15,16 +15,37 @@ * The default value, `consistent`, detects the first used list * style, and will warn when a subsequent list uses a different * style. - * @example - * + * + * @example {"name": "valid.md", "setting": "."} + * + * + * * 1. Foo * * 2. Bar * - * + * @example {"name": "valid.md", "setting": ")", "config": {"commonmark": true}} + * + * + * * 1) Foo * * 2) Bar + * + * @example {"name": "invalid.md", "label": "input", "config": {"commonmark": true}} + * + * 1. Foo + * + * 2) Bar + * + * @example {"name": "invalid.md", "label": "output"} + * + * 3:1-3:8: Marker style should be `.` + * + * @example {"name": "invalid.md", "label": "output", "setting": "!", "config": {"positionless": true}} + * + * 1:1: Invalid ordered list-item marker style `!`: use either `'.'` or `')'` */ 'use strict'; diff --git a/lib/rules/ordered-list-marker-value.js b/lib/rules/ordered-list-marker-value.js index 2b0cb623..3556bd30 100644 --- a/lib/rules/ordered-list-marker-value.js +++ b/lib/rules/ordered-list-marker-value.js @@ -14,33 +14,64 @@ * relative to the starting point. When set to `'single'`, bullets should * be the same as the relative starting point. When set to `'one'`, bullets * should always be `1`. - * @example - * + * + * @example {"name": "valid.md", "setting": "one"} + * * 1. Foo * 1. Bar * 1. Baz * + * Paragraph. + * * 1. Alpha * 1. Bravo * 1. Charlie * - * + * @example {"name": "valid.md", "setting": "single"} + * * 1. Foo * 1. Bar * 1. Baz * + * Paragraph. + * * 3. Alpha * 3. Bravo * 3. Charlie * - * + * @example {"name": "valid.md", "setting": "ordered"} + * * 1. Foo * 2. Bar * 3. Baz * + * Paragraph. + * * 3. Alpha * 4. Bravo * 5. Charlie + * + * @example {"name": "invalid.md", "setting": "one", "label": "input"} + * + * 1. Foo + * 2. Bar + * + * @example {"name": "invalid.md", "setting": "one", "label": "output"} + * + * 2:1-2:8: Marker should be `1`, was `2` + * + * @example {"name": "invalid.md", "setting": "ordered", "label": "input"} + * + * 1. Foo + * 1. Bar + * + * @example {"name": "invalid.md", "setting": "ordered", "label": "output"} + * + * 2:1-2:8: Marker should be `2`, was `1` + * + * @example {"name": "invalid.md", "setting": "invalid", "label": "output", "config": {"positionless": true}} + * + * 1:1: Invalid ordered list-item marker value `invalid`: use either `'ordered'` or `'one'` */ 'use strict'; diff --git a/lib/rules/rule-style.js b/lib/rules/rule-style.js index dfb28d2b..21a2c825 100644 --- a/lib/rules/rule-style.js +++ b/lib/rules/rule-style.js @@ -10,16 +10,38 @@ * * Options: `string`, either a valid markdown rule, or `consistent`, * default: `'consistent'`. - * @example - * + * + * @example {"name": "valid.md", "setting": "* * *"} + * + * + * * * * * * * * * * * - * + * @example {"name": "valid.md", "setting": "_______"} + * + * + * * _______ * * _______ + * + * @example {"name": "invalid.md", "label": "input"} + * + * + * + * *** + * + * * * * + * + * @example {"name": "invalid.md", "label": "output"} + * + * 5:1-5:6: Rules should use `***` + * + * @example {"name": "invalid.md", "label": "output", "setting": "!!!", "config": {"positionless": true}} + * + * 1:1: Invalid preferred rule-style: provide a valid markdown rule, or `'consistent'` */ 'use strict'; diff --git a/lib/rules/strong-marker.js b/lib/rules/strong-marker.js index 728805d5..2283c364 100644 --- a/lib/rules/strong-marker.js +++ b/lib/rules/strong-marker.js @@ -2,7 +2,7 @@ * @author Titus Wormer * @copyright 2015 Titus Wormer * @license MIT - * @module blockquote-indentation + * @module strong-marker * @fileoverview * Warn for violating strong markers. * @@ -12,14 +12,34 @@ * The default value, `consistent`, detects the first used strong * style, and will warn when a subsequent strong uses a different * style. - * @example - * - * **foo** - * **bar** - * - * - * __foo__ - * __bar__ + * + * @example {"name": "valid.md"} + * + * **foo** and **bar**. + * + * @example {"name": "also-valid.md"} + * + * __foo__ and __bar__. + * + * @example {"name": "valid.md", "setting": "*"} + * + * **foo**. + * + * @example {"name": "valid.md", "setting": "_"} + * + * __foo__. + * + * @example {"name": "invalid.md", "label": "input"} + * + * **foo** and __bar__. + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:13-1:20: Strong should use `*` as a marker + * + * @example {"name": "invalid.md", "label": "output", "setting": "!", "config": {"positionless": true}} + * + * 1:1: Invalid strong marker `!`: use either `'consistent'`, `'*'`, or `'_'` */ 'use strict'; diff --git a/lib/rules/table-cell-padding.js b/lib/rules/table-cell-padding.js index 197598b9..75f1ed43 100644 --- a/lib/rules/table-cell-padding.js +++ b/lib/rules/table-cell-padding.js @@ -12,21 +12,40 @@ * The default value, `consistent`, detects the first used cell padding * style, and will warn when a subsequent cells uses a different * style. - * @example - * + * + * @example {"name": "valid.md", "setting": "padded"} + * + * + * * | A | B | * | ----- | ----- | * | Alpha | Bravo | * - * + * @example {"name": "valid.md", "setting": "compact"} + * + * + * * |A |B | * |-----|-----| * |Alpha|Bravo| * - * + * @example {"name": "invalid.md", "label": "input"} + * + * + * * | A | B | * | -----| -----| * | Alpha| Bravo| + * + * @example {"name": "invalid.md", "label": "output"} + * + * 3:5: Cell should be padded, isn’t + * 3:9: Cell should be padded, isn’t + * 3:16: Cell should be padded, isn’t + * + * @example {"name": "invalid.md", "label": "output", "setting": "invalid", "config": {"positionless": true}} + * + * 1:1: Invalid table-cell-padding style `invalid` */ 'use strict'; diff --git a/lib/rules/table-pipe-alignment.js b/lib/rules/table-pipe-alignment.js index 8ebb9b2e..8fee7733 100644 --- a/lib/rules/table-pipe-alignment.js +++ b/lib/rules/table-pipe-alignment.js @@ -5,16 +5,23 @@ * @module table-pipe-alignment * @fileoverview * Warn when table pipes are not aligned. - * @example - * + * + * @example {"name": "valid.md"} + * * | A | B | * | ----- | ----- | * | Alpha | Bravo | * - * + * @example {"name": "invalid.md", "label": "input"} + * * | A | B | * | -- | -- | * | Alpha | Bravo | + * + * @example {"name": "invalid.md", "label": "output"} + * + * 3:9-3:10: Misaligned table fence + * 3:17-3:18: Misaligned table fence */ 'use strict'; diff --git a/lib/rules/table-pipes.js b/lib/rules/table-pipes.js index 681cbc23..6257ad3a 100644 --- a/lib/rules/table-pipes.js +++ b/lib/rules/table-pipes.js @@ -5,16 +5,25 @@ * @module table-pipes * @fileoverview * Warn when table rows are not fenced with pipes. - * @example - * + * + * @example {"name": "valid.md"} + * * | A | B | * | ----- | ----- | * | Alpha | Bravo | * - * + * @example {"name": "invalid.md", "label": "input"} + * * A | B * ----- | ----- * Alpha | Bravo + * + * @example {"name": "invalid.md", "label": "output"} + * + * 1:1: Missing initial pipe in table fence + * 1:10: Missing final pipe in table fence + * 3:1: Missing initial pipe in table fence + * 3:14: Missing final pipe in table fence */ 'use strict'; diff --git a/lib/rules/unordered-list-marker-style.js b/lib/rules/unordered-list-marker-style.js index e424b7d3..110588c2 100644 --- a/lib/rules/unordered-list-marker-style.js +++ b/lib/rules/unordered-list-marker-style.js @@ -13,22 +13,33 @@ * The default value, `consistent`, detects the first used list * style, and will warn when a subsequent list uses a different * style. - * @example - * - * - Foo - * - Bar * - * - * * Foo - * * Bar + * @example {"name": "valid.md", "setting": "*"} * - * - * + Foo - * + Bar + * * Foo * - * - * + Foo - * - Bar + * @example {"name": "valid.md", "setting": "-"} + * + * - Foo + * + * @example {"name": "valid.md", "setting": "+"} + * + * + Foo + * + * @example {"name": "invalid.md", "label": "input"} + * + * * Foo + * - Bar + * + Baz + * + * @example {"name": "invalid.md", "label": "output"} + * + * 2:1-2:6: Marker style should be `*` + * 3:1-3:6: Marker style should be `*` + * + * @example {"name": "invalid.md", "label": "output", "setting": "!", "config": {"positionless": true}} + * + * 1:1: Invalid unordered list-item marker style `!`: use either `'-'`, `'*'`, or `'+'` */ 'use strict'; diff --git a/package.json b/package.json index 8d181338..3c14557d 100644 --- a/package.json +++ b/package.json @@ -9,21 +9,26 @@ "validate", "remark" ], - "repository": { - "type": "git", - "url": "https://github.com/wooorm/remark-lint.git" - }, + "repository": "https://github.com/wooorm/remark-lint", "bugs": "https://github.com/wooorm/remark-lint/issues", "author": "Titus Wormer (http://wooorm.com)", "contributors": [ - "Titus Wormer (http://wooorm.com)" + "Titus Wormer (http://wooorm.com)", + "Stephan Schneider ", + "Ben Balter ", + "Danny Arnold ", + "Tony Brix ", + "Michael Mior ", + "Patrick Gilday ", + "Yoshua Wuyts ", + "YJ Yang ", + "Burak Yiğit Kaya " ], "dependencies": { "decamelize": "^1.0.0", "load-plugin": "^1.1.1", "mdast-util-heading-style": "^1.0.0", "mdast-util-to-string": "^1.0.0", - "npm-prefix": "^1.1.1", "plur": "^2.0.0", "remark-message-control": "^2.0.0", "trough": "^1.0.0", @@ -39,28 +44,35 @@ ], "devDependencies": { "browserify": "^13.0.0", + "chalk": "^1.1.3", "dox": "^0.8.0", "esmangle": "^1.0.0", - "istanbul": "^0.4.0", - "mocha": "^2.0.0", + "nyc": "^7.1.0", "remark": "^5.0.0", "remark-cli": "^1.0.0", "remark-comment-config": "^4.0.0", "remark-github": "^5.0.0", + "remark-lint-no-url-trailing-slash": "^2.0.0", "remark-toc": "^3.0.0", "remark-validate-links": "^4.0.0", - "mocha": "^2.0.0", - "vfile": "^1.0.0" + "strip-indent": "^1.0.0", + "tape": "^4.6.0", + "to-vfile": "^1.0.0", + "trim": "0.0.1", + "unist-builder": "^1.0.2", + "unist-util-remove-position": "^1.1.0", + "xo": "^0.16.0" }, "scripts": { - "build-rules": "node script/build-rule-documentation.js", + "build-index": "node script/build-index.js", + "build-rules": "node script/build-docs.js", "build-md": "remark . --quiet --frail", "build-bundle": "browserify index.js --bare -s remarkLint > remark-lint.js", "build-mangle": "esmangle remark-lint.js > remark-lint.min.js", - "build": "npm run build-rules && npm run build-md && npm run build-bundle && npm run build-mangle", + "build": "npm run build-md && npm run build-index && npm run build-rules && npm run build-bundle && npm run build-mangle", "lint": "xo", - "test-api": "mocha --check-leaks test/index.js", - "test-coverage": "istanbul cover _mocha -- test/index.js", + "test-api": "tape test/index.js", + "test-coverage": "nyc --reporter lcov tape test/index.js", "test": "npm run build && npm run lint && npm run test-coverage" }, "nyc": { @@ -87,10 +99,12 @@ "comment-config": null, "github": null, "toc": { - "tight": true + "tight": true, + "maxDepth": 2 }, "./": { - "no-missing-blank-lines": false + "no-missing-blank-lines": false, + "list-item-spacing": false }, "validate-links": null }, diff --git a/readme.md b/readme.md index 53a1cdab..7c4cfa44 100644 --- a/readme.md +++ b/readme.md @@ -4,8 +4,6 @@ [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat] - - **remark-lint** is a markdown code style linter. Another linter? Yes. Ensuring the markdown you (and contributors) write is of great quality will provide better rendering in all the different markdown parsers, and makes @@ -20,7 +18,6 @@ processor powered by [plugins][remark-plugins] (such as this one). * [Installation](#installation) * [Command line](#command-line) * [Programmatic](#programmatic) - * [remark.use(lint\[, options\])](#remarkuselint-options) * [Rules](#rules) * [Configuring remark-lint](#configuring-remark-lint) * [Using remark to fix your markdown](#using-remark-to-fix-your-markdown) @@ -93,7 +90,6 @@ console.log(report(file)); Now, running `node example.js` yields: ```txt - 1:1 warning Missing newline character at end of file final-newline 1:1-1:16 warning First heading level should be `1` first-heading-level 1:1-1:16 warning Don’t add a trailing `!` to headings no-heading-punctuation @@ -109,14 +105,18 @@ When processing a file, these warnings are available at `file.messages`, and look as follows: ```js -{ - file: '~/example.md', +{ [1:1-1:16: First heading level should be `1`] + message: 'First heading level should be `1`', + name: '1:1-1:16', + file: '', reason: 'First heading level should be `1`', line: 1, column: 1, - location: Position { start: [Object], end: [Object] }, - ruleId: 'first-heading-level', + location: { + start: { line: 1, column: 1, offset: 0 }, + end: { line: 1, column: 16, offset: 15 } }, fatal: false, + ruleId: 'first-heading-level', source: 'remark-lint' } ``` @@ -213,10 +213,20 @@ and I strongly suggest checking out how it can make your life easier :+1: Currently, **remark-lint** is integrated with Atom through [**linter-markdown**][linter-markdown]. +If you want to run all of **remark** from **Atom**, use +[**linter-remark**][linter-remark]. + +To run **remark**, optionally with **remark-lint** from **Gulp**, use +[**gulp-remark**][gulp-remark]. + I’m very interested in more integrations. Let me know if I can help. ## List of External Rules +External rules can be loaded through the [`external` setting][external]. + +Learn how to create and use external rules in [`doc/external.md`][doc-external]. + -[build-badge]: https://img.shields.io/travis/wooorm/remark-inline-links.svg +[build-badge]: https://img.shields.io/travis/wooorm/remark-lint.svg -[build-status]: https://travis-ci.org/wooorm/remark-inline-links +[build-status]: https://travis-ci.org/wooorm/remark-lint -[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/remark-inline-links.svg +[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/remark-lint.svg -[coverage-status]: https://codecov.io/github/wooorm/remark-inline-links +[coverage-status]: https://codecov.io/github/wooorm/remark-lint [chat-badge]: https://img.shields.io/gitter/room/wooorm/remark.svg [chat]: https://gitter.im/wooorm/remark -[releases]: https://github.com/wooorm/remark-inline-links/releases +[releases]: https://github.com/wooorm/remark-lint/releases [license]: LICENSE @@ -290,3 +300,11 @@ excluding `remark-lint-no-` or `remark-lint-` [vfile]: https://github.com/wooorm/vfile [vfile-message]: https://github.com/wooorm/vfile#vfilemessage + +[linter-remark]: https://github.com/wooorm/linter-remark + +[gulp-remark]: https://github.com/denysdovhan/gulp-remark + +[external]: doc/rules.md#external + +[doc-external]: doc/external.md diff --git a/script/additional.json b/script/additional.json deleted file mode 100755 index 887bd76f..00000000 --- a/script/additional.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "reset": { - "description": "By default, all rules are turned on unless explicitly set to `false`.\nWhen `reset: true`, the opposite is true: all rules are turned off,\nunless when given a non-nully and non-false value.\n\nOptions: `boolean`, default: `false`.", - "example": "\n```json\n{\n \"reset\": true,\n \"final-newline\": true\n}\n```\n" - }, - "external": { - "description": "External contains a list of extra rules to load.\nThese are, or refer to, an object mapping `ruleId`s to rules.\n\nNote that in node.js, a string can be given (a module\nname or a file), but in the browser an object must be passed in.\n\nWhen using a globally installed remark-lint, globally installed external\nrules are also loaded.\n\nThe prefix `remark-lint-` can be omitted.", - "example": "\n```json\n{\n \"external\": [\"foo\", \"bar\", \"baz\"]\n}\n```\n" - } -} diff --git a/script/build-docs.js b/script/build-docs.js new file mode 100644 index 00000000..831fb74e --- /dev/null +++ b/script/build-docs.js @@ -0,0 +1,184 @@ +/** + * @author Titus Wormer + * @copyright 2016 Titus Wormer + * @license MIT + * @module remark:lint:script:build-docs + * @fileoverview Creates `rules.md` files. + */ + +'use strict'; + +/* Dependencies. */ +var fs = require('fs'); +var path = require('path'); +var inspect = require('util').inspect; +var chalk = require('chalk'); +var remark = require('remark'); +var toc = require('remark-toc'); +var u = require('unist-builder'); +var rules = require('./util/rules'); +var rule = require('./util/rule'); + +/* Processor. */ +var markdown = remark().use(toc); + +/* Generate. */ +[path.join(process.cwd())].forEach(function (filePath) { + var children = []; + var all = rules(filePath); + var root; + + rules(filePath).forEach(function (rulePath) { + var info = rule(rulePath); + var tests = info.tests; + + children = children.concat( + u('heading', {depth: 2}, [ + u('inlineCode', info.ruleId) + ]), + markdown.parse(info.description).children + ); + + Object.keys(tests).forEach(function (setting) { + var fixtures = tests[setting]; + + Object.keys(fixtures).forEach(function (fileName) { + var fixture = fixtures[fileName]; + var label = inspect(JSON.parse(setting)); + var sentence; + + if (label === 'true') { + label = u('text', 'turned on'); + } else { + label = u('inlineCode', label); + } + + sentence = [ + u('text', 'When this rule is '), + label, + u('text', ', the following file\n'), + u('inlineCode', fileName), + u('text', ' is ') + ]; + + if (fixture.output.length) { + sentence.push( + u('strong', [u('text', 'not')]), + u('text', ' ') + ); + } + + sentence.push(u('text', 'ok:')); + + if (fixture.input == null) { + children.push( + u('paragraph', [ + u('text', 'When '), + label, + u('text', ' is passed in, the following error is given:') + ]) + ); + } else { + children.push( + u('paragraph', sentence), + u('code', {lang: 'markdown'}, fixture.input) + ); + } + + if (fixture.output.length) { + children.push( + u('code', {lang: 'text'}, fixture.output.join('\n')) + ); + } + }); + }); + }); + + root = u('root', [].concat( + markdown.parse([ + '', + '', + '# List of Rules', + '', + 'This document describes all (' + all.length + ')', + 'available rules, what they check for, examples of', + 'what they warn for, and how to fix their warnings.', + '', + 'Note: both camel-cased and dash-cases versions of rule id’s', + 'are supported in configuration objects:', + '', + '```json', + '{', + ' "final-newline": false', + '}', + '```', + '', + '...is treated the same as:', + '', + '```json', + '{', + ' "finalNewline": false', + '}', + '```', + '', + '## Table of Contents', + '', + '## `reset`', + '', + 'By default, all rules are turned on unless explicitly', + 'set to `false`. When `reset: true`, the opposite is', + '`true`: all rules are turned off, unless when given a', + 'non-nully and non-false value.', + '', + 'Options: `boolean`, default: `false`.', + '', + 'Explicitly activate rules:', + '', + '```json', + '{', + ' "reset": true,', + ' "final-newline": true', + '}', + '```', + '', + '## `external`', + '', + 'External contains a list of extra rules to load. These are,', + 'or refer to, an object mapping `ruleId`s to rules.', + '', + 'Note that in Node.js, a `string` can be given (a module name', + 'or a file path), but in the browser an object must be passed', + 'in.', + '', + 'When using a globally installed remark-lint, globally installed', + 'external rules are also loaded.', + '', + 'The prefix `remark-lint-` can be omitted.', + '', + '```js', + '{', + ' external: [\'no-empty-sections\', \'./a-local-file.js\']', + '}', + '```', + '', + 'Read more about external rules in', + '[`doc/external.md`](./external.md).', + '', + '' + ].join('\n')).children, + children + )); + + markdown.run(root); + + fs.writeFileSync( + path.join(filePath, 'doc', 'rules.md'), + markdown.stringify(root) + ); + + console.log( + chalk.green('✓') + + ' wrote docs for ' + all.length + ' rules in ' + + path.basename(filePath) + ); +}); diff --git a/script/build-index.js b/script/build-index.js new file mode 100644 index 00000000..5438263f --- /dev/null +++ b/script/build-index.js @@ -0,0 +1,52 @@ +/** + * @author Titus Wormer + * @copyright 2016 Titus Wormer + * @license MIT + * @module remark:lint:script:build-indices + * @fileoverview Creates `index.js` files for rules. + */ + +'use strict'; + +/* Dependencies. */ +var fs = require('fs'); +var path = require('path'); +var chalk = require('chalk'); +var rules = require('./util/rules'); + +/* Generate. */ +[path.join(process.cwd())].forEach(function (filePath) { + var base = path.resolve(filePath, 'lib', 'rules.js'); + var doc = []; + + rules(filePath).forEach(function (rulePath) { + var name = path.basename(rulePath); + var relative = './' + path.relative(path.dirname(base), rulePath); + + name = name.slice(0, name.indexOf('.')); + + doc.push( + ' \'' + name + '\': require(\'' + relative + '\')' + ); + }); + + doc = [].concat( + [ + '/* This file is generated. */', + '\'use strict\';', + 'module.exports = {' + ], + doc.join(',\n'), + [ + '};', + '' + ] + ).join('\n'); + + fs.writeFileSync(path.join(base), doc); + + console.log( + chalk.green('✓') + + ' wrote `index.js` in ' + path.basename(filePath) + ); +}); diff --git a/script/build-rule-documentation.js b/script/build-rule-documentation.js deleted file mode 100755 index e30729c9..00000000 --- a/script/build-rule-documentation.js +++ /dev/null @@ -1,181 +0,0 @@ -#!/usr/bin/env node -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:lint:script:build-rule-documentation - * @fileoverview Creates documentation for all exposed - * rules. - */ - -'use strict'; - -/* Dependencies. */ -var fs = require('fs'); -var path = require('path'); -var dox = require('dox'); -var remark = require('remark'); -var toc = require('remark-toc'); -var rules = require('../lib/rules'); -var additional = require('./additional.json'); - -/* Methods. */ -var exists = fs.existsSync; - -var children = []; - -/* Add main heading. */ -children.push({ - type: 'heading', - depth: 1, - children: [{ - type: 'text', - value: 'List of Rules' - }] -}); - -/* Add main description. */ -children.push( - { - type: 'paragraph', - children: [{ - type: 'text', - value: 'This document describes all available rules, what they\n' + - 'check for, examples of what they warn for, and how to\n' + - 'fix their warnings.' - }] - }, - { - type: 'paragraph', - children: [ - { - type: 'text', - value: 'See the readme for a ' - }, - { - type: 'link', - url: 'https://github.com/wooorm/remark-lint#list-of-external-rules', - children: [{ - type: 'text', - value: 'list of external rules' - }] - }, - { - type: 'text', - value: '.' - } - ] - } -); - -/* Add the rules heading. */ -children.push({ - type: 'heading', - depth: 2, - children: [{ - type: 'text', - value: 'Rules' - }] -}); - -/* Add a section on how to turn of rules. */ -children.push({ - type: 'paragraph', - children: [{ - type: 'text', - value: 'Remember that rules can always be turned off by\n' + - 'passing false. In addition, when reset is given, values can\n' + - 'be null or undefined in order to be ignored.' - }] -}); - -/* Add the table-of-contents heading. */ -children.push({ - type: 'heading', - depth: 3, - children: [{ - type: 'text', - value: 'Table of Contents' - }] -}); - -/* Add rules. */ -Object.keys(additional).sort() -.concat(Object.keys(rules).sort()) -.forEach(function (ruleId) { - var description; - var filePath; - var example; - var code; - var tags; - - filePath = path.join('lib', 'rules', ruleId + '.js'); - - if (exists(filePath)) { - code = fs.readFileSync(filePath, 'utf-8'); - tags = dox.parseComments(code)[0].tags; - description = find(tags, 'fileoverview'); - example = find(tags, 'example'); - - if (!description) { - throw new Error(ruleId + ' is missing a `@fileoverview`'); - } - - description = description.string; - example = example && example.string; - } else { - description = additional[ruleId].description; - example = additional[ruleId].example; - } - - children.push({ - type: 'heading', - depth: 3, - children: [{ - type: 'text', - value: ruleId - }] - }); - - if (example) { - children.push({ - type: 'code', - lang: 'md', - value: example - }); - } - - children = children.concat(remark().parse(description).children); -}); - -/* Node. */ -var node = {type: 'root', children: children}; - -/* Add toc. */ -remark().use(toc).run(node); - -/* Write. */ -fs.writeFileSync('doc/rules.md', remark().stringify(node)); - -/** - * Find the first tag in `tags` with a type set to `key`. - * - * @param {Array.} tags - List of tags. - * @param {string} key - Type of tag. - * @return {Object?} - Tag, when found. - */ -function find(tags, key) { - var value = null; - - tags.some(function (tag) { - if (tag && tag.type === key) { - value = tag; - - return true; - } - - return false; - }); - - return value; -} diff --git a/script/util/rule.js b/script/util/rule.js new file mode 100755 index 00000000..e9344e54 --- /dev/null +++ b/script/util/rule.js @@ -0,0 +1,159 @@ +/** + * @author Titus Wormer + * @copyright 2016 Titus Wormer + * @license MIT + * @module remark:lint:script:rule + * @fileoverview Get information for a rule. + */ + +'use strict'; + +/* Dependencies. */ +var fs = require('fs'); +var path = require('path'); +var dox = require('dox'); +var strip = require('strip-indent'); +var trim = require('trim'); + +/* Expose. */ +module.exports = ruleSync; + +/** + * Get information for a rule at `filePath`. + * + * @param {string} filePath - Path to rule. + */ +function ruleSync(filePath) { + var ruleId = path.basename(filePath); + var result = {}; + var tests = {}; + var description; + var code; + var tags; + var name; + + ruleId = ruleId.slice(0, ruleId.indexOf('.')); + + code = fs.readFileSync(filePath, 'utf-8'); + tags = dox.parseComments(code)[0].tags; + description = find(tags, 'fileoverview'); + name = find(tags, 'module'); + + /* istanbul ignore if */ + if (name !== ruleId) { + throw new Error( + ruleId + ' has an invalid `@module`: ' + name + ); + } + + /* istanbul ignore if */ + if (!description) { + throw new Error(ruleId + ' is missing a `@fileoverview`'); + } + + description = strip(description); + + result.ruleId = ruleId; + result.description = trim(description); + result.tests = tests; + result.filePath = filePath; + + findAll(tags, 'example').map(strip).forEach(function (example) { + var lines = example.split('\n'); + var value = strip(lines.slice(1).join('\n')); + var info; + var setting; + var context; + var name; + + try { + info = JSON.parse(lines[0]); + } catch (err) { + /* istanbul ignore next */ + throw new Error( + 'Could not parse example in ' + ruleId + ':\n' + err.stack + ); + } + + setting = JSON.stringify(info.setting || true); + context = tests[setting]; + name = info.name; + + if (!context) { + context = tests[setting] = []; + } + + if (!info.label) { + context[name] = { + config: info.config || {}, + setting: setting, + input: value, + output: [] + }; + + return; + } + + /* istanbul ignore if */ + if (info.label !== 'input' && info.label !== 'output') { + throw new Error( + 'Expected `input` or `ouput` for `label` in ' + + ruleId + ', not `' + info.label + '`' + ); + } + + if (!context[name]) { + context[name] = {config: info.config || {}}; + } + + context[name].setting = setting; + + if (info.label === 'output') { + value = value.split('\n'); + } + + context[name][info.label] = value; + }); + + return result; +} + +/** + * Find the first tag in `tags` with a type set to `key`. + * + * @param {Array.} tags - List of tags. + * @param {string} key - Type of tag. + * @return {Object?} - Tag, when found. + */ +function find(tags, key) { + var value = null; + + tags.some(function (tag) { + if (tag && tag.type === key) { + value = tag; + + return true; + } + + return false; + }); + + return value && value.string; +} + +/** + * Find the first tag in `tags` with a type set to `key`. + * + * @param {Array.} tags - List of tags. + * @param {string} key - Type of tag. + * @return {Object?} - Tag, when found. + */ +function findAll(tags, key) { + return tags + .filter(function (tag) { + return tag && tag.type === key; + }) + .map(function (tag) { + return tag.string; + }); +} diff --git a/script/util/rules.js b/script/util/rules.js new file mode 100644 index 00000000..fc14b5ab --- /dev/null +++ b/script/util/rules.js @@ -0,0 +1,33 @@ +/** + * @author Titus Wormer + * @copyright 2016 Titus Wormer + * @license MIT + * @module remark:lint:script:util:rules + * @fileoverview Get a list of rules. + */ + +'use strict'; + +/* Dependencies. */ +var fs = require('fs'); +var path = require('path'); + +/* Expose. */ +module.exports = rulesSync; + +/** + * Get a list of rules in a package. + * + * @param {string} filePath - Package to look into. + */ +function rulesSync(filePath) { + var basePath = path.join(filePath, 'lib', 'rules'); + + return fs.readdirSync(basePath) + .filter(function (basename) { + return path.extname(basename) === '.js'; + }) + .map(function (basename) { + return path.join(basePath, basename); + }); +} diff --git a/test/clean.js b/test/clean.js deleted file mode 100644 index a7dd8b0c..00000000 --- a/test/clean.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:lint:test:clean - * @fileoverview remark plug-in used to remove positional - * information from remark’s syntax tree. - * @todo Externalise into its own repository. - */ - -'use strict'; - -/* Dependencies. */ -var visit = require('unist-util-visit'); - -/** - * Delete the `position` key for each node. - * - * @param {Node} ast - Root node. - */ -function transformer(ast) { - visit(ast, function (node) { - node.position = undefined; - }); -} - -/** - * Return `transformer`. - * - * @return {Function} - See `transformer`. - */ -function attacher() { - return transformer; -} - -/* - * Expose. - */ - -module.exports = attacher; diff --git a/test/external/index.js b/test/external/index.js deleted file mode 100644 index 710fd583..00000000 --- a/test/external/index.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:lint:test:external - * @fileoverview Map of example external rules. - */ - -'use strict'; - -/* eslint-env commonjs */ - -/* - * Expose. - */ - -module.exports = { - 'no-lorem': require('./no-lorem') -}; diff --git a/test/external/no-lorem.js b/test/external/no-lorem.js deleted file mode 100644 index 44fdc487..00000000 --- a/test/external/no-lorem.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:lint:test:no-lorem - * @fileoverview - * Warn when `lorem` is used in a document. - * @example - * - * lorem - * - * - * ipsum - */ - -'use strict'; - -/* eslint-env commonjs */ - -/* - * Dependencies. - */ - -var vfileLocation = require('vfile-location'); - -/** - * Warn when `lorem` is used in a document. - * - * @param {Node} ast - Root node. - * @param {File} file - Virtual file. - * @param {*} preferred - Ignored. - * @param {Function} done - Callback. - */ -function noLorem(ast, file, preferred, done) { - var content = file.toString(); - var expression = /\blorem\b/gi; - var location = vfileLocation(file); - - while (expression.exec(content)) { - file.warn('Do not use lorem', location.toPosition(expression.lastIndex)); - } - - done(); -} - -/* - * Expose. - */ - -module.exports = noLorem; diff --git a/test/fixtures/-file-name-initial-dash.md b/test/fixtures/-file-name-initial-dash.md deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/blockquote-indentation-2.md b/test/fixtures/blockquote-indentation-2.md deleted file mode 100644 index b5aa97c9..00000000 --- a/test/fixtures/blockquote-indentation-2.md +++ /dev/null @@ -1,13 +0,0 @@ -> Foo - - - -> Bar - - - -> Baz - - - -> diff --git a/test/fixtures/blockquote-indentation-4.md b/test/fixtures/blockquote-indentation-4.md deleted file mode 100644 index 85b377c7..00000000 --- a/test/fixtures/blockquote-indentation-4.md +++ /dev/null @@ -1,13 +0,0 @@ -> Foo - - - -> Bar - - - -> Baz - - - -> diff --git a/test/fixtures/carriage-returns.md b/test/fixtures/carriage-returns.md deleted file mode 100644 index 3209051c..00000000 --- a/test/fixtures/carriage-returns.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: "Example # " ---- -# Establishing an example # - -Description. diff --git a/test/fixtures/checkbox-character-style-lower-x.md b/test/fixtures/checkbox-character-style-lower-x.md deleted file mode 100644 index 5d77f229..00000000 --- a/test/fixtures/checkbox-character-style-lower-x.md +++ /dev/null @@ -1,7 +0,0 @@ -* [x] Foo; - -- [x] Bar; - -+ [x] Baz; - -* [x] diff --git a/test/fixtures/checkbox-character-style-space.md b/test/fixtures/checkbox-character-style-space.md deleted file mode 100644 index bd2be29f..00000000 --- a/test/fixtures/checkbox-character-style-space.md +++ /dev/null @@ -1,7 +0,0 @@ -* [ ] Foo; - -- [ ] Bar; - -+ [ ] Baz; - -* [ ] diff --git a/test/fixtures/checkbox-character-style-tab.md b/test/fixtures/checkbox-character-style-tab.md deleted file mode 100644 index e0f2e573..00000000 --- a/test/fixtures/checkbox-character-style-tab.md +++ /dev/null @@ -1,7 +0,0 @@ -* [ ] Foo; - -- [ ] Bar; - -+ [ ] Baz; - -* [ ] diff --git a/test/fixtures/checkbox-character-style-upper-x.md b/test/fixtures/checkbox-character-style-upper-x.md deleted file mode 100644 index dd745875..00000000 --- a/test/fixtures/checkbox-character-style-upper-x.md +++ /dev/null @@ -1,7 +0,0 @@ -* [X] Foo; - -- [X] Bar; - -+ [X] Baz; - -* [X] diff --git a/test/fixtures/checkbox-content-indent-invalid.md b/test/fixtures/checkbox-content-indent-invalid.md deleted file mode 100644 index 885c251c..00000000 --- a/test/fixtures/checkbox-content-indent-invalid.md +++ /dev/null @@ -1,11 +0,0 @@ -* [x] This starts with two spaces; - -- [ ] This with three; - -- [ ] This with a space and a tab; - -+ [X] Below is trailing white space; - -* [x] - -Foo. diff --git a/test/fixtures/checkbox-content-indent-valid.md b/test/fixtures/checkbox-content-indent-valid.md deleted file mode 100644 index f1fb5f6a..00000000 --- a/test/fixtures/checkbox-content-indent-valid.md +++ /dev/null @@ -1,15 +0,0 @@ -- [x] One; - -+ [X] Two; - -* [ ] Three; - -- [ ] Four; - -- [x] Five (code); - -+ [X] Below is a single white space; - -* [x] - -Foo. diff --git a/test/fixtures/code-style-fenced.md b/test/fixtures/code-style-fenced.md deleted file mode 100644 index a25b7fb5..00000000 --- a/test/fixtures/code-style-fenced.md +++ /dev/null @@ -1,11 +0,0 @@ -Some fenced code block: - -``` -foo -``` - -And one with language flag: - -```barscript -bar -``` diff --git a/test/fixtures/code-style-indented.md b/test/fixtures/code-style-indented.md deleted file mode 100644 index ebb7e7aa..00000000 --- a/test/fixtures/code-style-indented.md +++ /dev/null @@ -1,7 +0,0 @@ -Some indented code block: - - foo - -And another: - - bar diff --git a/test/fixtures/comments-disable-multiple.md b/test/fixtures/comments-disable-multiple.md deleted file mode 100644 index 915734b1..00000000 --- a/test/fixtures/comments-disable-multiple.md +++ /dev/null @@ -1,13 +0,0 @@ -# Hello - - - -## Hello - -Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello. - - - -### Hello - -Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello. diff --git a/test/fixtures/comments-disable.md b/test/fixtures/comments-disable.md deleted file mode 100644 index a4993fb0..00000000 --- a/test/fixtures/comments-disable.md +++ /dev/null @@ -1,7 +0,0 @@ - - -alpha bravo charlie delta echo foxtrot golf hotel india julliet kilo lima mike november. - - - -alpha bravo charlie delta echo foxtrot golf hotel india julliet kilo lima mike november. diff --git a/test/fixtures/comments-duplicates.md b/test/fixtures/comments-duplicates.md deleted file mode 100644 index 9cadb723..00000000 --- a/test/fixtures/comments-duplicates.md +++ /dev/null @@ -1,7 +0,0 @@ - - -alpha bravo charlie delta echo foxtrot golf hotel india julliet kilo lima mike november. - - - -alpha bravo charlie delta echo foxtrot golf hotel india julliet kilo lima mike november. diff --git a/test/fixtures/comments-enable.md b/test/fixtures/comments-enable.md deleted file mode 100644 index 29a7330b..00000000 --- a/test/fixtures/comments-enable.md +++ /dev/null @@ -1,7 +0,0 @@ - - -alpha bravo charlie delta echo foxtrot golf hotel india julliet kilo lima mike november. - - - -alpha bravo charlie delta echo foxtrot golf hotel india julliet kilo lima mike november. diff --git a/test/fixtures/comments-inline.md b/test/fixtures/comments-inline.md deleted file mode 100644 index b8b8f80a..00000000 --- a/test/fixtures/comments-inline.md +++ /dev/null @@ -1 +0,0 @@ -Foo This is HTML. diff --git a/test/fixtures/comments-invalid-keyword.md b/test/fixtures/comments-invalid-keyword.md deleted file mode 100644 index e8405560..00000000 --- a/test/fixtures/comments-invalid-keyword.md +++ /dev/null @@ -1,5 +0,0 @@ -Intro. - - - -Outro. diff --git a/test/fixtures/comments-invalid-rule-id.md b/test/fixtures/comments-invalid-rule-id.md deleted file mode 100644 index 6d674c48..00000000 --- a/test/fixtures/comments-invalid-rule-id.md +++ /dev/null @@ -1,5 +0,0 @@ -Intro. - - - -Outro. diff --git a/test/fixtures/comments-none.md b/test/fixtures/comments-none.md deleted file mode 100644 index 24cda23d..00000000 --- a/test/fixtures/comments-none.md +++ /dev/null @@ -1 +0,0 @@ -Things should not fail without warnings, nor comments. Alpha bravo charlie delta echo foxtrot. diff --git a/test/fixtures/definition-case-invalid.md b/test/fixtures/definition-case-invalid.md deleted file mode 100644 index f051119e..00000000 --- a/test/fixtures/definition-case-invalid.md +++ /dev/null @@ -1,3 +0,0 @@ -This document has definitions with improper spacing and casing. - -[Invalid]: http://example.com/favicon.ico "Example Domain" diff --git a/test/fixtures/definition-case-valid.md b/test/fixtures/definition-case-valid.md deleted file mode 100644 index 43f2fb68..00000000 --- a/test/fixtures/definition-case-valid.md +++ /dev/null @@ -1,3 +0,0 @@ -This document has definitions with proper spacing and casing. - -[valid]: http://example.com/favicon.ico "Example Domain" diff --git a/test/fixtures/definition-spacing-invalid.md b/test/fixtures/definition-spacing-invalid.md deleted file mode 100644 index 57b57433..00000000 --- a/test/fixtures/definition-spacing-invalid.md +++ /dev/null @@ -1,3 +0,0 @@ -This document has definitions with improper spacing and casing. - -[another invalid]: http://example.org/favicon.ico "Example Domain" diff --git a/test/fixtures/definition-spacing-valid.md b/test/fixtures/definition-spacing-valid.md deleted file mode 100644 index b65290b9..00000000 --- a/test/fixtures/definition-spacing-valid.md +++ /dev/null @@ -1,3 +0,0 @@ -This document has definitions with proper spacing and casing. - -[another valid]: http://example.org/favicon.ico "Example Domain" diff --git a/test/fixtures/emphasis-marker-asterisk-underscore.md b/test/fixtures/emphasis-marker-asterisk-underscore.md deleted file mode 100644 index 256c3565..00000000 --- a/test/fixtures/emphasis-marker-asterisk-underscore.md +++ /dev/null @@ -1,3 +0,0 @@ -*foo* - -_bar_ diff --git a/test/fixtures/emphasis-marker-asterisk.md b/test/fixtures/emphasis-marker-asterisk.md deleted file mode 100644 index 4ac70c5d..00000000 --- a/test/fixtures/emphasis-marker-asterisk.md +++ /dev/null @@ -1,3 +0,0 @@ -*foo* - -*bar* diff --git a/test/fixtures/emphasis-marker-underscore-asterisk.md b/test/fixtures/emphasis-marker-underscore-asterisk.md deleted file mode 100644 index 5c58ea2e..00000000 --- a/test/fixtures/emphasis-marker-underscore-asterisk.md +++ /dev/null @@ -1,3 +0,0 @@ -_foo_ - -*bar* diff --git a/test/fixtures/emphasis-marker-underscore.md b/test/fixtures/emphasis-marker-underscore.md deleted file mode 100644 index 6dd4f372..00000000 --- a/test/fixtures/emphasis-marker-underscore.md +++ /dev/null @@ -1,3 +0,0 @@ -_foo_ - -_bar_ diff --git a/test/fixtures/empty.md b/test/fixtures/empty.md deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/fenced-code-flag-invalid.md b/test/fixtures/fenced-code-flag-invalid.md deleted file mode 100644 index 23ae4a08..00000000 --- a/test/fixtures/fenced-code-flag-invalid.md +++ /dev/null @@ -1,5 +0,0 @@ -A missing code flag. - -``` -foo -``` diff --git a/test/fixtures/fenced-code-flag-unknown.md b/test/fixtures/fenced-code-flag-unknown.md deleted file mode 100644 index eb098bd7..00000000 --- a/test/fixtures/fenced-code-flag-unknown.md +++ /dev/null @@ -1,5 +0,0 @@ -A missing code flag. - -```bar -foo -``` diff --git a/test/fixtures/fenced-code-flag-valid.md b/test/fixtures/fenced-code-flag-valid.md deleted file mode 100644 index 0a818450..00000000 --- a/test/fixtures/fenced-code-flag-valid.md +++ /dev/null @@ -1,7 +0,0 @@ -A nice code flag. - -```foo -foo -``` - - foo diff --git a/test/fixtures/fenced-code-marker-mismatched.md b/test/fixtures/fenced-code-marker-mismatched.md deleted file mode 100644 index f73cd631..00000000 --- a/test/fixtures/fenced-code-marker-mismatched.md +++ /dev/null @@ -1,9 +0,0 @@ -```foo -bar(); -``` - -~~~ -baz(); -~~~ - - qux(); diff --git a/test/fixtures/fenced-code-marker-tick.md b/test/fixtures/fenced-code-marker-tick.md deleted file mode 100644 index b1b9e703..00000000 --- a/test/fixtures/fenced-code-marker-tick.md +++ /dev/null @@ -1,9 +0,0 @@ -```foo -bar(); -``` - -``` -baz(); -``` - - qux(); diff --git a/test/fixtures/fenced-code-marker-tilde.md b/test/fixtures/fenced-code-marker-tilde.md deleted file mode 100644 index 3bc5419d..00000000 --- a/test/fixtures/fenced-code-marker-tilde.md +++ /dev/null @@ -1,9 +0,0 @@ -~~~foo -bar(); -~~~ - -~~~ -baz(); -~~~ - - qux(); diff --git a/test/fixtures/file-extension-markdown.markdown b/test/fixtures/file-extension-markdown.markdown deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/file-extension-md.md b/test/fixtures/file-extension-md.md deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/file-name characters.md b/test/fixtures/file-name characters.md deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/file-name--consecutive-dashes.md b/test/fixtures/file-name--consecutive-dashes.md deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/file-name-Upper-case.md b/test/fixtures/file-name-Upper-case.md deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/file-name-final-dash-.md b/test/fixtures/file-name-final-dash-.md deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/file-without-extension b/test/fixtures/file-without-extension deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/final-definition-invalid.md b/test/fixtures/final-definition-invalid.md deleted file mode 100644 index 80e45ad0..00000000 --- a/test/fixtures/final-definition-invalid.md +++ /dev/null @@ -1,7 +0,0 @@ -[valid]: http://example.com/favicon.ico "Example.domain" - -This document has the definitions in some weird... - -[another]: http://example.org/favicon.ico "Example.domain" - -...places in the document. diff --git a/test/fixtures/final-definition-valid.md b/test/fixtures/final-definition-valid.md deleted file mode 100644 index 6ea6cd36..00000000 --- a/test/fixtures/final-definition-valid.md +++ /dev/null @@ -1,4 +0,0 @@ -This document has the definitions properly at the end of the document. - -[valid]: http://example.com/favicon.ico "Example.domain" -[another]: http://example.org/favicon.ico "Example.domain" diff --git a/test/fixtures/final-newline-invalid.md b/test/fixtures/final-newline-invalid.md deleted file mode 100644 index ce85b46a..00000000 --- a/test/fixtures/final-newline-invalid.md +++ /dev/null @@ -1 +0,0 @@ -Foo bar. \ No newline at end of file diff --git a/test/fixtures/final-newline-valid.md b/test/fixtures/final-newline-valid.md deleted file mode 100644 index b7035dc3..00000000 --- a/test/fixtures/final-newline-valid.md +++ /dev/null @@ -1 +0,0 @@ -Foo bar. diff --git a/test/fixtures/first-heading-level-invalid-second.md b/test/fixtures/first-heading-level-invalid-second.md deleted file mode 100644 index ad0eb404..00000000 --- a/test/fixtures/first-heading-level-invalid-second.md +++ /dev/null @@ -1 +0,0 @@ -# Valid diff --git a/test/fixtures/first-heading-level-invalid.md b/test/fixtures/first-heading-level-invalid.md deleted file mode 100644 index 11df5383..00000000 --- a/test/fixtures/first-heading-level-invalid.md +++ /dev/null @@ -1 +0,0 @@ -## Invalid diff --git a/test/fixtures/first-heading-level-valid-second.md b/test/fixtures/first-heading-level-valid-second.md deleted file mode 100644 index dfeb664e..00000000 --- a/test/fixtures/first-heading-level-valid-second.md +++ /dev/null @@ -1 +0,0 @@ -## Valid diff --git a/test/fixtures/first-heading-level-valid.md b/test/fixtures/first-heading-level-valid.md deleted file mode 100644 index ad0eb404..00000000 --- a/test/fixtures/first-heading-level-valid.md +++ /dev/null @@ -1 +0,0 @@ -# Valid diff --git a/test/fixtures/gaps-toc-final.md b/test/fixtures/gaps-toc-final.md deleted file mode 100644 index 66a1eea7..00000000 --- a/test/fixtures/gaps-toc-final.md +++ /dev/null @@ -1,10 +0,0 @@ -# Foo - -## Table of Contents - -This paragraph is removed by remark-toc. However, a rule such as -`no-consecutive-blank-lines` cannot see this node as it has no -position. **remark-lint** knows that this node has no positional -information and can ignore the space between the ToC heading -and end of the document, thus ignoring any messages between -nodes. diff --git a/test/fixtures/gaps-toc-internal.md b/test/fixtures/gaps-toc-internal.md deleted file mode 100644 index 8fc7b378..00000000 --- a/test/fixtures/gaps-toc-internal.md +++ /dev/null @@ -1,11 +0,0 @@ -# Foo - -## Table of Contents - -This paragraph is removed by remark-toc. However, a rule such as -`no-consecutive-blank-lines` cannot see this node as it has no -position. **remark-lint** knows that this node has no positional -information and can ignore the space between the ToC heading -and next node, thus ignoring any messages between nodes. - -## Bar diff --git a/test/fixtures/hard-break-spaces-invalid.md b/test/fixtures/hard-break-spaces-invalid.md deleted file mode 100644 index bda059b4..00000000 --- a/test/fixtures/hard-break-spaces-invalid.md +++ /dev/null @@ -1,8 +0,0 @@ -Here’s one that uses too -much white space. - -- A bullet with three trailing spaces - Next line. - -And here’s a commonmark\ -break. diff --git a/test/fixtures/hard-break-spaces-valid.md b/test/fixtures/hard-break-spaces-valid.md deleted file mode 100644 index 5ca080bb..00000000 --- a/test/fixtures/hard-break-spaces-valid.md +++ /dev/null @@ -1,8 +0,0 @@ -Here’s one that uses too -just enough white space. - -- A bullet with two trailing spaces - Next line. - -And here’s another -break. diff --git a/test/fixtures/heading-increment-invalid-blockquote.md b/test/fixtures/heading-increment-invalid-blockquote.md deleted file mode 100644 index 61905e05..00000000 --- a/test/fixtures/heading-increment-invalid-blockquote.md +++ /dev/null @@ -1,3 +0,0 @@ -> # Foo -> -> ### Bar diff --git a/test/fixtures/heading-increment-invalid-list.md b/test/fixtures/heading-increment-invalid-list.md deleted file mode 100644 index 2c057ed5..00000000 --- a/test/fixtures/heading-increment-invalid-list.md +++ /dev/null @@ -1,3 +0,0 @@ -* # Foo - - ### Bar diff --git a/test/fixtures/heading-increment-invalid.md b/test/fixtures/heading-increment-invalid.md deleted file mode 100644 index 4e75f6ae..00000000 --- a/test/fixtures/heading-increment-invalid.md +++ /dev/null @@ -1,3 +0,0 @@ -# Foo - -### Bar diff --git a/test/fixtures/heading-length-normal.md b/test/fixtures/heading-length-normal.md deleted file mode 100644 index 311271dc..00000000 --- a/test/fixtures/heading-length-normal.md +++ /dev/null @@ -1 +0,0 @@ -# Normal diff --git a/test/fixtures/heading-length-quite-short.md b/test/fixtures/heading-length-quite-short.md deleted file mode 100644 index a4f04dd0..00000000 --- a/test/fixtures/heading-length-quite-short.md +++ /dev/null @@ -1 +0,0 @@ -# This heading is quite long diff --git a/test/fixtures/heading-length-too-long.md b/test/fixtures/heading-length-too-long.md deleted file mode 100644 index 222d8ac8..00000000 --- a/test/fixtures/heading-length-too-long.md +++ /dev/null @@ -1 +0,0 @@ -# This heading is longer than 60 characters longer longer longer diff --git a/test/fixtures/heading-nesting-initial.md b/test/fixtures/heading-nesting-initial.md deleted file mode 100644 index 11df5383..00000000 --- a/test/fixtures/heading-nesting-initial.md +++ /dev/null @@ -1 +0,0 @@ -## Invalid diff --git a/test/fixtures/heading-style-atx-closed.md b/test/fixtures/heading-style-atx-closed.md deleted file mode 100644 index 528c3491..00000000 --- a/test/fixtures/heading-style-atx-closed.md +++ /dev/null @@ -1,11 +0,0 @@ -# ATX-closed # - -## ATX-closed ## - -### ATX-closed ### - -#### ATX-closed #### - -##### ATX-closed ##### - -###### ATX-closed ###### diff --git a/test/fixtures/heading-style-atx.md b/test/fixtures/heading-style-atx.md deleted file mode 100644 index 3e6d7f68..00000000 --- a/test/fixtures/heading-style-atx.md +++ /dev/null @@ -1,13 +0,0 @@ -# ATX - -## ATX - -### ATX / Setext - -#### ATX / Setext - -##### ATX / Setext - -###### ATX / Setext - -Note that the missing spaces aren’t pretty: but they’re there to test against :) diff --git a/test/fixtures/heading-style-empty.md b/test/fixtures/heading-style-empty.md deleted file mode 100644 index 8bbfbec9..00000000 --- a/test/fixtures/heading-style-empty.md +++ /dev/null @@ -1,11 +0,0 @@ -# # - -## - -### ### - -#### - -##### ##### - -###### diff --git a/test/fixtures/heading-style-not-consistent.md b/test/fixtures/heading-style-not-consistent.md deleted file mode 100644 index c161bee8..00000000 --- a/test/fixtures/heading-style-not-consistent.md +++ /dev/null @@ -1,12 +0,0 @@ -# ATX - -Setext ------ - -### ATX Closed ### - -#### ATX / Setext - -##### ATX Closed ###### - -###### ATX / Setext diff --git a/test/fixtures/heading-style-setext.md b/test/fixtures/heading-style-setext.md deleted file mode 100644 index 5ddb7ccb..00000000 --- a/test/fixtures/heading-style-setext.md +++ /dev/null @@ -1,13 +0,0 @@ -Setext -===== - -Setext ------ - -### ATX / Setext - -#### ATX / Setext - -##### ATX / Setext - -###### ATX / Setext diff --git a/test/fixtures/link-title-style-double.md b/test/fixtures/link-title-style-double.md deleted file mode 100644 index 21572ca9..00000000 --- a/test/fixtures/link-title-style-double.md +++ /dev/null @@ -1,5 +0,0 @@ -[foo bar baz]( "example") - -![foo bar baz]( "example") - -[foo bar baz]: "example" diff --git a/test/fixtures/link-title-style-missing.md b/test/fixtures/link-title-style-missing.md deleted file mode 100644 index f0fc5616..00000000 --- a/test/fixtures/link-title-style-missing.md +++ /dev/null @@ -1,5 +0,0 @@ -[foo bar baz]() - -![foo bar baz]() - -[foo bar baz]: diff --git a/test/fixtures/link-title-style-parentheses.md b/test/fixtures/link-title-style-parentheses.md deleted file mode 100644 index 33544d66..00000000 --- a/test/fixtures/link-title-style-parentheses.md +++ /dev/null @@ -1,5 +0,0 @@ -[foo bar baz]( (example)) - -![foo bar baz]( (example)) - -[foo bar baz]: (example) diff --git a/test/fixtures/link-title-style-single.md b/test/fixtures/link-title-style-single.md deleted file mode 100644 index ff4c73d5..00000000 --- a/test/fixtures/link-title-style-single.md +++ /dev/null @@ -1,5 +0,0 @@ -[foo bar baz]( 'example') - -![foo bar baz]( 'example') - -[foo bar baz]: 'example' diff --git a/test/fixtures/link-title-style-trailing-white-space.md b/test/fixtures/link-title-style-trailing-white-space.md deleted file mode 100644 index 607f9322..00000000 --- a/test/fixtures/link-title-style-trailing-white-space.md +++ /dev/null @@ -1,5 +0,0 @@ -[foo bar baz]( "example" ) - -![foo bar baz]( 'example' ) - -[foo bar baz]: (example) diff --git a/test/fixtures/list-item-bullet-indent-invalid.md b/test/fixtures/list-item-bullet-indent-invalid.md deleted file mode 100644 index b8114ec8..00000000 --- a/test/fixtures/list-item-bullet-indent-invalid.md +++ /dev/null @@ -1,4 +0,0 @@ -Some text - - * List item - * List item diff --git a/test/fixtures/list-item-bullet-indent-valid.md b/test/fixtures/list-item-bullet-indent-valid.md deleted file mode 100644 index 6e4fc7e9..00000000 --- a/test/fixtures/list-item-bullet-indent-valid.md +++ /dev/null @@ -1,4 +0,0 @@ -Some text - -* List item -* List item diff --git a/test/fixtures/list-item-content-indent-invalid.md b/test/fixtures/list-item-content-indent-invalid.md deleted file mode 100644 index 929562ea..00000000 --- a/test/fixtures/list-item-content-indent-invalid.md +++ /dev/null @@ -1,19 +0,0 @@ -* List item - - * Nested list item indented by 3 spaces - - - -* List item - - * [x] with checked checkbox. - - - -1. Foo - 1. Bar - - - -1. [x] Foo - 1. Bar diff --git a/test/fixtures/list-item-content-indent-valid.md b/test/fixtures/list-item-content-indent-valid.md deleted file mode 100644 index 74adbc40..00000000 --- a/test/fixtures/list-item-content-indent-valid.md +++ /dev/null @@ -1,20 +0,0 @@ -* List item - - * Nested list item indented by 4 spaces - - - -* List item - - * [x] with checked checkbox. - - - -1. Foo - 1. Bar - - - -* [ ] [alpha](http://bravo.com) - * [ ] charlie - * [ ] delta diff --git a/test/fixtures/list-item-indent-mixed.md b/test/fixtures/list-item-indent-mixed.md deleted file mode 100644 index 1020465f..00000000 --- a/test/fixtures/list-item-indent-mixed.md +++ /dev/null @@ -1,50 +0,0 @@ -Foo: - -- item 1 -- item 2 -- item 3 - -Bar: - -1. item 1 -2. item 2 -3. item 3 - -Baz: - -- item - 1 - -- item - 2 - -- item - 3 - -Qux: - -1. item - 1 - -2. item - 2 - -3. item - 3 - -And an extra test for numbers: - -9. foo -10. bar -11. baz - -...and loose: - -9. foo - 1 - -10. bar - 2 - -11. baz - 3 diff --git a/test/fixtures/list-item-indent-space.md b/test/fixtures/list-item-indent-space.md deleted file mode 100644 index 4d882faf..00000000 --- a/test/fixtures/list-item-indent-space.md +++ /dev/null @@ -1,63 +0,0 @@ -Foo: - -- item 1 -- item 2 -- item 3 - -Bar: - -1. item 1 -2. item 2 -3. item 3 - -Baz: - -- item - 1 - -- item - 2 - -- item - 3 - -Qux: - -1. item - 1 - -2. item - 2 - -3. item - 3 - -And an extra test for numbers: - -9. foo -10. bar -11. baz - -...and loose: - -9. foo - 1 - -10. bar - 2 - -11. baz - 3 - -And many items: - -1. One -1. Two -1. Three -1. Four -1. Five -1. Six -1. Seven -1. Eight -1. Nine -1. Ten diff --git a/test/fixtures/list-item-indent-tab-size.md b/test/fixtures/list-item-indent-tab-size.md deleted file mode 100644 index 8b46f742..00000000 --- a/test/fixtures/list-item-indent-tab-size.md +++ /dev/null @@ -1,50 +0,0 @@ -Foo: - -- item 1 -- item 2 -- item 3 - -Bar: - -1. item 1 -2. item 2 -3. item 3 - -Baz: - -- item - 1 - -- item - 2 - -- item - 3 - -Qux: - -1. item - 1 - -2. item - 2 - -3. item - 3 - -And an extra test for numbers - -9. foo -10. bar -11. baz - -...and loose: - -9. foo - 1 - -10. bar - 2 - -11. baz - 3 diff --git a/test/fixtures/list-item-marker-asterisk.md b/test/fixtures/list-item-marker-asterisk.md deleted file mode 100644 index 544f94cf..00000000 --- a/test/fixtures/list-item-marker-asterisk.md +++ /dev/null @@ -1,10 +0,0 @@ -* item 1 - - -* item 1 - - -> * item 1 - - -> * item 1 diff --git a/test/fixtures/list-item-marker-dash.md b/test/fixtures/list-item-marker-dash.md deleted file mode 100644 index bea0b692..00000000 --- a/test/fixtures/list-item-marker-dash.md +++ /dev/null @@ -1,5 +0,0 @@ -- item 1 -- item 1 - -> - item 1 -> - item 1 diff --git a/test/fixtures/list-item-marker-dot.md b/test/fixtures/list-item-marker-dot.md deleted file mode 100644 index 8503fc9d..00000000 --- a/test/fixtures/list-item-marker-dot.md +++ /dev/null @@ -1,5 +0,0 @@ -1. item 1 -1. item 1 - -> 1. item 1 -> 1. item 1 diff --git a/test/fixtures/list-item-marker-paren.md b/test/fixtures/list-item-marker-paren.md deleted file mode 100644 index 4db5fd16..00000000 --- a/test/fixtures/list-item-marker-paren.md +++ /dev/null @@ -1,5 +0,0 @@ -1) item 1 -1) item 1 - -> 1) item 1 -> 1) item 1 diff --git a/test/fixtures/list-item-marker-plus.md b/test/fixtures/list-item-marker-plus.md deleted file mode 100644 index 42871149..00000000 --- a/test/fixtures/list-item-marker-plus.md +++ /dev/null @@ -1,10 +0,0 @@ -+ item 1 - - -+ item 1 - - -> + item 1 - - -> + item 1 diff --git a/test/fixtures/list-item-spacing-loose-invalid.md b/test/fixtures/list-item-spacing-loose-invalid.md deleted file mode 100644 index 458c1dce..00000000 --- a/test/fixtures/list-item-spacing-loose-invalid.md +++ /dev/null @@ -1,4 +0,0 @@ -- Wrapped - item -- item 2 -- item 3 diff --git a/test/fixtures/list-item-spacing-loose-valid.md b/test/fixtures/list-item-spacing-loose-valid.md deleted file mode 100644 index ba65bfff..00000000 --- a/test/fixtures/list-item-spacing-loose-valid.md +++ /dev/null @@ -1,6 +0,0 @@ -- Wrapped - item - -- item 2 - -- item 3 diff --git a/test/fixtures/list-item-spacing-tight-invalid.md b/test/fixtures/list-item-spacing-tight-invalid.md deleted file mode 100644 index 550f5aef..00000000 --- a/test/fixtures/list-item-spacing-tight-invalid.md +++ /dev/null @@ -1,5 +0,0 @@ -- item 1 - -- item 2 - -- item 3 diff --git a/test/fixtures/list-item-spacing-tight-valid.md b/test/fixtures/list-item-spacing-tight-valid.md deleted file mode 100644 index b60d4ecc..00000000 --- a/test/fixtures/list-item-spacing-tight-valid.md +++ /dev/null @@ -1,3 +0,0 @@ -- item 1 -- item 2 -- item 3 diff --git a/test/fixtures/lorem-invalid.md b/test/fixtures/lorem-invalid.md deleted file mode 100644 index 28fcf5ad..00000000 --- a/test/fixtures/lorem-invalid.md +++ /dev/null @@ -1 +0,0 @@ -Lorem. diff --git a/test/fixtures/lorem-valid.md b/test/fixtures/lorem-valid.md deleted file mode 100644 index 5571b2e9..00000000 --- a/test/fixtures/lorem-valid.md +++ /dev/null @@ -1 +0,0 @@ -Ipsum. diff --git a/test/fixtures/maximum-line-length-invalid.md b/test/fixtures/maximum-line-length-invalid.md deleted file mode 100644 index a20f0e7d..00000000 --- a/test/fixtures/maximum-line-length-invalid.md +++ /dev/null @@ -1,7 +0,0 @@ -This line is simply toooooooooooooooooooooooooooooooooooooooooooooooooooooo long. - -Just like thiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis one. - -And this one is also very wrong: because the link starts aaaaaaafter the column: - - and such. diff --git a/test/fixtures/maximum-line-length-valid.md b/test/fixtures/maximum-line-length-valid.md deleted file mode 100644 index 86e8b1c2..00000000 --- a/test/fixtures/maximum-line-length-valid.md +++ /dev/null @@ -1,24 +0,0 @@ -This line is simply not tooooooooooooooooooooooooooooooooooooooooooooooooooooooo -long. - -This is also fine: - - - -[foo](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. - -. - -In addition, definitions are also fine: - -[foo]: diff --git a/test/fixtures/no-auto-link-without-protocol-invalid.md b/test/fixtures/no-auto-link-without-protocol-invalid.md deleted file mode 100644 index cf0f9d68..00000000 --- a/test/fixtures/no-auto-link-without-protocol-invalid.md +++ /dev/null @@ -1,12 +0,0 @@ -No tool, including **remark**, supports the below examples, except for the -e-mail. - - - - - - - - foo - -bar diff --git a/test/fixtures/no-auto-link-without-protocol-valid.md b/test/fixtures/no-auto-link-without-protocol-valid.md deleted file mode 100644 index df77b186..00000000 --- a/test/fixtures/no-auto-link-without-protocol-valid.md +++ /dev/null @@ -1,7 +0,0 @@ -[file.html](file.html) - - - - - - diff --git a/test/fixtures/no-blockquote-without-caret-invalid.md b/test/fixtures/no-blockquote-without-caret-invalid.md deleted file mode 100644 index 77cb87e1..00000000 --- a/test/fixtures/no-blockquote-without-caret-invalid.md +++ /dev/null @@ -1,17 +0,0 @@ -* > This is a blockquote - > which is immediately followed by - - > this blockquote. Unfortunately - > In some parsers, these are treated as the same blockquote. - -> This is a blockquote -> which is immediately followed by - - -> this blockquote. Unfortunately -> In some parsers, these are treated as the same blockquote. - - - -> Fooo -bar diff --git a/test/fixtures/no-blockquote-without-caret-valid.md b/test/fixtures/no-blockquote-without-caret-valid.md deleted file mode 100644 index a2b97f7e..00000000 --- a/test/fixtures/no-blockquote-without-caret-valid.md +++ /dev/null @@ -1,17 +0,0 @@ -* > This is a blockquote - > which is immediately followed by - > - > this blockquote. Unfortunately - > In some parsers, these are treated as the same blockquote. - -> This is a blockquote -> which is immediately followed by -> -> -> this blockquote. Unfortunately -> In some parsers, these are treated as the same blockquote. - - - -> Fooo -> bar diff --git a/test/fixtures/no-consecutive-blank-lines-invalid.md b/test/fixtures/no-consecutive-blank-lines-invalid.md deleted file mode 100644 index 41b92617..00000000 --- a/test/fixtures/no-consecutive-blank-lines-invalid.md +++ /dev/null @@ -1,22 +0,0 @@ - -Foo - - -Bar - - -> Baz -> -> -> Qux - - -1. Quux - - - -1. Foo - - - - Bar diff --git a/test/fixtures/no-consecutive-blank-lines-valid.md b/test/fixtures/no-consecutive-blank-lines-valid.md deleted file mode 100644 index c1a8aedc..00000000 --- a/test/fixtures/no-consecutive-blank-lines-valid.md +++ /dev/null @@ -1,15 +0,0 @@ -Foo - -Bar - -> Baz -> -> Qux - -1. Quux - - -1. Foo - - - Bar diff --git a/test/fixtures/no-duplicate-definitions-invalid.md b/test/fixtures/no-duplicate-definitions-invalid.md deleted file mode 100644 index a26e6e19..00000000 --- a/test/fixtures/no-duplicate-definitions-invalid.md +++ /dev/null @@ -1,2 +0,0 @@ -[foo]: bar -[foo]: qux diff --git a/test/fixtures/no-duplicate-definitions-valid.md b/test/fixtures/no-duplicate-definitions-valid.md deleted file mode 100644 index 0bb5abbe..00000000 --- a/test/fixtures/no-duplicate-definitions-valid.md +++ /dev/null @@ -1,2 +0,0 @@ -[foo]: bar -[bar]: qux diff --git a/test/fixtures/no-duplicate-headings-invalid.md b/test/fixtures/no-duplicate-headings-invalid.md deleted file mode 100644 index 817d1060..00000000 --- a/test/fixtures/no-duplicate-headings-invalid.md +++ /dev/null @@ -1,8 +0,0 @@ -# Fooo - -## Fooo - -![Bar](this://even-works-with.images/and/links) ---- - -## [Bar](http://bar.com) ## diff --git a/test/fixtures/no-duplicate-headings-valid.md b/test/fixtures/no-duplicate-headings-valid.md deleted file mode 100644 index 24915288..00000000 --- a/test/fixtures/no-duplicate-headings-valid.md +++ /dev/null @@ -1,8 +0,0 @@ -# toString - -## hasOwnProperty - -![Bar](this://even-works-with.images/and/links) ---- - -## [Baz](http://qux.com) ## diff --git a/test/fixtures/no-emphasis-as-heading-invalid.md b/test/fixtures/no-emphasis-as-heading-invalid.md deleted file mode 100644 index ba044e0b..00000000 --- a/test/fixtures/no-emphasis-as-heading-invalid.md +++ /dev/null @@ -1,7 +0,0 @@ -**How to make omelets** - -Break an egg. - -*How to bake bread* - -Open the flour sack. diff --git a/test/fixtures/no-emphasis-as-heading-valid.md b/test/fixtures/no-emphasis-as-heading-valid.md deleted file mode 100644 index b754ab7a..00000000 --- a/test/fixtures/no-emphasis-as-heading-valid.md +++ /dev/null @@ -1,26 +0,0 @@ -# How to make omelets - -Break an egg. - -## How to bake bread - -Open the flour sack. - -*And this is valid* - -* One -* Two - -This is also valid: - - foo - -So is **this**: - -Foo. - -# This one’s also Ignored - -_Byline_: - -Foo. diff --git a/test/fixtures/no-heading-content-indent-invalid.md b/test/fixtures/no-heading-content-indent-invalid.md deleted file mode 100644 index 6225e239..00000000 --- a/test/fixtures/no-heading-content-indent-invalid.md +++ /dev/null @@ -1,13 +0,0 @@ -# Too much spacing - -## Even more spacing ## - -####Too much spacing right, too few left #### - - ## Even works for indented headings ## - -Foo -=== - -Bar ---- diff --git a/test/fixtures/no-heading-content-indent-valid.md b/test/fixtures/no-heading-content-indent-valid.md deleted file mode 100644 index 406770e0..00000000 --- a/test/fixtures/no-heading-content-indent-valid.md +++ /dev/null @@ -1,13 +0,0 @@ -# Too much spacing - -## Even more spacing ## - -#### Too much spacing right, too few left #### - - ## Even works for indented headings ## - -Foo -=== - -Bar ---- diff --git a/test/fixtures/no-heading-indent-invalid.md b/test/fixtures/no-heading-indent-invalid.md deleted file mode 100644 index fe3a237e..00000000 --- a/test/fixtures/no-heading-indent-invalid.md +++ /dev/null @@ -1,9 +0,0 @@ - # Hello world - - Foo ------ - - # Hello world # - - Bar -===== diff --git a/test/fixtures/no-heading-indent-valid.md b/test/fixtures/no-heading-indent-valid.md deleted file mode 100644 index 8dbf978b..00000000 --- a/test/fixtures/no-heading-indent-valid.md +++ /dev/null @@ -1,13 +0,0 @@ -# Hello world - -Foo ------ - -# Hello world # - -Bar -===== - - - -##### diff --git a/test/fixtures/no-heading-punctuation-colon.md b/test/fixtures/no-heading-punctuation-colon.md deleted file mode 100644 index 7ccb4fd5..00000000 --- a/test/fixtures/no-heading-punctuation-colon.md +++ /dev/null @@ -1 +0,0 @@ -# Foo: diff --git a/test/fixtures/no-heading-punctuation-period.md b/test/fixtures/no-heading-punctuation-period.md deleted file mode 100644 index 351de836..00000000 --- a/test/fixtures/no-heading-punctuation-period.md +++ /dev/null @@ -1 +0,0 @@ -# Foo. diff --git a/test/fixtures/no-heading-punctuation-question.md b/test/fixtures/no-heading-punctuation-question.md deleted file mode 100644 index d0777c6d..00000000 --- a/test/fixtures/no-heading-punctuation-question.md +++ /dev/null @@ -1 +0,0 @@ -# Foo? diff --git a/test/fixtures/no-heading-punctuation-valid.md b/test/fixtures/no-heading-punctuation-valid.md deleted file mode 100644 index 7635c78e..00000000 --- a/test/fixtures/no-heading-punctuation-valid.md +++ /dev/null @@ -1 +0,0 @@ -# Foo diff --git a/test/fixtures/no-html-invalid.md b/test/fixtures/no-html-invalid.md deleted file mode 100644 index 49872917..00000000 --- a/test/fixtures/no-html-invalid.md +++ /dev/null @@ -1,3 +0,0 @@ -

HTML

- -Inline HTML might be a problem! diff --git a/test/fixtures/no-html-valid.md b/test/fixtures/no-html-valid.md deleted file mode 100644 index 9268e515..00000000 --- a/test/fixtures/no-html-valid.md +++ /dev/null @@ -1,3 +0,0 @@ -# HTML - -Inline HTML (HyperText Markup Language) might be a problem! diff --git a/test/fixtures/no-inline-padding-invalid.md b/test/fixtures/no-inline-padding-invalid.md deleted file mode 100644 index f0a3717e..00000000 --- a/test/fixtures/no-inline-padding-invalid.md +++ /dev/null @@ -1,9 +0,0 @@ -Emphasis: * foo*, and _bar _. - -Strong: **baz ** and __ qux__. - -Delete: ~~ quux~~ (this one isn’t parsed by remark when padded). - -An image: ![ alpha](bravo.png). - -A link: [ charlie ](delta.html). diff --git a/test/fixtures/no-inline-padding-valid.md b/test/fixtures/no-inline-padding-valid.md deleted file mode 100644 index b5089388..00000000 --- a/test/fixtures/no-inline-padding-valid.md +++ /dev/null @@ -1,9 +0,0 @@ -Emphasis: *foo*, and _bar_. - -Strong: **baz** and __qux__. - -Delete: ~~quux~~ (this one isn’t parsed by remark when padded). - -An image: ![alpha](bravo.png). - -A link: [charlie](delta.html). diff --git a/test/fixtures/no-literal-urls-invalid.md b/test/fixtures/no-literal-urls-invalid.md deleted file mode 100644 index 92f7cd23..00000000 --- a/test/fixtures/no-literal-urls-invalid.md +++ /dev/null @@ -1,5 +0,0 @@ -http://example.com - -foo@example.com which isn’t detected by remark yet. - -mailto:foo@example.com which isn’t detected by remark yet. diff --git a/test/fixtures/no-literal-urls-valid.md b/test/fixtures/no-literal-urls-valid.md deleted file mode 100644 index c3b27c11..00000000 --- a/test/fixtures/no-literal-urls-valid.md +++ /dev/null @@ -1,5 +0,0 @@ - - - which isn’t detected by remark yet. - - which isn’t detected by remark yet. diff --git a/test/fixtures/no-missing-blank-lines-invalid.md b/test/fixtures/no-missing-blank-lines-invalid.md deleted file mode 100644 index 9f987919..00000000 --- a/test/fixtures/no-missing-blank-lines-invalid.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -YAML: "front-matter" ---- -| A | table | with | -| --------- | ------- | ---- | -| incorrect | spacing | ... | -Foo bar baz -Heading -=== -* A list -1. Numbered list, followed by a rule: ---- -```text -fenced code -``` - indented code -A normal paragraph. -
foo
- -fooo -> blockquote diff --git a/test/fixtures/no-missing-blank-lines-valid.md b/test/fixtures/no-missing-blank-lines-valid.md deleted file mode 100644 index 0ca01dc1..00000000 --- a/test/fixtures/no-missing-blank-lines-valid.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -YAML: "front-matter" ---- - -| A | table | with | -| --------- | ------- | ---- | -| incorrect | spacing | ... | - -Foo bar baz - -Heading -=== - -* A list - -1. Numbered list, followed by a rule: - ---- - -```text -fenced code -``` - - indented code - -A normal paragraph. - -
foo
- -> blockquote diff --git a/test/fixtures/no-multiple-toplevel-headings-invalid-second.md b/test/fixtures/no-multiple-toplevel-headings-invalid-second.md deleted file mode 100644 index b86bbb84..00000000 --- a/test/fixtures/no-multiple-toplevel-headings-invalid-second.md +++ /dev/null @@ -1,4 +0,0 @@ -Another heading ---------------- - -## Another diff --git a/test/fixtures/no-multiple-toplevel-headings-invalid.md b/test/fixtures/no-multiple-toplevel-headings-invalid.md deleted file mode 100644 index ed2c58cc..00000000 --- a/test/fixtures/no-multiple-toplevel-headings-invalid.md +++ /dev/null @@ -1,7 +0,0 @@ -# Invalid - -Another heading ---------------- - -Another -======= diff --git a/test/fixtures/no-multiple-toplevel-headings-valid-second.md b/test/fixtures/no-multiple-toplevel-headings-valid-second.md deleted file mode 100644 index bb77d90d..00000000 --- a/test/fixtures/no-multiple-toplevel-headings-valid-second.md +++ /dev/null @@ -1,4 +0,0 @@ -Valid ---------------- - -### Another heading diff --git a/test/fixtures/no-multiple-toplevel-headings-valid.md b/test/fixtures/no-multiple-toplevel-headings-valid.md deleted file mode 100644 index 8751cf20..00000000 --- a/test/fixtures/no-multiple-toplevel-headings-valid.md +++ /dev/null @@ -1,4 +0,0 @@ -# Valid - -Another heading ---------------- diff --git a/test/fixtures/no-shell-dollars-invalid.md b/test/fixtures/no-shell-dollars-invalid.md deleted file mode 100644 index aa04b3ed..00000000 --- a/test/fixtures/no-shell-dollars-invalid.md +++ /dev/null @@ -1,36 +0,0 @@ -An indented code block is ignored: - - $ echo a - $ echo a > file - -An unflagged fenced code block is also ignored: - -``` -$ echo a -$ echo a > file -``` - -Flagged fenced code blocks: - -```sh -$ echo a -$ echo a > file -``` - -```bash -$ echo a - -$ echo a > file -``` - -```command -$ echo a -$ echo a > file -``` - -Nested: - -> * Hello blocks without language are also ignored: -> -> $ echo a -> $ echo a > file diff --git a/test/fixtures/no-shell-dollars-valid.md b/test/fixtures/no-shell-dollars-valid.md deleted file mode 100644 index b5f399f5..00000000 --- a/test/fixtures/no-shell-dollars-valid.md +++ /dev/null @@ -1,50 +0,0 @@ -An indented code block: - - $ echo a - a - $ echo a > file - -An unflagged fenced code block: - -``` -$ echo a -a -$ echo a > file -``` - -Empty: - -```bash -``` - -Flagged fenced code blocks: - -```sh -$ echo a -a -$ echo a > file -``` - -```bash -echo a -echo a > file -``` - -```command -$ echo a -a -$ echo a > file -``` - -```javascript -$ echo a -$ echo a > file -``` - -Nested: - -> * Hello -> -> $ echo a -> a -> $ echo a > file diff --git a/test/fixtures/no-shortcut-reference-image-invalid.md b/test/fixtures/no-shortcut-reference-image-invalid.md deleted file mode 100644 index 28534a2c..00000000 --- a/test/fixtures/no-shortcut-reference-image-invalid.md +++ /dev/null @@ -1,4 +0,0 @@ -Here’s an ![valid] reference image, and here’s ![another]. - -[valid]: http://example.com/favicon.ico "Example Domain" -[another]: http://example.org/favicon.ico "Example Domain" diff --git a/test/fixtures/no-shortcut-reference-image-valid.md b/test/fixtures/no-shortcut-reference-image-valid.md deleted file mode 100644 index 30a2b153..00000000 --- a/test/fixtures/no-shortcut-reference-image-valid.md +++ /dev/null @@ -1,4 +0,0 @@ -Here’s an ![valid][] reference image, and here’s ![another][]. - -[valid]: http://example.com/favicon.ico "Example Domain" -[another]: http://example.org/favicon.ico "Example Domain" diff --git a/test/fixtures/no-shortcut-reference-link-invalid.md b/test/fixtures/no-shortcut-reference-link-invalid.md deleted file mode 100644 index 8567935d..00000000 --- a/test/fixtures/no-shortcut-reference-link-invalid.md +++ /dev/null @@ -1,4 +0,0 @@ -Here’s an [invalid] reference link, and here’s [another]. - -[invalid]: http://example.com "Example Domain" -[another]: http://example.org "Example Domain" diff --git a/test/fixtures/no-shortcut-reference-link-valid.md b/test/fixtures/no-shortcut-reference-link-valid.md deleted file mode 100644 index 1aa5be44..00000000 --- a/test/fixtures/no-shortcut-reference-link-valid.md +++ /dev/null @@ -1,4 +0,0 @@ -Here’s an [valid][] reference link, and here’s [another][]. - -[valid]: http://example.com "Example Domain" -[another]: http://example.org "Example Domain" diff --git a/test/fixtures/no-table-indentation-invalid.md b/test/fixtures/no-table-indentation-invalid.md deleted file mode 100644 index 8574d680..00000000 --- a/test/fixtures/no-table-indentation-invalid.md +++ /dev/null @@ -1,6 +0,0 @@ -Did you know GitHub renders a table indented, by four spaces, as a table, not -code? - - | Foo | Bar | - | --- | --- | - | Baz | Qux | diff --git a/test/fixtures/no-table-indentation-valid.md b/test/fixtures/no-table-indentation-valid.md deleted file mode 100644 index a2111e1f..00000000 --- a/test/fixtures/no-table-indentation-valid.md +++ /dev/null @@ -1,5 +0,0 @@ -Here’s a proper table: - -| Foo | Bar | -| --- | --- | -| Baz | Qux | diff --git a/test/fixtures/no-tabs-invalid.md b/test/fixtures/no-tabs-invalid.md deleted file mode 100644 index bf881047..00000000 --- a/test/fixtures/no-tabs-invalid.md +++ /dev/null @@ -1,13 +0,0 @@ - Here's one before a code block. - -Here's a tab: , and here is another: . - -And this is in `inline code`. - -> This is in a block quote. - -* And... - - 1. in a list. - -And this is a tab as the last character. diff --git a/test/fixtures/no-tabs-valid.md b/test/fixtures/no-tabs-valid.md deleted file mode 100644 index a889560a..00000000 --- a/test/fixtures/no-tabs-valid.md +++ /dev/null @@ -1,11 +0,0 @@ -Here's a paragraph without tabs. - - This is a very normal indented code block. - -This is in quite boring `inline code`. - -> This is a really standard block quote. - -* And... - - 1. This is just a list. diff --git a/test/fixtures/no-undefined-references-invalid.md b/test/fixtures/no-undefined-references-invalid.md deleted file mode 100644 index 67895d6c..00000000 --- a/test/fixtures/no-undefined-references-invalid.md +++ /dev/null @@ -1 +0,0 @@ -[foo][] diff --git a/test/fixtures/no-undefined-references-valid.md b/test/fixtures/no-undefined-references-valid.md deleted file mode 100644 index c2ae904b..00000000 --- a/test/fixtures/no-undefined-references-valid.md +++ /dev/null @@ -1,3 +0,0 @@ -[foo][] - -[foo]: https://example.com diff --git a/test/fixtures/no-unused-definitions-invalid.md b/test/fixtures/no-unused-definitions-invalid.md deleted file mode 100644 index 0819aa94..00000000 --- a/test/fixtures/no-unused-definitions-invalid.md +++ /dev/null @@ -1 +0,0 @@ -[bar]: https://example.com diff --git a/test/fixtures/no-unused-definitions-valid.md b/test/fixtures/no-unused-definitions-valid.md deleted file mode 100644 index c2ae904b..00000000 --- a/test/fixtures/no-unused-definitions-valid.md +++ /dev/null @@ -1,3 +0,0 @@ -[foo][] - -[foo]: https://example.com diff --git a/test/fixtures/ordered-list-marker-value-one.md b/test/fixtures/ordered-list-marker-value-one.md deleted file mode 100644 index 0e14495c..00000000 --- a/test/fixtures/ordered-list-marker-value-one.md +++ /dev/null @@ -1,8 +0,0 @@ -1. One; -1. Two; -1. Three. - - -1. One; -1. Two; -1. Three. diff --git a/test/fixtures/ordered-list-marker-value-ordered.md b/test/fixtures/ordered-list-marker-value-ordered.md deleted file mode 100644 index 454b2e0e..00000000 --- a/test/fixtures/ordered-list-marker-value-ordered.md +++ /dev/null @@ -1,8 +0,0 @@ -1. One; -2. Two; -3. Three. - - -3. One; -4. Two; -5. Three. diff --git a/test/fixtures/ordered-list-marker-value-single.md b/test/fixtures/ordered-list-marker-value-single.md deleted file mode 100644 index 27cb5b20..00000000 --- a/test/fixtures/ordered-list-marker-value-single.md +++ /dev/null @@ -1,8 +0,0 @@ -1. One; -1. Two; -1. Three. - - -3. One; -3. Two; -3. Three. diff --git a/test/fixtures/remark-github.md b/test/fixtures/remark-github.md deleted file mode 100644 index ba0b1e7e..00000000 --- a/test/fixtures/remark-github.md +++ /dev/null @@ -1,5 +0,0 @@ -A user @wooorm. - -A commit 1234567. - -And an issue GH-1. diff --git a/test/fixtures/rule-style-invalid.md b/test/fixtures/rule-style-invalid.md deleted file mode 100644 index 50569fea..00000000 --- a/test/fixtures/rule-style-invalid.md +++ /dev/null @@ -1,15 +0,0 @@ -Foo - -* * * * - -Bar - -- - - - - - -Baz - -_ _ _ - -Qux - -**** diff --git a/test/fixtures/rule-style-valid.md b/test/fixtures/rule-style-valid.md deleted file mode 100644 index 65dd29a9..00000000 --- a/test/fixtures/rule-style-valid.md +++ /dev/null @@ -1,15 +0,0 @@ -Foo - -* * * * - -Bar - -* * * * - -Baz - -* * * * - -Qux - -* * * * diff --git a/test/fixtures/strong-marker-asterisk-underscore.md b/test/fixtures/strong-marker-asterisk-underscore.md deleted file mode 100644 index 3ec2b783..00000000 --- a/test/fixtures/strong-marker-asterisk-underscore.md +++ /dev/null @@ -1,3 +0,0 @@ -**foo** - -__bar__ diff --git a/test/fixtures/strong-marker-asterisk.md b/test/fixtures/strong-marker-asterisk.md deleted file mode 100644 index 81dfc739..00000000 --- a/test/fixtures/strong-marker-asterisk.md +++ /dev/null @@ -1,3 +0,0 @@ -**foo** - -**bar** diff --git a/test/fixtures/strong-marker-underscore-asterisk.md b/test/fixtures/strong-marker-underscore-asterisk.md deleted file mode 100644 index 5d911eb9..00000000 --- a/test/fixtures/strong-marker-underscore-asterisk.md +++ /dev/null @@ -1,3 +0,0 @@ -__foo__ - -**bar** diff --git a/test/fixtures/strong-marker-underscore.md b/test/fixtures/strong-marker-underscore.md deleted file mode 100644 index 9074ba74..00000000 --- a/test/fixtures/strong-marker-underscore.md +++ /dev/null @@ -1,3 +0,0 @@ -__foo__ - -__bar__ diff --git a/test/fixtures/table-cell-padding-compact-unaligned.md b/test/fixtures/table-cell-padding-compact-unaligned.md deleted file mode 100644 index c57b0372..00000000 --- a/test/fixtures/table-cell-padding-compact-unaligned.md +++ /dev/null @@ -1,6 +0,0 @@ -Here are some unaligned spaced tables. - -|foooo|fo|foooo|fo| -|-----|:-|:---:|-:| -|bar|baz|baaaaaar|bar| -|bar|baaaaaaaaaaz|bar| diff --git a/test/fixtures/table-cell-padding-compact.md b/test/fixtures/table-cell-padding-compact.md deleted file mode 100644 index 731fb226..00000000 --- a/test/fixtures/table-cell-padding-compact.md +++ /dev/null @@ -1,11 +0,0 @@ -Here are some properly non-spaced tables. - -|foooo|foooo|foooo|foooo| -|-----|:----|:---:|----:| -|bar |baz | bar | bar| - -So is this one (the longest cell receives preference, not the first): - -|foo |fuu | foo | foo| -|-----|:----|:---:|----:| -|baaar|baaar|baaar|baaar| diff --git a/test/fixtures/table-cell-padding-mixed.md b/test/fixtures/table-cell-padding-mixed.md deleted file mode 100644 index 9240ba8f..00000000 --- a/test/fixtures/table-cell-padding-mixed.md +++ /dev/null @@ -1,19 +0,0 @@ -Here’s a weirdly padded table, which start compact. - -|foooo |foooo| fooo |foooo| -|------|:----|:----:|----:| -|bar |baz | bar | bar| - -|bar |baz | bar | bar| -|------|:----|:----:|----:| -|foooo |foooo| fooo |foooo| - -Here’s a weirdly padded table, which start padded. - -| foooo |foooo| fooo |foooo| -| ----- |:----|:----:|----:| -| bar |baz | bar | bar| - -| bar |baz | bar | bar| -| ----- |:----|:----:|----:| -| foooo |foooo| fooo |foooo| diff --git a/test/fixtures/table-cell-padding-padded-unaligned.md b/test/fixtures/table-cell-padding-padded-unaligned.md deleted file mode 100644 index 1e55ff16..00000000 --- a/test/fixtures/table-cell-padding-padded-unaligned.md +++ /dev/null @@ -1,6 +0,0 @@ -Here are some unaligned spaced tables. - -| foooo | fo | foooo | fo | -| ----- | :- | :---: | -: | -| bar | baz | baaaaaar | bar | -| bar | baaaaaaaaaaaaz | bar | diff --git a/test/fixtures/table-cell-padding-padded.md b/test/fixtures/table-cell-padding-padded.md deleted file mode 100644 index 28016a66..00000000 --- a/test/fixtures/table-cell-padding-padded.md +++ /dev/null @@ -1,11 +0,0 @@ -Here are some properly spaced tables. - -| foooo | foooo | foooo | foooo | -| ----- | :---- | :---: | ----: | -| bar | baz | bar | bar | - -So is this one (the longest cell receives preference, not the first): - -| foo | foo | foo | foo | -| ----- | :---- | :---: | ----: | -| baaar | baaaz | baaar | baaar | diff --git a/test/fixtures/table-pipe-alignment-invalid.md b/test/fixtures/table-pipe-alignment-invalid.md deleted file mode 100644 index e8746ec1..00000000 --- a/test/fixtures/table-pipe-alignment-invalid.md +++ /dev/null @@ -1,5 +0,0 @@ -Unaligned fences (note that the alignment-row is not validated). - -| Foo | Bar | Baz | -| --- | ---- | ---- | -| Qu | Quux | foooo | diff --git a/test/fixtures/table-pipe-alignment-valid.md b/test/fixtures/table-pipe-alignment-valid.md deleted file mode 100644 index 870df4cd..00000000 --- a/test/fixtures/table-pipe-alignment-valid.md +++ /dev/null @@ -1,5 +0,0 @@ -Aligned fences (note the missing last cell in the last row). - -| Foooo | Bar | Baz | -| ----- | ----- | --- | -| Qux | Quux | diff --git a/test/fixtures/table-pipes-invalid.md b/test/fixtures/table-pipes-invalid.md deleted file mode 100644 index 73822cff..00000000 --- a/test/fixtures/table-pipes-invalid.md +++ /dev/null @@ -1,23 +0,0 @@ -Without fences: - -Foo | Bar ---- | --- -Baz | Qux - -Without initial fence: - -Foo | Bar | ---- | --- | -Baz | Qux | - -Without final fence: - -| Foo | Bar -| --- | --- -| Baz | Qux - -Centered without fences: - -Foooooo | Baaaaar -:-----: | :-----: - Baz | Qux diff --git a/test/fixtures/table-pipes-valid.md b/test/fixtures/table-pipes-valid.md deleted file mode 100644 index 1a4273e9..00000000 --- a/test/fixtures/table-pipes-valid.md +++ /dev/null @@ -1,11 +0,0 @@ -With fences: - -| Foo | Bar | -| --- | --- | -| Baz | Qux | - -Centered with fences: - -| Foooooo | Baaaaar | -| :-----: | :-----: | -| Baz | Qux | diff --git a/test/fixtures/the-file-name.md b/test/fixtures/the-file-name.md deleted file mode 100644 index e69de29b..00000000 diff --git a/test/index.js b/test/index.js index 44c79166..add6d0c9 100644 --- a/test/index.js +++ b/test/index.js @@ -1,1986 +1,254 @@ /** * @author Titus Wormer - * @copyright 2015 Titus Wormer + * @copyright 2016 Titus Wormer * @license MIT - * @module remark:lint:test - * @fileoverview Tests for remark-lint. + * @module remark:lint + * @fileoverview Test suite for `remark-lint`. */ 'use strict'; -/* eslint-env node, mocha */ +/* eslint-disable max-params */ -var fs = require('fs'); +/* Dependencies. */ var path = require('path'); -var assert = require('assert'); +var test = require('tape'); +var vfile = require('to-vfile'); +var removePosition = require('unist-util-remove-position'); var remark = require('remark'); -var File = require('vfile'); -var toc = require('remark-toc'); -var github = require('remark-github'); var lint = require('..'); -var plural = require('plur'); -var clean = require('./clean'); +var rules = require('../script/util/rules'); +var rule = require('../script/util/rule'); + +/* Tests. */ +test('core', function (t) { + t.test('should work', function (st) { + var doc = vfile('virtual.md'); + + st.plan(2); + + doc.contents = [ + '# A heading', + '', + '# Another main heading.', + '', + '', + '', + '# Another main heading.' + ].join('\n'); + + remark() + .use(lint, {finalNewline: false}) + .process(doc, function (err) { + st.ifErr(err, 'should not fail'); + st.deepEqual( + doc.messages.map(String), + [ + 'virtual.md:3:1-3:24: Don’t add a trailing `.` to headings', + 'virtual.md:3:1-3:24: Don’t use multiple top level headings (3:1)' + ]); + }); + }); + + t.test('should support no options', function (st) { + st.plan(2); + + remark().use(lint).process('.', function (err, file) { + st.ifErr(err, 'should not fail'); + st.deepEqual( + file.messages.map(String), + ['1:1: Missing newline character at end of file'], + 'should warn for missing new lines' + ); + }); + }); + + t.test('should support camel-cased rule-id’s', function (st) { + st.plan(2); + + remark() + .use(lint, {finalNewline: false}) + .process('.', function (err, file) { + st.ifErr(err, 'should not fail'); + st.deepEqual(file.messages, [], 'should disable `final-newline`'); + }); + }); + + t.test('should support dash-cased rule-id’s', function (st) { + st.plan(2); + + remark() + .use(lint, {'final-newline': false}) + .process('.', function (err, file) { + st.ifErr(err, 'should not fail'); + st.deepEqual(file.messages, [], 'should disable `final-newline`'); + }); + }); + + t.end(); +}); -/* - * Methods. - */ +test('external rules', function (t) { + var tests = { + 'literal external rules': [ + require('remark-lint-no-url-trailing-slash') + ], + 'external rules by package name': [ + 'remark-lint-no-url-trailing-slash' + ], + 'external rules by prefixless name': [ + 'no-url-trailing-slash' + ], + 'external rules by absolute file-path': [ + path.join(__dirname, 'local-external.js') + ], + 'external rules by relative file-path': [ + path.relative( + process.cwd(), + path.join(__dirname, 'local-external.js') + ) + ], + 'external rules without extension': [ + path.join(__dirname, 'local-external') + ] + }; + + t.plan(Object.keys(tests).length); + + Object.keys(tests).forEach(function (label) { + t.test('should load ' + label, function (st) { + var doc = '[alpha](https://bravo.charlie/)\n'; + + st.plan(2); + + remark() + .use(lint, { + external: tests[label] + }) + .process(doc, function (err, file) { + st.ifErr(err, 'should not fail'); + st.deepEqual( + file.messages.map(String), + ['1:1-1:32: Remove trailing slash (https://bravo.charlie)'], + 'should warn for missing new lines' + ); + }); + }); + }); +}); -var read = fs.readFileSync; -var join = path.join; -var basename = path.basename; -var extname = path.extname; -var dirname = path.dirname; -var dequal = assert.deepEqual; +test('rules', function (t) { + var all = rules(process.cwd()); -/** - * Create a `File` from a `filePath`. - * - * @param {string} filePath - Path to file. - * @return {File} - Virtual file representation. - */ -function toFile(filePath) { - var extension = extname(filePath); - var directory = dirname(filePath); - var name = basename(filePath, extension); + t.plan(all.length); - return new File({ - 'directory': directory, - 'filename': name, - 'extension': extension.slice(1), - 'contents': read(join('test', 'fixtures', filePath), 'utf-8') + all.forEach(function (rulePath) { + var info = rule(rulePath); + + t.test(info.ruleId, function (sst) { + assertRule(sst, info); }); -} + }); +}); /** - * Shortcut. + * Assert a rule. * - * @param {string} filePath - Path to `file`. - * @param {Object?} options - Passed to `remark-lint` - * @param {Object?} settings - Passed to `remark` - * @param {boolean?} shouldClean - Uses `clean` plugin, - * when truthy. - * @return {Array.} - Messages. + * @param {Test} t - Tape test. + * @param {Object} rule - Rule information. */ -function process(filePath, options, settings, shouldClean) { - var file = toFile(filePath); - var processor = remark(); - - if (shouldClean) { - processor.use(clean); - } - - processor.use(lint, options); +function assertRule(t, rule) { + var tests = rule.tests; - file.quiet = true; + Object.keys(tests).forEach(function (setting) { + var fixture = tests[setting]; + var config = JSON.parse(setting); - processor.process(file, settings, function (err) { - if (err) { - if (file.messages.indexOf(err) !== -1) { - return; - } - - throw err; - } + t.test(setting, function (st) { + Object.keys(fixture).forEach(function (name) { + st.test(name, function (sst) { + assertFixture(sst, rule, fixture[name], name, config); + }); + }); }); + }); - return file.messages; + t.end(); } -/* - * BDD-like helpers. - */ - -var currentRule = null; -var currentSetting = null; - /** - * Describe a single remark-lint rule. + * Assert a fixture. * - * @param {string} ruleId - Rule to turn on when testing. - * @param {Function} description - Passed to `describe()`. + * @param {Test} t - Tape test. + * @param {Object} rule - Rule information. + * @param {Object} fixture - Fixture information. + * @param {string} basename - Name of fixture. + * @param {*} setting - Configuration. */ -function describeRule(ruleId, description) { - currentRule = ruleId; - - describe(ruleId, description); - - currentRule = null; -} +function assertFixture(t, rule, fixture, basename, setting) { + var ruleId = rule.ruleId; + var file = vfile(basename); + var expected = fixture.output; + var options = {reset: true}; + var positionless = fixture.config.positionless; -/** - * Describe how a single remark-lint rule should behave - * when given a certain `setting`. - * - * @param {*} setting - Passed to the rule. - * @param {Function} description - Passed to `describe()`. - */ -function describeSetting(setting, description) { - currentSetting = setting; + file.quiet = true; - describe(JSON.stringify(setting), description); + options[ruleId] = setting; - currentSetting = null; -} + file.contents = preprocess(fixture.input || ''); -/** - * Assert the messages triggered when running a bound rule - * with a bound setting on `filePath`, are the same as - * `messages`. Additionally accepts `settings` which are - * given to `remark`. - * - * @param {string} filePath - Location of file in - * `test/fixtures/`. - * @param {Array.} messages - Assertions. - * @param {Object?} settings - Passed to `remark`. - * @param {Object?} overwrite - Passed to `remark-lint` - * instead of constructing based on BDD-like tests. - */ -function assertFile(filePath, messages, settings, overwrite) { - var n = -1; - var options; - var results; - var max; - var label; + t.plan(positionless ? 1 : 2); - if (overwrite) { - options = overwrite; - } else { - /* - * Construct remark-lint options. - */ + remark().use(lint, options).process(file, fixture.config); - options = {}; - options.reset = true; - options[currentRule] = currentSetting; + file.messages.forEach(function (message) { + if (message.ruleId !== ruleId) { + throw new Error( + 'Expected `' + ruleId + '`, not `' + + message.ruleId + '` as `ruleId` for ' + + message + ); } + }); - /* - * Convert messages to strings. - */ - - results = process(filePath, options, settings).map(String); + t.deepEqual( + normalize(file.messages), + expected, + 'should equal with position' + ); - max = (results.length > messages.length ? results : messages).length; + if (!positionless) { + file.messages = []; - /* - * Create descriptive label for the test. - */ + remark().use(function () { + return removePosition; + }).use(lint, options).process(file); - label = max === 0 ? 'shouldn’t warn' : - max === 1 ? 'should warn' : - 'should warn ' + max + ' ' + plural('time', max); + t.deepEqual( + normalize(file.messages), + [], + 'should equal without position' + ); + } - /* - * Assert. - */ - - it(filePath + ' ' + label, function () { - while (++n < max) { - assert.strictEqual(messages[n], results[n]); - } - }); + file.messages = []; } -/* - * Basic tests. - */ - -describe('remark-lint', function () { - it('should work without `options`', function () { - assert(process('file-extension-markdown.markdown').length === 1); - }); - - it('should ignore rules when set to `false`', function () { - assert(process('file-extension-markdown.markdown', { - 'file-extension': false - }).length === 0); - }); - - it('should ignore all rules when `reset: true`', function () { - assert(process('file-extension-markdown.markdown', { - 'reset': true - }).length === 0); - }); - - it('...except for explicitly turned on rules', function () { - assert(process('file-extension-markdown.markdown', { - 'reset': true, - 'file-extension': 'md' - }).length === 1); - }); - - it('should accept camel-cased rules', function () { - dequal(process('maximum-line-length-valid.md', { - 'reset': true, - 'maximumLineLength': 20 - }).map(String), [ - 'maximum-line-length-valid.md:1:81: Line must be at most 20 characters', - 'maximum-line-length-valid.md:18:61: Line must be at most 20 characters', - 'maximum-line-length-valid.md:22:40: Line must be at most 20 characters' - ]); - }); - - it('should work with carriage returns', function () { - dequal(process('carriage-returns.md').map(String), [ - 'carriage-returns.md:5:1-5:28: Missing blank line before block node' - ]); - }); -}); - -/* - * Validate external rules. - */ - -describe('External', function () { - describe('Load external rules with require', function () { - assertFile('lorem-invalid.md', [ - 'lorem-invalid.md:1:6: Do not use lorem' - ], null, { - 'external': ['test/external'] - }); - }); - - describe('Load external rules with require and without `.js` extension', function () { - assertFile('lorem-invalid.md', [ - 'lorem-invalid.md:1:6: Do not use lorem' - ], null, { - 'external': ['test/external/index'] - }); - }); - - describe('Load external rules with require and with `.js` extension', function () { - assertFile('lorem-invalid.md', [ - 'lorem-invalid.md:1:6: Do not use lorem' - ], null, { - 'external': ['test/external/index.js'] - }); - }); - - describe('Load local external rules', function () { - it('should fail on invalid external rules', function () { - assert.throws(function () { - process('lorem-valid.md', { - 'external': ['remark'] - }); - }); - }); - }); - - describe('Load external rules by passing in', function () { - var external = require('./external'); - - assertFile('lorem-invalid.md', [ - 'lorem-invalid.md:1:6: Do not use lorem' - ], null, { - 'external': [external] - }); - }); -}); - -/* - * Validate gaps are ignored. - */ - -describe('Gaps', function () { - it('should supports gaps in a document', function (done) { - var file = toFile('gaps-toc-internal.md'); - var processor = remark().use(toc).use(lint); - - file.quiet = true; - - processor.process(file, function (err) { - assert(file.messages.length === 0); - - done(err); - }); - }); - - it('should supports gaps at the end of a document', function (done) { - var file = toFile('gaps-toc-final.md'); - var processor = remark().use(toc).use(lint); - - file.quiet = true; - - processor.process(file, function (err) { - assert(file.messages.length === 0); - - done(err); - }); - }); -}); - -/* - * Validate only “real” links are warned about. - */ - -describe('GitHub', function () { - it('should supports gaps in a document', function (done) { - var file = toFile('remark-github.md'); - var processor = remark().use(github).use(lint); - - file.quiet = true; - - processor.process(file, function (err) { - assert(file.messages.length === 0); - done(err); - }); - }); -}); - -/* - * Validate inline en- and disabling. - */ - -describe('Comments', function () { - describe('Disable and re-enable rules based on markers', function () { - assertFile('comments-disable.md', [ - 'comments-disable.md:7:89: Line must be at most 80 characters' - ], null, {}); - }); - - describe('Enable and re-disable rules based on markers', function () { - assertFile('comments-enable.md', [ - 'comments-enable.md:3:89: Line must be at most 80 characters' - ], null, { - 'reset': true - }); - }); - - describe('Disable multiple rules at once', function () { - assertFile('comments-disable-multiple.md', [ - 'comments-disable-multiple.md:11:1-11:10: Do not use headings with similar content (5:1)' - ], null, {}); - }); - - describe('Inline comments', function () { - assertFile('comments-inline.md', [ - 'comments-inline.md:1:32-1:38: Do not use HTML in markdown', - 'comments-inline.md:1:50-1:57: Do not use HTML in markdown' - ], null, { - 'reset': true - }); - }); - - describe('Invalid comments', function () { - assertFile('comments-invalid-keyword.md', [ - 'comments-invalid-keyword.md:3:1-3:20: Unknown keyword `foo`: expected `\'enable\'`, `\'disable\'`, or `\'ignore\'`' - ], null, { - 'reset': true - }); - }); - - describe('Invalid rules', function () { - assertFile('comments-invalid-rule-id.md', [ - 'comments-invalid-rule-id.md:3:1-3:23: Unknown rule: cannot enable `\'bar\'`' - ], null, { - 'reset': true - }); - }); - - describe('Without comments', function () { - assertFile('comments-none.md', [], null, { - 'reset': true - }); - }); - - describe('Duplicate enabling of rules', function () { - assertFile('comments-duplicates.md', [ - 'comments-duplicates.md:3:89: Line must be at most 80 characters', - 'comments-duplicates.md:7:89: Line must be at most 80 characters' - ], null, {}); - }); -}); - -/* - * Validate rules. +/** + * Normalize a list of messages. + * + * @param {Array.} messages - List of warnings. + * @return {Array.} - Normalized warnings. */ +function normalize(messages) { + return messages.map(function (message) { + var value = String(message); -describe('Rules', function () { - describeRule('file-extension', function () { - describeSetting('md', function () { - assertFile('file-extension-markdown.markdown', [ - 'file-extension-markdown.markdown:1:1: Invalid extension: use `md`' - ]); - - assertFile('file-without-extension', []); - assertFile('file-extension-md.md', []); - }); - - describeSetting('markdown', function () { - assertFile('file-extension-markdown.markdown', []); - assertFile('file-without-extension', []); - - assertFile('file-extension-md.md', [ - 'file-extension-md.md:1:1: Invalid extension: use `markdown`' - ]); - }); - }); - - describeRule('no-file-name-articles', function () { - describeSetting(true, function () { - assertFile('the-file-name.md', [ - 'the-file-name.md:1:1: Do not start file names with `the`' - ]); - }); - }); - - describeRule('no-file-name-mixed-case', function () { - describeSetting(true, function () { - assertFile('file-name-Upper-case.md', [ - 'file-name-Upper-case.md:1:1: Do not mix casing in file names' - ]); - }); - }); - - describeRule('no-file-name-irregular-characters', function () { - describeSetting(true, function () { - assertFile('file-name characters.md', [ - 'file-name characters.md:1:1: Do not use ` ` in a file name' - ]); - }); - - describeSetting(/[^\\.aeiou]/, function () { - assertFile('empty.md', [ - 'empty.md:1:1: Do not use `m` in a file name' - ]); - }); - - describeSetting('aeiou', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Do not use `m` in a file name' - ]); - }); - }); - - describeRule('no-file-name-consecutive-dashes', function () { - describeSetting(true, function () { - assertFile('file-name--consecutive-dashes.md', [ - 'file-name--consecutive-dashes.md:1:1: Do not use consecutive dashes in a file name' - ]); - }); - }); - - describeRule('no-file-name-consecutive-dashes', function () { - describeSetting(true, function () { - assertFile('file-name--consecutive-dashes.md', [ - 'file-name--consecutive-dashes.md:1:1: Do not use consecutive dashes in a file name' - ]); - }); - }); - - describeRule('no-file-name-outer-dashes', function () { - describeSetting(true, function () { - assertFile('-file-name-initial-dash.md', [ - '-file-name-initial-dash.md:1:1: Do not use initial or final dashes in a file name' - ]); - - assertFile('file-name-final-dash-.md', [ - 'file-name-final-dash-.md:1:1: Do not use initial or final dashes in a file name' - ]); - }); - }); - - describeRule('maximum-heading-length', function () { - describeSetting(true, function () { - assertFile('heading-length-too-long.md', [ - 'heading-length-too-long.md:1:1-1:65: Use headings shorter than `60`' - ]); - - assertFile('heading-length-normal.md', []); - assertFile('heading-length-quite-short.md', []); - }); - - describeSetting(20, function () { - assertFile('heading-length-too-long.md', [ - 'heading-length-too-long.md:1:1-1:65: Use headings shorter than `20`' - ]); - - assertFile('heading-length-quite-short.md', [ - 'heading-length-quite-short.md:1:1-1:29: Use headings shorter than `20`' - ]); - - assertFile('heading-length-normal.md', []); - }); - }); - - describeRule('first-heading-level', function () { - describeSetting(true, function () { - assertFile('first-heading-level-invalid.md', [ - 'first-heading-level-invalid.md:1:1-1:11: First heading level should be `1`' - ]); - - assertFile('first-heading-level-valid.md', []); - }); - - describeSetting(2, function () { - assertFile('first-heading-level-invalid-second.md', [ - 'first-heading-level-invalid-second.md:1:1-1:8: First heading level should be `2`' - ]); - - assertFile('first-heading-level-valid-second.md', []); - }); - }); - - describeRule('heading-increment', function () { - describeSetting(true, function () { - assertFile('heading-increment-invalid.md', [ - 'heading-increment-invalid.md:3:1-3:8: Heading levels should increment by one level at a time' - ]); - - assertFile('heading-increment-invalid-blockquote.md', [ - 'heading-increment-invalid-blockquote.md:3:3-3:10: Heading levels should increment by one level at a time' - ]); - - assertFile('heading-increment-invalid-list.md', [ - 'heading-increment-invalid-list.md:3:5-3:12: Heading levels should increment by one level at a time' - ]); - - assertFile('first-heading-level-invalid.md', []); - }); - }); - - describeRule('no-heading-punctuation', function () { - describeSetting(true, function () { - assertFile('no-heading-punctuation-period.md', [ - 'no-heading-punctuation-period.md:1:1-1:7: Don’t add a trailing `.` to headings' - ]); - - assertFile('no-heading-punctuation-colon.md', [ - 'no-heading-punctuation-colon.md:1:1-1:7: Don’t add a trailing `:` to headings' - ]); - - assertFile('no-heading-punctuation-question.md', [ - 'no-heading-punctuation-question.md:1:1-1:7: Don’t add a trailing `?` to headings' - ]); - - assertFile('no-heading-punctuation-valid.md', []); - }); - - describeSetting('o', function () { - assertFile('no-heading-punctuation-period.md', []); - assertFile('no-heading-punctuation-colon.md', []); - assertFile('no-heading-punctuation-question.md', []); - - assertFile('no-heading-punctuation-valid.md', [ - 'no-heading-punctuation-valid.md:1:1-1:6: Don’t add a trailing `o` to headings' - ]); - }); - }); - - describeRule('heading-style', function () { - describeSetting(true, function () { - assertFile('heading-style-atx.md', []); - assertFile('heading-style-atx-closed.md', []); - assertFile('heading-style-setext.md', []); - - assertFile('heading-style-not-consistent.md', [ - 'heading-style-not-consistent.md:3:1-4:6: Headings should use atx', - 'heading-style-not-consistent.md:6:1-6:19: Headings should use atx', - 'heading-style-not-consistent.md:10:1-10:24: Headings should use atx' - ]); - - assertFile('heading-style-empty.md', [ - 'heading-style-empty.md:3:1-3:3: Headings should use atx-closed', - 'heading-style-empty.md:7:1-7:5: Headings should use atx-closed', - 'heading-style-empty.md:11:1-11:7: Headings should use atx-closed' - ]); - }); - - describeSetting('atx', function () { - assertFile('heading-style-atx.md', []); - - assertFile('heading-style-atx-closed.md', [ - 'heading-style-atx-closed.md:1:1-1:15: Headings should use atx', - 'heading-style-atx-closed.md:3:1-3:17: Headings should use atx', - 'heading-style-atx-closed.md:5:1-5:19: Headings should use atx', - 'heading-style-atx-closed.md:7:1-7:21: Headings should use atx', - 'heading-style-atx-closed.md:9:1-9:23: Headings should use atx', - 'heading-style-atx-closed.md:11:1-11:25: Headings should use atx' - ]); - - assertFile('heading-style-setext.md', [ - 'heading-style-setext.md:1:1-2:6: Headings should use atx', - 'heading-style-setext.md:4:1-5:6: Headings should use atx' - ]); - - assertFile('heading-style-not-consistent.md', [ - 'heading-style-not-consistent.md:3:1-4:6: Headings should use atx', - 'heading-style-not-consistent.md:6:1-6:19: Headings should use atx', - 'heading-style-not-consistent.md:10:1-10:24: Headings should use atx' - ]); - - assertFile('heading-style-empty.md', [ - 'heading-style-empty.md:1:1-1:4: Headings should use atx', - 'heading-style-empty.md:5:1-5:8: Headings should use atx', - 'heading-style-empty.md:9:1-9:12: Headings should use atx' - ]); - }); - - describeSetting('atx-closed', function () { - assertFile('heading-style-atx.md', [ - 'heading-style-atx.md:1:1-1:6: Headings should use atx-closed', - 'heading-style-atx.md:3:1-3:7: Headings should use atx-closed', - 'heading-style-atx.md:5:1-5:17: Headings should use atx-closed', - 'heading-style-atx.md:7:1-7:18: Headings should use atx-closed', - 'heading-style-atx.md:9:1-9:19: Headings should use atx-closed', - 'heading-style-atx.md:11:1-11:20: Headings should use atx-closed' - ]); - - assertFile('heading-style-atx-closed.md', []); - - assertFile('heading-style-setext.md', [ - 'heading-style-setext.md:1:1-2:6: Headings should use atx-closed', - 'heading-style-setext.md:4:1-5:6: Headings should use atx-closed', - 'heading-style-setext.md:7:1-7:17: Headings should use atx-closed', - 'heading-style-setext.md:9:1-9:18: Headings should use atx-closed', - 'heading-style-setext.md:11:1-11:19: Headings should use atx-closed', - 'heading-style-setext.md:13:1-13:20: Headings should use atx-closed' - ]); - - assertFile('heading-style-not-consistent.md', [ - 'heading-style-not-consistent.md:1:1-1:6: Headings should use atx-closed', - 'heading-style-not-consistent.md:3:1-4:6: Headings should use atx-closed', - 'heading-style-not-consistent.md:8:1-8:18: Headings should use atx-closed', - 'heading-style-not-consistent.md:12:1-12:20: Headings should use atx-closed' - ]); - - assertFile('heading-style-empty.md', [ - 'heading-style-empty.md:3:1-3:3: Headings should use atx-closed', - 'heading-style-empty.md:7:1-7:5: Headings should use atx-closed', - 'heading-style-empty.md:11:1-11:7: Headings should use atx-closed' - ]); - }); - - describeSetting('setext', function () { - assertFile('heading-style-atx.md', [ - 'heading-style-atx.md:1:1-1:6: Headings should use setext', - 'heading-style-atx.md:3:1-3:7: Headings should use setext' - ]); - - assertFile('heading-style-atx-closed.md', [ - 'heading-style-atx-closed.md:1:1-1:15: Headings should use setext', - 'heading-style-atx-closed.md:3:1-3:17: Headings should use setext', - 'heading-style-atx-closed.md:5:1-5:19: Headings should use setext', - 'heading-style-atx-closed.md:7:1-7:21: Headings should use setext', - 'heading-style-atx-closed.md:9:1-9:23: Headings should use setext', - 'heading-style-atx-closed.md:11:1-11:25: Headings should use setext' - ]); - - assertFile('heading-style-setext.md', []); - - assertFile('heading-style-not-consistent.md', [ - 'heading-style-not-consistent.md:1:1-1:6: Headings should use setext', - 'heading-style-not-consistent.md:6:1-6:19: Headings should use setext', - 'heading-style-not-consistent.md:10:1-10:24: Headings should use setext' - ]); - - assertFile('heading-style-empty.md', [ - 'heading-style-empty.md:1:1-1:4: Headings should use setext', - 'heading-style-empty.md:3:1-3:3: Headings should use setext', - 'heading-style-empty.md:5:1-5:8: Headings should use setext', - 'heading-style-empty.md:9:1-9:12: Headings should use setext' - ]); - }); - }); - - describeRule('no-heading-indent', function () { - describeSetting(true, function () { - assertFile('no-heading-indent-invalid.md', [ - 'no-heading-indent-invalid.md:1:4: Remove 3 spaces before this heading', - 'no-heading-indent-invalid.md:3:2: Remove 1 space before this heading', - 'no-heading-indent-invalid.md:6:2: Remove 1 space before this heading', - 'no-heading-indent-invalid.md:8:4: Remove 3 spaces before this heading' - ]); - - assertFile('no-heading-indent-valid.md', []); - }); - }); - - describeRule('no-heading-content-indent', function () { - describeSetting(true, function () { - assertFile('no-heading-content-indent-invalid.md', [ - 'no-heading-content-indent-invalid.md:1:4: Remove 1 space before this heading’s content', - 'no-heading-content-indent-invalid.md:3:6: Remove 2 spaces before this heading’s content', - 'no-heading-content-indent-invalid.md:5:5: Add 1 space before this heading’s content', - 'no-heading-content-indent-invalid.md:5:41: Remove 1 space after this heading’s content', - 'no-heading-content-indent-invalid.md:7:7: Remove 1 space before this heading’s content', - 'no-heading-content-indent-invalid.md:7:39: Remove 1 space after this heading’s content' - ], { - 'pedantic': true - }); - - assertFile('no-heading-content-indent-valid.md', [], { - 'pedantic': true - }); - }); - }); - - describeRule('no-duplicate-headings', function () { - describeSetting(true, function () { - assertFile('no-duplicate-headings-invalid.md', [ - 'no-duplicate-headings-invalid.md:3:1-3:8: Do not use headings with similar content (1:1)', - 'no-duplicate-headings-invalid.md:8:1-8:28: Do not use headings with similar content (5:1)' - ]); - - assertFile('no-duplicate-headings-valid.md', []); - }); - }); - - describeRule('no-emphasis-as-heading', function () { - describeSetting(true, function () { - assertFile('no-emphasis-as-heading-invalid.md', [ - 'no-emphasis-as-heading-invalid.md:1:1-1:24: Don’t use emphasis to introduce a section, use a heading', - 'no-emphasis-as-heading-invalid.md:5:1-5:20: Don’t use emphasis to introduce a section, use a heading' - ]); - - assertFile('no-emphasis-as-heading-valid.md', []); - }); - }); - - describeRule('no-multiple-toplevel-headings', function () { - describeSetting(true, function () { - assertFile('no-multiple-toplevel-headings-invalid.md', [ - 'no-multiple-toplevel-headings-invalid.md:6:1-7:8: Don’t use multiple top level headings (6:1)' - ]); - - assertFile('no-multiple-toplevel-headings-valid.md', []); - }); - - describeSetting(2, function () { - assertFile('no-multiple-toplevel-headings-invalid-second.md', [ - 'no-multiple-toplevel-headings-invalid-second.md:4:1-4:11: Don’t use multiple top level headings (4:1)' - ]); - - assertFile('no-multiple-toplevel-headings-valid-second.md', []); - }); - }); - - describeRule('no-literal-urls', function () { - describeSetting(true, function () { - assertFile('no-literal-urls-invalid.md', [ - 'no-literal-urls-invalid.md:1:1-1:19: Don’t use literal URLs without angle brackets' - ]); - - assertFile('no-literal-urls-valid.md', []); - }); - }); - - describeRule('no-auto-link-without-protocol', function () { - describeSetting(true, function () { - assertFile('no-auto-link-without-protocol-invalid.md', [ - 'no-auto-link-without-protocol-invalid.md:8:1-8:17: All automatic links must start with a protocol' - ]); - - assertFile('no-auto-link-without-protocol-valid.md', []); - }); - }); - - describeRule('no-consecutive-blank-lines', function () { - describeSetting(true, function () { - assertFile('no-consecutive-blank-lines-invalid.md', [ - 'no-consecutive-blank-lines-invalid.md:2:1: Remove 1 line before node', - 'no-consecutive-blank-lines-invalid.md:5:1: Remove 1 line before node', - 'no-consecutive-blank-lines-invalid.md:8:1: Remove 1 line before node', - 'no-consecutive-blank-lines-invalid.md:11:3: Remove 1 line before node', - 'no-consecutive-blank-lines-invalid.md:14:1: Remove 1 line before node', - 'no-consecutive-blank-lines-invalid.md:18:1: Remove 1 line before node', - 'no-consecutive-blank-lines-invalid.md:22:1: Remove 1 line before node' - ]); - - assertFile('no-consecutive-blank-lines-valid.md', []); - }); - }); - - describeRule('no-missing-blank-lines', function () { - describeSetting(true, function () { - assertFile('no-missing-blank-lines-invalid.md', [ - 'no-missing-blank-lines-invalid.md:4:1-6:31: Missing blank line before block node', - 'no-missing-blank-lines-invalid.md:7:1-7:12: Missing blank line before block node', - 'no-missing-blank-lines-invalid.md:8:1-9:4: Missing blank line before block node', - 'no-missing-blank-lines-invalid.md:10:1-11:39: Missing blank line before block node', - 'no-missing-blank-lines-invalid.md:12:1-12:4: Missing blank line before block node', - 'no-missing-blank-lines-invalid.md:13:1-15:4: Missing blank line before block node', - 'no-missing-blank-lines-invalid.md:16:1-16:18: Missing blank line before block node', - 'no-missing-blank-lines-invalid.md:17:1-17:20: Missing blank line before block node', - 'no-missing-blank-lines-invalid.md:18:1-18:15: Missing blank line before block node', - 'no-missing-blank-lines-invalid.md:21:1-21:13: Missing blank line before block node' - ]); - - assertFile('no-missing-blank-lines-valid.md', []); - }); - }); - - describeRule('blockquote-indentation', function () { - describeSetting(true, function () { - assertFile('blockquote-indentation-2.md', []); - assertFile('blockquote-indentation-4.md', []); - }); - - describeSetting(2, function () { - assertFile('blockquote-indentation-2.md', []); - - assertFile('blockquote-indentation-4.md', [ - 'blockquote-indentation-4.md:1:3: Remove 2 spaces between blockquote and content', - 'blockquote-indentation-4.md:5:3: Remove 2 spaces between blockquote and content', - 'blockquote-indentation-4.md:9:3: Remove 2 spaces between blockquote and content' - ]); - }); - - describeSetting(4, function () { - assertFile('blockquote-indentation-2.md', [ - 'blockquote-indentation-2.md:1:3: Add 2 spaces between blockquote and content', - 'blockquote-indentation-2.md:5:3: Add 2 spaces between blockquote and content', - 'blockquote-indentation-2.md:9:3: Add 2 spaces between blockquote and content' - ]); - - assertFile('blockquote-indentation-4.md', []); - }); - }); - - describeRule('emphasis-marker', function () { - describeSetting(true, function () { - assertFile('emphasis-marker-asterisk-underscore.md', [ - 'emphasis-marker-asterisk-underscore.md:3:1-3:6: Emphasis should use `*` as a marker' - ]); - - assertFile('emphasis-marker-underscore-asterisk.md', [ - 'emphasis-marker-underscore-asterisk.md:3:1-3:6: Emphasis should use `_` as a marker' - ]); - - assertFile('emphasis-marker-asterisk.md', []); - assertFile('emphasis-marker-underscore.md', []); - }); - - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid emphasis marker `~`: use either `\'consistent\'`, `\'*\'`, or `\'_\'`' - ]); - }); - - describeSetting('*', function () { - assertFile('emphasis-marker-asterisk-underscore.md', [ - 'emphasis-marker-asterisk-underscore.md:3:1-3:6: Emphasis should use `*` as a marker' - ]); - - assertFile('emphasis-marker-underscore-asterisk.md', [ - 'emphasis-marker-underscore-asterisk.md:1:1-1:6: Emphasis should use `*` as a marker' - ]); - - assertFile('emphasis-marker-asterisk.md', []); - - assertFile('emphasis-marker-underscore.md', [ - 'emphasis-marker-underscore.md:1:1-1:6: Emphasis should use `*` as a marker', - 'emphasis-marker-underscore.md:3:1-3:6: Emphasis should use `*` as a marker' - ]); - }); - - describeSetting('_', function () { - assertFile('emphasis-marker-asterisk-underscore.md', [ - 'emphasis-marker-asterisk-underscore.md:1:1-1:6: Emphasis should use `_` as a marker' - ]); + return value.slice(value.indexOf(':') + 1); + }); +} - assertFile('emphasis-marker-underscore-asterisk.md', [ - 'emphasis-marker-underscore-asterisk.md:3:1-3:6: Emphasis should use `_` as a marker' - ]); - - assertFile('emphasis-marker-asterisk.md', [ - 'emphasis-marker-asterisk.md:1:1-1:6: Emphasis should use `_` as a marker', - 'emphasis-marker-asterisk.md:3:1-3:6: Emphasis should use `_` as a marker' - ]); - - assertFile('emphasis-marker-underscore.md', []); - }); - - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid emphasis marker `~`: use either `\'consistent\'`, `\'*\'`, or `\'_\'`' - ]); - }); - }); - - describeRule('strong-marker', function () { - describeSetting(true, function () { - assertFile('strong-marker-asterisk-underscore.md', [ - 'strong-marker-asterisk-underscore.md:3:1-3:8: Strong should use `*` as a marker' - ]); - - assertFile('strong-marker-underscore-asterisk.md', [ - 'strong-marker-underscore-asterisk.md:3:1-3:8: Strong should use `_` as a marker' - ]); - - assertFile('strong-marker-asterisk.md', []); - assertFile('strong-marker-underscore.md', []); - }); - - describeSetting('*', function () { - assertFile('strong-marker-asterisk-underscore.md', [ - 'strong-marker-asterisk-underscore.md:3:1-3:8: Strong should use `*` as a marker' - ]); - - assertFile('strong-marker-underscore-asterisk.md', [ - 'strong-marker-underscore-asterisk.md:1:1-1:8: Strong should use `*` as a marker' - ]); - - assertFile('strong-marker-asterisk.md', []); - - assertFile('strong-marker-underscore.md', [ - 'strong-marker-underscore.md:1:1-1:8: Strong should use `*` as a marker', - 'strong-marker-underscore.md:3:1-3:8: Strong should use `*` as a marker' - ]); - }); - - describeSetting('_', function () { - assertFile('strong-marker-asterisk-underscore.md', [ - 'strong-marker-asterisk-underscore.md:1:1-1:8: Strong should use `_` as a marker' - ]); - - assertFile('strong-marker-underscore-asterisk.md', [ - 'strong-marker-underscore-asterisk.md:3:1-3:8: Strong should use `_` as a marker' - ]); - - assertFile('strong-marker-asterisk.md', [ - 'strong-marker-asterisk.md:1:1-1:8: Strong should use `_` as a marker', - 'strong-marker-asterisk.md:3:1-3:8: Strong should use `_` as a marker' - ]); - - assertFile('strong-marker-underscore.md', []); - }); - - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid strong marker `~`: use either `\'consistent\'`, `\'*\'`, or `\'_\'`' - ]); - }); - }); - - describeRule('no-inline-padding', function () { - describeSetting(true, function () { - assertFile('no-inline-padding-invalid.md', [ - 'no-inline-padding-invalid.md:1:11-1:17: Don’t pad `emphasis` with inner spaces', - 'no-inline-padding-invalid.md:1:23-1:29: Don’t pad `emphasis` with inner spaces', - 'no-inline-padding-invalid.md:3:9-3:17: Don’t pad `strong` with inner spaces', - 'no-inline-padding-invalid.md:3:22-3:30: Don’t pad `strong` with inner spaces', - 'no-inline-padding-invalid.md:7:11-7:31: Don’t pad `image` with inner spaces', - 'no-inline-padding-invalid.md:9:9-9:32: Don’t pad `link` with inner spaces' - ]); - - assertFile('no-inline-padding-valid.md', []); - }); - }); - - describeRule('no-table-indentation', function () { - describeSetting(true, function () { - assertFile('no-table-indentation-invalid.md', [ - 'no-table-indentation-invalid.md:4:1-4:16: Do not indent table rows', - 'no-table-indentation-invalid.md:6:1-6:16: Do not indent table rows' - ]); - - assertFile('no-table-indentation-valid.md', []); - }); - }); - - describeRule('table-pipes', function () { - describeSetting(true, function () { - assertFile('table-pipes-invalid.md', [ - 'table-pipes-invalid.md:3:1: Missing initial pipe in table fence', - 'table-pipes-invalid.md:3:10: Missing final pipe in table fence', - 'table-pipes-invalid.md:5:1: Missing initial pipe in table fence', - 'table-pipes-invalid.md:5:10: Missing final pipe in table fence', - 'table-pipes-invalid.md:9:1: Missing initial pipe in table fence', - 'table-pipes-invalid.md:11:1: Missing initial pipe in table fence', - 'table-pipes-invalid.md:15:12: Missing final pipe in table fence', - 'table-pipes-invalid.md:17:12: Missing final pipe in table fence', - 'table-pipes-invalid.md:21:1: Missing initial pipe in table fence', - 'table-pipes-invalid.md:21:18: Missing final pipe in table fence', - 'table-pipes-invalid.md:23:1: Missing initial pipe in table fence', - 'table-pipes-invalid.md:23:16: Missing final pipe in table fence' - ]); - - assertFile('table-pipes-valid.md', []); - }); - }); - - describeRule('table-pipe-alignment', function () { - describeSetting(true, function () { - assertFile('table-pipe-alignment-invalid.md', [ - 'table-pipe-alignment-invalid.md:5:6-5:7: Misaligned table fence', - 'table-pipe-alignment-invalid.md:5:22-5:23: Misaligned table fence' - ]); - - assertFile('table-pipe-alignment-valid.md', []); - }); - }); - - describeRule('table-cell-padding', function () { - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid table-cell-padding style `~`' - ]); - }); - - describeSetting(true, function () { - assertFile('table-cell-padding-padded.md', []); - assertFile('table-cell-padding-compact.md', []); - assertFile('table-cell-padding-padded-unaligned.md', []); - assertFile('table-cell-padding-compact-unaligned.md', []); - - assertFile('table-cell-padding-mixed.md', [ - 'table-cell-padding-mixed.md:3:7: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:3:16: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:3:20: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:7:7: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:7:16: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:7:20: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:13:10: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:13:15: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:13:23: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:13:28: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:17:10: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:17:14: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:17:25: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:17:28: Cell should be padded, isn’t' - ]); - }); - - describeSetting('compact', function () { - assertFile('table-cell-padding-padded.md', [ - 'table-cell-padding-padded.md:3:3: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:3:8: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:3:11: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:3:16: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:3:19: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:3:24: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:3:27: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:3:32: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:9:3: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:9:8: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:9:11: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:9:16: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:9:20: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:9:24: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:9:29: Cell should be compact, isn’t', - 'table-cell-padding-padded.md:9:32: Cell should be compact, isn’t' - ]); - - assertFile('table-cell-padding-compact.md', []); - - assertFile('table-cell-padding-padded-unaligned.md', [ - 'table-cell-padding-padded-unaligned.md:3:3: Cell should be compact, isn’t', - 'table-cell-padding-padded-unaligned.md:3:8: Cell should be compact, isn’t', - 'table-cell-padding-padded-unaligned.md:3:11: Cell should be compact, isn’t', - 'table-cell-padding-padded-unaligned.md:3:13: Cell should be compact, isn’t', - 'table-cell-padding-padded-unaligned.md:3:16: Cell should be compact, isn’t', - 'table-cell-padding-padded-unaligned.md:3:21: Cell should be compact, isn’t', - 'table-cell-padding-padded-unaligned.md:3:24: Cell should be compact, isn’t', - 'table-cell-padding-padded-unaligned.md:3:26: Cell should be compact, isn’t' - ]); - - assertFile('table-cell-padding-compact-unaligned.md', []); - - assertFile('table-cell-padding-mixed.md', [ - 'table-cell-padding-mixed.md:3:7: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:3:16: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:3:20: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:7:7: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:7:16: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:7:20: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:13:3: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:13:8: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:13:17: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:13:21: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:17:3: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:17:8: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:17:17: Cell should be compact, isn’t', - 'table-cell-padding-mixed.md:17:21: Cell should be compact, isn’t' - ]); - }); - - describeSetting('padded', function () { - assertFile('table-cell-padding-padded.md', []); - - assertFile('table-cell-padding-compact.md', [ - 'table-cell-padding-compact.md:3:2: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:3:7: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:3:8: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:3:13: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:3:14: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:3:19: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:3:20: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:3:25: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:9:2: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:9:6: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:9:8: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:9:12: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:9:15: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:9:18: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:9:22: Cell should be padded, isn’t', - 'table-cell-padding-compact.md:9:25: Cell should be padded, isn’t' - ]); - - assertFile('table-cell-padding-padded-unaligned.md', []); - - assertFile('table-cell-padding-compact-unaligned.md', [ - 'table-cell-padding-compact-unaligned.md:3:2: Cell should be padded, isn’t', - 'table-cell-padding-compact-unaligned.md:3:7: Cell should be padded, isn’t', - 'table-cell-padding-compact-unaligned.md:3:8: Cell should be padded, isn’t', - 'table-cell-padding-compact-unaligned.md:3:10: Cell should be padded, isn’t', - 'table-cell-padding-compact-unaligned.md:3:11: Cell should be padded, isn’t', - 'table-cell-padding-compact-unaligned.md:3:16: Cell should be padded, isn’t', - 'table-cell-padding-compact-unaligned.md:3:17: Cell should be padded, isn’t', - 'table-cell-padding-compact-unaligned.md:3:19: Cell should be padded, isn’t' - ]); - - assertFile('table-cell-padding-mixed.md', [ - 'table-cell-padding-mixed.md:3:2: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:3:9: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:3:14: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:3:22: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:3:27: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:7:2: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:7:9: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:7:13: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:7:24: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:7:27: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:13:10: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:13:15: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:13:23: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:13:28: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:17:10: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:17:14: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:17:25: Cell should be padded, isn’t', - 'table-cell-padding-mixed.md:17:28: Cell should be padded, isn’t' - ]); - }); - }); - - describeRule('no-blockquote-without-caret', function () { - describeSetting(true, function () { - assertFile('no-blockquote-without-caret-invalid.md', [ - 'no-blockquote-without-caret-invalid.md:3:1: Missing caret in blockquote', - 'no-blockquote-without-caret-invalid.md:9:1: Missing caret in blockquote', - 'no-blockquote-without-caret-invalid.md:10:1: Missing caret in blockquote', - 'no-blockquote-without-caret-invalid.md:17:1: Missing caret in blockquote' - ]); - - assertFile('no-blockquote-without-caret-valid.md', []); - }); - }); - - describeRule('code-block-style', function () { - describeSetting(true, function () { - assertFile('code-style-indented.md', []); - assertFile('code-style-fenced.md', []); - }); - - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid code block style `~`: use either `\'consistent\'`, `\'fenced\'`, or `\'indented\'`' - ]); - }); - - describeSetting('indented', function () { - assertFile('code-style-indented.md', []); - - assertFile('code-style-fenced.md', [ - 'code-style-fenced.md:3:1-5:4: Code blocks should be indented', - 'code-style-fenced.md:9:1-11:4: Code blocks should be indented' - ]); - }); - - describeSetting('fenced', function () { - assertFile('code-style-indented.md', [ - 'code-style-indented.md:3:1-3:8: Code blocks should be fenced', - 'code-style-indented.md:7:1-7:8: Code blocks should be fenced' - ]); - - assertFile('code-style-fenced.md', []); - }); - }); - - describeRule('definition-case', function () { - describeSetting(true, function () { - assertFile('definition-case-invalid.md', [ - 'definition-case-invalid.md:3:1-3:59: Do not use upper-case characters in definition labels' - ]); - - assertFile('definition-case-valid.md', []); - }); - }); - - describeRule('definition-spacing', function () { - describeSetting(true, function () { - assertFile('definition-spacing-invalid.md', [ - 'definition-spacing-invalid.md:3:1-3:68: Do not use consecutive white-space in definition labels' - ]); - - assertFile('definition-spacing-valid.md', []); - }); - }); - - describeRule('fenced-code-flag', function () { - describeSetting(true, function () { - assertFile('fenced-code-flag-invalid.md', [ - 'fenced-code-flag-invalid.md:3:1-5:4: Missing code-language flag' - ]); - - assertFile('fenced-code-flag-unknown.md', []); - assertFile('fenced-code-flag-valid.md', []); - }); - - describeSetting(['foo'], function () { - assertFile('fenced-code-flag-invalid.md', [ - 'fenced-code-flag-invalid.md:3:1-5:4: Missing code-language flag' - ]); - - assertFile('fenced-code-flag-unknown.md', [ - 'fenced-code-flag-unknown.md:3:1-5:4: Invalid code-language flag' - ]); - - assertFile('fenced-code-flag-valid.md', []); - }); - - describeSetting({ - 'allowEmpty': true, - 'flags': ['foo'] - }, function () { - assertFile('fenced-code-flag-invalid.md', []); - - assertFile('fenced-code-flag-unknown.md', [ - 'fenced-code-flag-unknown.md:3:1-5:4: Invalid code-language flag' - ]); - - assertFile('fenced-code-flag-valid.md', []); - }); - }); - - describeRule('final-definition', function () { - describeSetting(true, function () { - assertFile('final-definition-invalid.md', [ - 'final-definition-invalid.md:1:1-1:57: Move definitions to the end of the file (after the node at line `7`)', - 'final-definition-invalid.md:5:1-5:59: Move definitions to the end of the file (after the node at line `7`)' - ]); - - assertFile('final-definition-valid.md', []); - }); - }); - - describeRule('hard-break-spaces', function () { - describeSetting(true, function () { - assertFile('hard-break-spaces-invalid.md', [ - 'hard-break-spaces-invalid.md:1:25-2:1: Use two spaces for hard line breaks', - 'hard-break-spaces-invalid.md:4:40-5:5: Use two spaces for hard line breaks' - ]); - - assertFile('hard-break-spaces-valid.md', []); - }); - }); - - describeRule('no-html', function () { - describeSetting(true, function () { - assertFile('no-html-invalid.md', [ - 'no-html-invalid.md:1:1-1:14: Do not use HTML in markdown', - 'no-html-invalid.md:3:8-3:14: Do not use HTML in markdown', - 'no-html-invalid.md:3:18-3:25: Do not use HTML in markdown' - ]); - - assertFile('no-html-valid.md', []); - }); - }); - - describeRule('maximum-line-length', function () { - describeSetting(true, function () { - assertFile('maximum-line-length-invalid.md', [ - 'maximum-line-length-invalid.md:1:82: Line must be at most 80 characters', - 'maximum-line-length-invalid.md:3:86: Line must be at most 80 characters', - 'maximum-line-length-invalid.md:5:99: Line must be at most 80 characters', - 'maximum-line-length-invalid.md:7:97: Line must be at most 80 characters' - ]); - - assertFile('maximum-line-length-valid.md', []); - }); - - describeSetting(100, function () { - assertFile('maximum-line-length-invalid.md', []); - assertFile('maximum-line-length-valid.md', []); - }); - }); - - describeRule('list-item-bullet-indent', function () { - describeSetting(true, function () { - assertFile('list-item-bullet-indent-invalid.md', [ - 'list-item-bullet-indent-invalid.md:3:3: Incorrect indentation before bullet: remove 2 spaces', - 'list-item-bullet-indent-invalid.md:4:3: Incorrect indentation before bullet: remove 2 spaces' - ]); - - assertFile('list-item-bullet-indent-valid.md', []); - }); - }); - - describeRule('list-item-content-indent', function () { - describeSetting(true, function () { - assertFile('list-item-content-indent-invalid.md', [ - 'list-item-content-indent-invalid.md:14:5: Don’t use mixed indentation for children, remove 1 space', - 'list-item-content-indent-invalid.md:19:5: Don’t use mixed indentation for children, remove 1 space' - ]); - - assertFile('list-item-content-indent-valid.md', []); - }); - }); - - describeRule('list-item-indent', function () { - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid list-item indent style `~`: use either `\'tab-size\'`, `\'space\'`, or `\'mixed\'`' - ]); - }); - - describeSetting('tab-size', function () { - assertFile('list-item-indent-tab-size.md', []); - - assertFile('list-item-indent-space.md', [ - 'list-item-indent-space.md:3:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-space.md:4:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-space.md:5:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-space.md:9:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:10:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:11:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:15:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-space.md:18:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-space.md:21:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-space.md:26:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:29:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:32:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:37:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:43:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:54:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:55:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:56:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:57:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:58:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:59:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:60:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:61:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:62:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:63:4: Incorrect list-item indent: add 1 space' - ]); - - assertFile('list-item-indent-mixed.md', [ - 'list-item-indent-mixed.md:3:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-mixed.md:4:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-mixed.md:5:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-mixed.md:9:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-mixed.md:10:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-mixed.md:11:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-mixed.md:37:4: Incorrect list-item indent: add 1 space' - ]); - }); - - describeSetting('space', function () { - assertFile('list-item-indent-tab-size.md', [ - 'list-item-indent-tab-size.md:3:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-tab-size.md:4:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-tab-size.md:5:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-tab-size.md:9:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-tab-size.md:10:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-tab-size.md:11:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-tab-size.md:15:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-tab-size.md:18:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-tab-size.md:21:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-tab-size.md:26:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-tab-size.md:29:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-tab-size.md:32:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-tab-size.md:37:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-tab-size.md:43:5: Incorrect list-item indent: remove 1 space' - ]); - - assertFile('list-item-indent-space.md', []); - - assertFile('list-item-indent-mixed.md', [ - 'list-item-indent-mixed.md:15:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-mixed.md:18:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-mixed.md:21:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-mixed.md:26:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-mixed.md:29:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-mixed.md:32:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-mixed.md:43:5: Incorrect list-item indent: remove 1 space' - ]); - }); - - describeSetting('mixed', function () { - assertFile('list-item-indent-tab-size.md', [ - 'list-item-indent-tab-size.md:3:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-tab-size.md:4:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-tab-size.md:5:5: Incorrect list-item indent: remove 2 spaces', - 'list-item-indent-tab-size.md:9:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-tab-size.md:10:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-tab-size.md:11:5: Incorrect list-item indent: remove 1 space', - 'list-item-indent-tab-size.md:37:5: Incorrect list-item indent: remove 1 space' - ]); - - assertFile('list-item-indent-space.md', [ - 'list-item-indent-space.md:15:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-space.md:18:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-space.md:21:3: Incorrect list-item indent: add 2 spaces', - 'list-item-indent-space.md:26:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:29:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:32:4: Incorrect list-item indent: add 1 space', - 'list-item-indent-space.md:43:4: Incorrect list-item indent: add 1 space' - ]); - - assertFile('list-item-indent-mixed.md', []); - }); - }); - - describeRule('list-item-spacing', function () { - describeSetting(true, function () { - assertFile('list-item-spacing-tight-invalid.md', [ - 'list-item-spacing-tight-invalid.md:2:1-3:1: Extraneous new line after list item', - 'list-item-spacing-tight-invalid.md:4:1-5:1: Extraneous new line after list item' - ]); - - assertFile('list-item-spacing-loose-invalid.md', [ - 'list-item-spacing-loose-invalid.md:2:9-3:1: Missing new line after list item', - 'list-item-spacing-loose-invalid.md:3:11-4:1: Missing new line after list item' - ]); - - assertFile('list-item-spacing-tight-valid.md', []); - assertFile('list-item-spacing-loose-valid.md', []); - }); - }); - - describeRule('ordered-list-marker-value', function () { - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid ordered list-item marker value `~`: use either `\'ordered\'` or `\'one\'`' - ]); - }); - - describeSetting('ordered', function () { - assertFile('ordered-list-marker-value-ordered.md', []); - - assertFile('ordered-list-marker-value-one.md', [ - 'ordered-list-marker-value-one.md:2:1-2:9: Marker should be `2`, was `1`', - 'ordered-list-marker-value-one.md:3:1-3:11: Marker should be `3`, was `1`', - 'ordered-list-marker-value-one.md:7:1-7:9: Marker should be `2`, was `1`', - 'ordered-list-marker-value-one.md:8:1-8:11: Marker should be `3`, was `1`' - ]); - - assertFile('ordered-list-marker-value-single.md', [ - 'ordered-list-marker-value-single.md:2:1-2:9: Marker should be `2`, was `1`', - 'ordered-list-marker-value-single.md:3:1-3:11: Marker should be `3`, was `1`', - 'ordered-list-marker-value-single.md:7:1-7:9: Marker should be `4`, was `3`', - 'ordered-list-marker-value-single.md:8:1-8:11: Marker should be `5`, was `3`' - ]); - }); - - describeSetting('one', function () { - assertFile('ordered-list-marker-value-ordered.md', [ - 'ordered-list-marker-value-ordered.md:2:1-2:9: Marker should be `1`, was `2`', - 'ordered-list-marker-value-ordered.md:3:1-3:11: Marker should be `1`, was `3`', - 'ordered-list-marker-value-ordered.md:7:1-7:9: Marker should be `1`, was `4`', - 'ordered-list-marker-value-ordered.md:8:1-8:11: Marker should be `1`, was `5`' - ]); - - assertFile('ordered-list-marker-value-one.md', []); - - assertFile('ordered-list-marker-value-single.md', [ - 'ordered-list-marker-value-single.md:7:1-7:9: Marker should be `1`, was `3`', - 'ordered-list-marker-value-single.md:8:1-8:11: Marker should be `1`, was `3`' - ]); - }); - - describeSetting('single', function () { - assertFile('ordered-list-marker-value-ordered.md', [ - 'ordered-list-marker-value-ordered.md:2:1-2:9: Marker should be `1`, was `2`', - 'ordered-list-marker-value-ordered.md:3:1-3:11: Marker should be `1`, was `3`', - 'ordered-list-marker-value-ordered.md:7:1-7:9: Marker should be `3`, was `4`', - 'ordered-list-marker-value-ordered.md:8:1-8:11: Marker should be `3`, was `5`' - ]); - - assertFile('ordered-list-marker-value-one.md', []); - - assertFile('ordered-list-marker-value-single.md', []); - }); - }); - - describeRule('ordered-list-marker-style', function () { - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid ordered list-item marker style `~`: use either `\'.\'` or `\')\'`' - ]); - }); - - describeSetting(true, function () { - assertFile('list-item-marker-dot.md', [], { - 'commonmark': true - }); - - assertFile('list-item-marker-paren.md', [], { - 'commonmark': true - }); - }); - - describeSetting('.', function () { - assertFile('list-item-marker-dot.md', [], { - 'commonmark': true - }); - - assertFile('list-item-marker-paren.md', [ - 'list-item-marker-paren.md:1:1-1:10: Marker style should be `.`', - 'list-item-marker-paren.md:2:1-2:11: Marker style should be `.`', - 'list-item-marker-paren.md:4:3-4:14: Marker style should be `.`', - 'list-item-marker-paren.md:5:3-5:15: Marker style should be `.`' - ], { - 'commonmark': true - }); - }); - - describeSetting(')', function () { - assertFile('list-item-marker-dot.md', [ - 'list-item-marker-dot.md:1:1-1:10: Marker style should be `)`', - 'list-item-marker-dot.md:2:1-2:11: Marker style should be `)`', - 'list-item-marker-dot.md:4:3-4:14: Marker style should be `)`', - 'list-item-marker-dot.md:5:3-5:15: Marker style should be `)`' - ], { - 'commonmark': true - }); - - assertFile('list-item-marker-paren.md', [], { - 'commonmark': true - }); - }); - }); - - describeRule('unordered-list-marker-style', function () { - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid unordered list-item marker style `~`: use either `\'-\'`, `\'*\'`, or `\'+\'`' - ]); - }); - - describeSetting(true, function () { - assertFile('list-item-marker-dash.md', []); - assertFile('list-item-marker-asterisk.md', []); - assertFile('list-item-marker-plus.md', []); - }); - - describeSetting('-', function () { - assertFile('list-item-marker-dash.md', []); - - assertFile('list-item-marker-asterisk.md', [ - 'list-item-marker-asterisk.md:1:1-1:9: Marker style should be `-`', - 'list-item-marker-asterisk.md:4:1-4:11: Marker style should be `-`', - 'list-item-marker-asterisk.md:7:3-7:13: Marker style should be `-`', - 'list-item-marker-asterisk.md:10:3-10:15: Marker style should be `-`' - ]); - - assertFile('list-item-marker-plus.md', [ - 'list-item-marker-plus.md:1:1-1:9: Marker style should be `-`', - 'list-item-marker-plus.md:4:1-4:11: Marker style should be `-`', - 'list-item-marker-plus.md:7:3-7:13: Marker style should be `-`', - 'list-item-marker-plus.md:10:3-10:15: Marker style should be `-`' - ]); - }); - - describeSetting('*', function () { - assertFile('list-item-marker-dash.md', [ - 'list-item-marker-dash.md:1:1-1:9: Marker style should be `*`', - 'list-item-marker-dash.md:2:1-2:11: Marker style should be `*`', - 'list-item-marker-dash.md:4:3-4:13: Marker style should be `*`', - 'list-item-marker-dash.md:5:3-5:15: Marker style should be `*`' - ]); - - assertFile('list-item-marker-asterisk.md', []); - - assertFile('list-item-marker-plus.md', [ - 'list-item-marker-plus.md:1:1-1:9: Marker style should be `*`', - 'list-item-marker-plus.md:4:1-4:11: Marker style should be `*`', - 'list-item-marker-plus.md:7:3-7:13: Marker style should be `*`', - 'list-item-marker-plus.md:10:3-10:15: Marker style should be `*`' - ]); - }); - - describeSetting('+', function () { - assertFile('list-item-marker-dash.md', [ - 'list-item-marker-dash.md:1:1-1:9: Marker style should be `+`', - 'list-item-marker-dash.md:2:1-2:11: Marker style should be `+`', - 'list-item-marker-dash.md:4:3-4:13: Marker style should be `+`', - 'list-item-marker-dash.md:5:3-5:15: Marker style should be `+`' - ]); - - assertFile('list-item-marker-asterisk.md', [ - 'list-item-marker-asterisk.md:1:1-1:9: Marker style should be `+`', - 'list-item-marker-asterisk.md:4:1-4:11: Marker style should be `+`', - 'list-item-marker-asterisk.md:7:3-7:13: Marker style should be `+`', - 'list-item-marker-asterisk.md:10:3-10:15: Marker style should be `+`' - ]); - - assertFile('list-item-marker-plus.md', []); - }); - }); - - describeRule('no-tabs', function () { - describeSetting(true, function () { - assertFile('no-tabs-invalid.md', [ - 'no-tabs-invalid.md:1:1: Use spaces instead of hard-tabs', - 'no-tabs-invalid.md:3:14: Use spaces instead of hard-tabs', - 'no-tabs-invalid.md:3:37: Use spaces instead of hard-tabs', - 'no-tabs-invalid.md:5:23: Use spaces instead of hard-tabs', - 'no-tabs-invalid.md:7:2: Use spaces instead of hard-tabs', - 'no-tabs-invalid.md:9:2: Use spaces instead of hard-tabs', - 'no-tabs-invalid.md:11:1: Use spaces instead of hard-tabs', - 'no-tabs-invalid.md:11:4: Use spaces instead of hard-tabs', - 'no-tabs-invalid.md:13:41: Use spaces instead of hard-tabs' - ]); - - assertFile('no-tabs-valid.md', []); - }); - }); - - describeRule('no-shell-dollars', function () { - describeSetting(true, function () { - assertFile('no-shell-dollars-invalid.md', [ - 'no-shell-dollars-invalid.md:15:1-18:4: Do not use dollar signs before shell-commands', - 'no-shell-dollars-invalid.md:20:1-24:4: Do not use dollar signs before shell-commands', - 'no-shell-dollars-invalid.md:26:1-29:4: Do not use dollar signs before shell-commands' - ]); - - assertFile('no-shell-dollars-valid.md', []); - }); - }); - - describeRule('no-shortcut-reference-link', function () { - describeSetting(true, function () { - assertFile('no-shortcut-reference-link-invalid.md', [ - 'no-shortcut-reference-link-invalid.md:1:11-1:20: Use the trailing [] on reference links', - 'no-shortcut-reference-link-invalid.md:1:48-1:57: Use the trailing [] on reference links' - ]); - - assertFile('no-shortcut-reference-link-valid.md', []); - }); - }); - - describeRule('no-shortcut-reference-image', function () { - describeSetting(true, function () { - assertFile('no-shortcut-reference-image-invalid.md', [ - 'no-shortcut-reference-image-invalid.md:1:11-1:19: Use the trailing [] on reference images', - 'no-shortcut-reference-image-invalid.md:1:48-1:58: Use the trailing [] on reference images' - ]); - - assertFile('no-shortcut-reference-image-valid.md', []); - }); - }); - - describeRule('no-blockquote-without-caret', function () { - describeSetting(true, function () { - assertFile('no-blockquote-without-caret-invalid.md', [ - 'no-blockquote-without-caret-invalid.md:3:1: Missing caret in blockquote', - 'no-blockquote-without-caret-invalid.md:9:1: Missing caret in blockquote', - 'no-blockquote-without-caret-invalid.md:10:1: Missing caret in blockquote', - 'no-blockquote-without-caret-invalid.md:17:1: Missing caret in blockquote' - ]); - - assertFile('no-blockquote-without-caret-valid.md', []); - }); - }); - - describeRule('rule-style', function () { - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid preferred rule-style: provide a valid markdown rule, or `\'consistent\'`' - ]); - }); - - describeSetting(true, function () { - assertFile('rule-style-invalid.md', [ - 'rule-style-invalid.md:7:1-7:10: Rules should use `* * * *`', - 'rule-style-invalid.md:11:1-11:6: Rules should use `* * * *`', - 'rule-style-invalid.md:15:1-15:5: Rules should use `* * * *`' - ]); - - assertFile('rule-style-valid.md', []); - }); - }); - - describeRule('final-newline', function () { - describeSetting(true, function () { - assertFile('final-newline-invalid.md', [ - 'final-newline-invalid.md:1:1: Missing newline character at end of file' - ]); - - assertFile('final-newline-valid.md', []); - }); - }); - - describeRule('link-title-style', function () { - var settings = { - 'commonmark': true - }; - - describeSetting('~', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid link title style marker `~`: use either `\'consistent\'`, `\'"\'`, `\'\\\'\'`, or `\'()\'`' - ]); - }); - - describeSetting(true, function () { - assertFile('link-title-style-double.md', [], settings); - assertFile('link-title-style-single.md', [], settings); - assertFile('link-title-style-parentheses.md', [], settings); - assertFile('link-title-style-missing.md', [], settings); - - assertFile('link-title-style-trailing-white-space.md', [ - 'link-title-style-trailing-white-space.md:3:45: Titles should use `"` as a quote', - 'link-title-style-trailing-white-space.md:5:45: Titles should use `"` as a quote' - ], settings); - }); - - describeSetting('"', function () { - assertFile('link-title-style-double.md', [], settings); - assertFile('link-title-style-missing.md', [], settings); - - assertFile('link-title-style-single.md', [ - 'link-title-style-single.md:1:44: Titles should use `"` as a quote', - 'link-title-style-single.md:3:45: Titles should use `"` as a quote', - 'link-title-style-single.md:5:45: Titles should use `"` as a quote' - ], settings); - - assertFile('link-title-style-parentheses.md', [ - 'link-title-style-parentheses.md:1:44: Titles should use `"` as a quote', - 'link-title-style-parentheses.md:3:45: Titles should use `"` as a quote', - 'link-title-style-parentheses.md:5:45: Titles should use `"` as a quote' - ], settings); - }); - - describeSetting('\'', function () { - assertFile('link-title-style-single.md', [], settings); - assertFile('link-title-style-missing.md', [], settings); - - assertFile('link-title-style-double.md', [ - 'link-title-style-double.md:1:44: Titles should use `\'` as a quote', - 'link-title-style-double.md:3:45: Titles should use `\'` as a quote', - 'link-title-style-double.md:5:45: Titles should use `\'` as a quote' - ], settings); - - assertFile('link-title-style-parentheses.md', [ - 'link-title-style-parentheses.md:1:44: Titles should use `\'` as a quote', - 'link-title-style-parentheses.md:3:45: Titles should use `\'` as a quote', - 'link-title-style-parentheses.md:5:45: Titles should use `\'` as a quote' - ], settings); - }); - - describeSetting('()', function () { - assertFile('link-title-style-parentheses.md', [], settings); - assertFile('link-title-style-missing.md', [], settings); - - assertFile('link-title-style-double.md', [ - 'link-title-style-double.md:1:44: Titles should use `()` as a quote', - 'link-title-style-double.md:3:45: Titles should use `()` as a quote', - 'link-title-style-double.md:5:45: Titles should use `()` as a quote' - ], settings); - - assertFile('link-title-style-single.md', [ - 'link-title-style-single.md:1:44: Titles should use `()` as a quote', - 'link-title-style-single.md:3:45: Titles should use `()` as a quote', - 'link-title-style-single.md:5:45: Titles should use `()` as a quote' - ], settings); - }); - }); - - describeRule('no-duplicate-definitions', function () { - describeSetting(true, function () { - assertFile('no-duplicate-definitions-invalid.md', [ - 'no-duplicate-definitions-invalid.md:2:1-2:11: Do not use definitions with the same identifier (1:1)' - ]); - - assertFile('no-duplicate-definitions-valid.md', []); - }); - }); - - describeRule('no-undefined-references', function () { - describeSetting(true, function () { - assertFile('no-undefined-references-invalid.md', [ - 'no-undefined-references-invalid.md:1:1-1:8: Found reference to undefined definition' - ]); - - assertFile('no-undefined-references-valid.md', []); - }); - }); - - describeRule('no-unused-definitions', function () { - describeSetting(true, function () { - assertFile('no-unused-definitions-invalid.md', [ - 'no-unused-definitions-invalid.md:1:1-1:27: Found unused definition' - ]); - - assertFile('no-unused-definitions-valid.md', []); - }); - }); - - describeRule('fenced-code-marker', function () { - describeSetting(true, function () { - assertFile('fenced-code-marker-tick.md', []); - assertFile('fenced-code-marker-tilde.md', []); - - assertFile('fenced-code-marker-mismatched.md', [ - 'fenced-code-marker-mismatched.md:5:1-7:4: Fenced code should use ` as a marker' - ]); - }); - - describeSetting('@', function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid fenced code marker `@`: use either `\'consistent\'`, `` \'`\' ``, or `\'~\'`' - ]); - }); - - describeSetting('`', function () { - assertFile('fenced-code-marker-tick.md', []); - - assertFile('fenced-code-marker-tilde.md', [ - 'fenced-code-marker-tilde.md:1:1-3:4: Fenced code should use ` as a marker', - 'fenced-code-marker-tilde.md:5:1-7:4: Fenced code should use ` as a marker' - ]); - - assertFile('fenced-code-marker-mismatched.md', [ - 'fenced-code-marker-mismatched.md:5:1-7:4: Fenced code should use ` as a marker' - ]); - }); - - describeSetting('~', function () { - assertFile('fenced-code-marker-tick.md', [ - 'fenced-code-marker-tick.md:1:1-3:4: Fenced code should use ~ as a marker', - 'fenced-code-marker-tick.md:5:1-7:4: Fenced code should use ~ as a marker' - ]); - - assertFile('fenced-code-marker-tilde.md', []); - - assertFile('fenced-code-marker-mismatched.md', [ - 'fenced-code-marker-mismatched.md:1:1-3:4: Fenced code should use ~ as a marker' - ]); - }); - }); - - describeRule('checkbox-character-style', function () { - describeSetting(true, function () { - assertFile('checkbox-character-style-lower-x.md', []); - assertFile('checkbox-character-style-upper-x.md', []); - assertFile('checkbox-character-style-space.md', []); - assertFile('checkbox-character-style-tab.md', []); - }); - - describeSetting({ - 'checked': '@' - }, function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid checked checkbox marker `@`: use either `\'x\'`, or `\'X\'`' - ]); - }); - - describeSetting({ - 'unchecked': '@' - }, function () { - assertFile('empty.md', [ - 'empty.md:1:1: Invalid unchecked checkbox marker `@`: use either `\'\\t\'`, or `\' \'`' - ]); - }); - - describeSetting({ - 'checked': 'X' - }, function () { - assertFile('checkbox-character-style-lower-x.md', [ - 'checkbox-character-style-lower-x.md:1:6-1:7: Checked checkboxes should use `X` as a marker', - 'checkbox-character-style-lower-x.md:3:4-3:5: Checked checkboxes should use `X` as a marker', - 'checkbox-character-style-lower-x.md:5:5-5:6: Checked checkboxes should use `X` as a marker', - 'checkbox-character-style-lower-x.md:7:6-7:7: Checked checkboxes should use `X` as a marker' - ]); - - assertFile('checkbox-character-style-upper-x.md', []); - }); - - describeSetting({ - 'checked': 'x' - }, function () { - assertFile('checkbox-character-style-lower-x.md', []); - - assertFile('checkbox-character-style-upper-x.md', [ - 'checkbox-character-style-upper-x.md:1:6-1:7: Checked checkboxes should use `x` as a marker', - 'checkbox-character-style-upper-x.md:3:4-3:5: Checked checkboxes should use `x` as a marker', - 'checkbox-character-style-upper-x.md:5:5-5:6: Checked checkboxes should use `x` as a marker', - 'checkbox-character-style-upper-x.md:7:6-7:7: Checked checkboxes should use `x` as a marker' - ]); - }); - - describeSetting({ - 'unchecked': ' ' - }, function () { - assertFile('checkbox-character-style-space.md', []); - - assertFile('checkbox-character-style-tab.md', [ - 'checkbox-character-style-tab.md:1:6-1:7: Unchecked checkboxes should use ` ` as a marker', - 'checkbox-character-style-tab.md:3:4-3:5: Unchecked checkboxes should use ` ` as a marker', - 'checkbox-character-style-tab.md:5:5-5:6: Unchecked checkboxes should use ` ` as a marker', - 'checkbox-character-style-tab.md:7:6-7:7: Unchecked checkboxes should use ` ` as a marker' - ]); - }); - - describeSetting({ - 'unchecked': '\t' - }, function () { - assertFile('checkbox-character-style-space.md', [ - 'checkbox-character-style-space.md:1:6-1:7: Unchecked checkboxes should use `\t` as a marker', - 'checkbox-character-style-space.md:3:4-3:5: Unchecked checkboxes should use `\t` as a marker', - 'checkbox-character-style-space.md:5:5-5:6: Unchecked checkboxes should use `\t` as a marker', - 'checkbox-character-style-space.md:7:6-7:7: Unchecked checkboxes should use `\t` as a marker' - ]); - - assertFile('checkbox-character-style-tab.md', []); - }); - }); - - describeRule('checkbox-content-indent', function () { - describeSetting(true, function () { - assertFile('checkbox-content-indent-invalid.md', [ - 'checkbox-content-indent-invalid.md:1:7-1:8: Checkboxes should be followed by a single character', - 'checkbox-content-indent-invalid.md:3:7-3:9: Checkboxes should be followed by a single character', - 'checkbox-content-indent-invalid.md:5:7-5:8: Checkboxes should be followed by a single character', - 'checkbox-content-indent-invalid.md:7:9-7:11: Checkboxes should be followed by a single character', - 'checkbox-content-indent-invalid.md:9:9-9:11: Checkboxes should be followed by a single character' - ]); - - assertFile('checkbox-content-indent-valid.md', []); - }); - }); -}); - -/* - * Check that no warnings are created for generated - * nodes: nodes without positional information. - */ - -var nonnode = [ - 'no-file-name-articles', - 'no-tabs', - 'no-file-name-outer-dashes', - 'maximum-line-length', - 'final-newline', - 'no-file-name-mixed-case', - 'no-file-name-consecutive-dashes', - 'file-extension', - 'no-file-name-irregular-characters' -]; - -describe('remark-lint with generated nodes', function () { - fs.readdirSync(join(__dirname, 'fixtures')) - .filter(function (filePath) { - return filePath.charAt(0) !== '.'; - }) - .forEach(function (filePath) { - it(filePath, function () { - var messages = process(filePath, null, null, true); - - messages = messages.filter(function (message) { - return !message.ruleId || nonnode.indexOf(message.ruleId) === -1; - }); - }); - }); -}); +function preprocess(value) { + return value.replace(/»/g, '\t').replace(/·/g, ' '); +} diff --git a/test/local-external.js b/test/local-external.js new file mode 100644 index 00000000..16ea414e --- /dev/null +++ b/test/local-external.js @@ -0,0 +1,15 @@ +/** + * @author Titus Wormer + * @copyright 2016 Titus Wormer + * @license MIT + * @module remark:lint + * @fileoverview Example local externals. + */ + +'use strict'; + +/* eslint-disable max-params */ + +module.exports = { + 'trailing-slash': require('remark-lint-no-url-trailing-slash')['trailing-slash'] +};