mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
This commit is contained in:
parent
6302b26c99
commit
47ff95e8d2
19 changed files with 157 additions and 4 deletions
|
@ -2143,6 +2143,10 @@ module.exports = {
|
|||
"function": function MD010(params, onError) {
|
||||
var codeBlocks = params.config.code_blocks;
|
||||
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||
var spacesPerTab = params.config.spaces_per_tab;
|
||||
var spaceMultiplier = (spacesPerTab === undefined) ?
|
||||
1 :
|
||||
Math.max(0, Number(spacesPerTab));
|
||||
forEachLine(lineMetadata(), function (line, lineIndex, inCode) {
|
||||
if (!inCode || includeCodeBlocks) {
|
||||
var match = null;
|
||||
|
@ -2152,7 +2156,7 @@ module.exports = {
|
|||
addError(onError, lineIndex + 1, "Column: " + column, null, [column, length_1], {
|
||||
"editColumn": column,
|
||||
"deleteCount": length_1,
|
||||
"insertText": "".padEnd(length_1)
|
||||
"insertText": "".padEnd(length_1 * spaceMultiplier)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -388,7 +388,7 @@ Tags: whitespace, hard_tab
|
|||
|
||||
Aliases: no-hard-tabs
|
||||
|
||||
Parameters: code_blocks (boolean; default true)
|
||||
Parameters: code_blocks, spaces_per_tab (boolean; default true, number; default 1)
|
||||
|
||||
Fixable: Most violations can be fixed by tooling
|
||||
|
||||
|
@ -420,6 +420,9 @@ You have the option to exclude this rule for code blocks. To do so, set the
|
|||
`code_blocks` parameter to `false`. Code blocks are included by default since
|
||||
handling of tabs by tools is often inconsistent (ex: using 4 vs. 8 spaces).
|
||||
|
||||
If you would like the fixer to change tabs to x spaces, then configure the `spaces_per_tab`
|
||||
parameter to the number x. The default value would be 1.
|
||||
|
||||
Rationale: Hard tabs are often rendered inconsistently by different editors and
|
||||
can be harder to work with than spaces.
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@ module.exports = {
|
|||
"function": function MD010(params, onError) {
|
||||
const codeBlocks = params.config.code_blocks;
|
||||
const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||
const spacesPerTab = params.config.spaces_per_tab;
|
||||
const spaceMultiplier = (spacesPerTab === undefined) ?
|
||||
1 :
|
||||
Math.max(0, Number(spacesPerTab));
|
||||
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
||||
if (!inCode || includeCodeBlocks) {
|
||||
let match = null;
|
||||
|
@ -29,7 +33,7 @@ module.exports = {
|
|||
{
|
||||
"editColumn": column,
|
||||
"deleteCount": length,
|
||||
"insertText": "".padEnd(length)
|
||||
"insertText": "".padEnd(length * spaceMultiplier)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,9 @@
|
|||
// MD010/no-hard-tabs - Hard tabs
|
||||
"MD010": {
|
||||
// Include code blocks
|
||||
"code_blocks": true
|
||||
"code_blocks": true,
|
||||
// Number of spaces for each hard tab
|
||||
"spaces_per_tab": 1
|
||||
},
|
||||
|
||||
// MD011/no-reversed-links - Reversed link syntax
|
||||
|
|
|
@ -50,6 +50,8 @@ MD009:
|
|||
MD010:
|
||||
# Include code blocks
|
||||
code_blocks: true
|
||||
# Number of spaces for each hard tab
|
||||
spaces_per_tab: 1
|
||||
|
||||
# MD011/no-reversed-links - Reversed link syntax
|
||||
MD011: true
|
||||
|
|
|
@ -135,6 +135,11 @@ rules.forEach(function forRule(rule) {
|
|||
"description": "Include code blocks",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"spaces_per_tab": {
|
||||
"description": "Number of spaces for each hard tab",
|
||||
"type": "number",
|
||||
"default": 1
|
||||
}
|
||||
};
|
||||
break;
|
||||
|
|
|
@ -327,6 +327,11 @@
|
|||
"description": "Include code blocks",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"spaces_per_tab": {
|
||||
"description": "Number of spaces for each hard tab",
|
||||
"type": "number",
|
||||
"default": 1
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
@ -343,6 +348,11 @@
|
|||
"description": "Include code blocks",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"spaces_per_tab": {
|
||||
"description": "Number of spaces for each hard tab",
|
||||
"type": "number",
|
||||
"default": 1
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
|
7
test/detailed-results-4-tabs-MD010.json
Normal file
7
test/detailed-results-4-tabs-MD010.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"MD009": false,
|
||||
"MD010": {
|
||||
"spaces_per_tab": 4
|
||||
},
|
||||
"MD041": false
|
||||
}
|
3
test/detailed-results-4-tabs-MD010.md
Normal file
3
test/detailed-results-4-tabs-MD010.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
text
|
||||
text and text 2
|
||||
texts with trailing spaces
|
3
test/detailed-results-4-tabs-MD010.md.fixed
Normal file
3
test/detailed-results-4-tabs-MD010.md.fixed
Normal file
|
@ -0,0 +1,3 @@
|
|||
text
|
||||
text and text 2
|
||||
texts with trailing spaces
|
29
test/detailed-results-4-tabs-MD010.results.json
Normal file
29
test/detailed-results-4-tabs-MD010.results.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
[
|
||||
{
|
||||
"errorContext": null,
|
||||
"errorDetail": "Column: 1",
|
||||
"errorRange": [1, 13],
|
||||
"lineNumber": 1,
|
||||
"ruleDescription": "Hard tabs",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"ruleNames": ["MD010", "no-hard-tabs"]
|
||||
},
|
||||
{
|
||||
"errorContext": null,
|
||||
"errorDetail": "Column: 5",
|
||||
"errorRange": [5, 2],
|
||||
"lineNumber": 2,
|
||||
"ruleDescription": "Hard tabs",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"ruleNames": ["MD010", "no-hard-tabs"]
|
||||
},
|
||||
{
|
||||
"errorContext": null,
|
||||
"errorDetail": "Column: 27",
|
||||
"errorRange": [27, 3],
|
||||
"lineNumber": 3,
|
||||
"ruleDescription": "Hard tabs",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"ruleNames": ["MD010", "no-hard-tabs"]
|
||||
}
|
||||
]
|
4
test/detailed-results-default-spaces-MD010.json
Normal file
4
test/detailed-results-default-spaces-MD010.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"MD009": false,
|
||||
"MD041": false
|
||||
}
|
3
test/detailed-results-default-spaces-MD010.md
Normal file
3
test/detailed-results-default-spaces-MD010.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
text
|
||||
text and text 2
|
||||
texts with trailing spaces
|
3
test/detailed-results-default-spaces-MD010.md.fixed
Normal file
3
test/detailed-results-default-spaces-MD010.md.fixed
Normal file
|
@ -0,0 +1,3 @@
|
|||
text
|
||||
text and text 2
|
||||
texts with trailing spaces
|
29
test/detailed-results-default-spaces-MD010.results.json
Normal file
29
test/detailed-results-default-spaces-MD010.results.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
[
|
||||
{
|
||||
"errorContext": null,
|
||||
"errorDetail": "Column: 1",
|
||||
"errorRange": [1, 13],
|
||||
"lineNumber": 1,
|
||||
"ruleDescription": "Hard tabs",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"ruleNames": ["MD010", "no-hard-tabs"]
|
||||
},
|
||||
{
|
||||
"errorContext": null,
|
||||
"errorDetail": "Column: 5",
|
||||
"errorRange": [5, 2],
|
||||
"lineNumber": 2,
|
||||
"ruleDescription": "Hard tabs",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"ruleNames": ["MD010", "no-hard-tabs"]
|
||||
},
|
||||
{
|
||||
"errorContext": null,
|
||||
"errorDetail": "Column: 27",
|
||||
"errorRange": [27, 3],
|
||||
"lineNumber": 3,
|
||||
"ruleDescription": "Hard tabs",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"ruleNames": ["MD010", "no-hard-tabs"]
|
||||
}
|
||||
]
|
7
test/detailed-results-no-tabs-edge-case-MD010.json
Normal file
7
test/detailed-results-no-tabs-edge-case-MD010.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"MD009": false,
|
||||
"MD010": {
|
||||
"spaces_per_tab": 0
|
||||
},
|
||||
"MD041": false
|
||||
}
|
3
test/detailed-results-no-tabs-edge-case-MD010.md
Normal file
3
test/detailed-results-no-tabs-edge-case-MD010.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
text
|
||||
text and text 2
|
||||
texts with trailing spaces
|
3
test/detailed-results-no-tabs-edge-case-MD010.md.fixed
Normal file
3
test/detailed-results-no-tabs-edge-case-MD010.md.fixed
Normal file
|
@ -0,0 +1,3 @@
|
|||
text
|
||||
text and text 2
|
||||
texts with trailing spaces
|
29
test/detailed-results-no-tabs-edge-case-MD010.results.json
Normal file
29
test/detailed-results-no-tabs-edge-case-MD010.results.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
[
|
||||
{
|
||||
"errorContext": null,
|
||||
"errorDetail": "Column: 1",
|
||||
"errorRange": [1, 13],
|
||||
"lineNumber": 1,
|
||||
"ruleDescription": "Hard tabs",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"ruleNames": ["MD010", "no-hard-tabs"]
|
||||
},
|
||||
{
|
||||
"errorContext": null,
|
||||
"errorDetail": "Column: 5",
|
||||
"errorRange": [5, 2],
|
||||
"lineNumber": 2,
|
||||
"ruleDescription": "Hard tabs",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"ruleNames": ["MD010", "no-hard-tabs"]
|
||||
},
|
||||
{
|
||||
"errorContext": null,
|
||||
"errorDetail": "Column: 27",
|
||||
"errorRange": [27, 3],
|
||||
"lineNumber": 3,
|
||||
"ruleDescription": "Hard tabs",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"ruleNames": ["MD010", "no-hard-tabs"]
|
||||
}
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue