markdownlint-cli 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/markdownlint.js +21 -15
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Options:
|
|
|
33
33
|
-c, --config <configFile> configuration file (JSON, JSONC, JS, YAML, or TOML)
|
|
34
34
|
--configPointer <pointer> JSON Pointer to object within configuration file (default: "")
|
|
35
35
|
-d, --dot include files/folders with a dot (for example `.github`)
|
|
36
|
-
-f, --fix fix basic
|
|
36
|
+
-f, --fix fix basic issues (does not work with STDIN)
|
|
37
37
|
-i, --ignore <file|directory|glob> file(s) to ignore/exclude (default: [])
|
|
38
38
|
-j, --json write issues in json format
|
|
39
39
|
-o, --output <outputFile> write issues to file (no console)
|
|
@@ -81,12 +81,12 @@ The order of operations is:
|
|
|
81
81
|
- Apply exclusions from `-p`/`--ignore-path` (if specified) or `.markdownlintignore` (if present)
|
|
82
82
|
- Apply exclusions from any `-i`/`--ignore` option(s) that are specified
|
|
83
83
|
|
|
84
|
-
### Fixing
|
|
84
|
+
### Fixing issues
|
|
85
85
|
|
|
86
|
-
When the `--fix` option is specified, `markdownlint-cli` tries to apply all fixes reported by the active rules and reports any
|
|
86
|
+
When the `--fix` option is specified, `markdownlint-cli` tries to apply all fixes reported by the active rules and reports any issues that remain.
|
|
87
87
|
Because this option makes changes to the input files, it is good to make a backup first or work with files under source control so any unwanted changes can be undone.
|
|
88
88
|
|
|
89
|
-
> Because not all rules include fix information when reporting
|
|
89
|
+
> Because not all rules include fix information when reporting issues, fixes may overlap, and not all issues are fixable, `--fix` will not usually address all issues.
|
|
90
90
|
|
|
91
91
|
## Configuration
|
|
92
92
|
|
|
@@ -130,11 +130,11 @@ If a rule is passed to both `--enable` and `--disable`, it will be disabled.
|
|
|
130
130
|
|
|
131
131
|
`markdownlint-cli` returns one of the following exit codes:
|
|
132
132
|
|
|
133
|
-
- `0`:
|
|
134
|
-
- `1`: Linting errors
|
|
133
|
+
- `0`: Linting successful, no errors (warnings possible)
|
|
134
|
+
- `1`: Linting successful, some errors (warnings possible)
|
|
135
135
|
- `2`: Unable to write `-o`/`--output` output file
|
|
136
136
|
- `3`: Unable to load `-r`/`--rules` custom rule
|
|
137
|
-
- `4`: Unexpected
|
|
137
|
+
- `4`: Unexpected problem (e.g. malformed config)
|
|
138
138
|
|
|
139
139
|
## Use with pre-commit
|
|
140
140
|
|
|
@@ -142,7 +142,7 @@ To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add so
|
|
|
142
142
|
|
|
143
143
|
```yaml
|
|
144
144
|
- repo: https://github.com/igorshubovych/markdownlint-cli
|
|
145
|
-
rev: v0.
|
|
145
|
+
rev: v0.47.0
|
|
146
146
|
hooks:
|
|
147
147
|
- id: markdownlint
|
|
148
148
|
```
|
|
@@ -160,8 +160,8 @@ To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add so
|
|
|
160
160
|
|
|
161
161
|
MIT © Igor Shubovych
|
|
162
162
|
|
|
163
|
-
[actions-badge]: https://github.com/igorshubovych/markdownlint-cli/workflows/
|
|
164
|
-
[actions-url]: https://github.com/igorshubovych/markdownlint-cli/actions
|
|
163
|
+
[actions-badge]: https://github.com/igorshubovych/markdownlint-cli/actions/workflows/ci.yml/badge.svg
|
|
164
|
+
[actions-url]: https://github.com/igorshubovych/markdownlint-cli/actions/workflows/ci.yml
|
|
165
165
|
[commander-variadic]: https://github.com/tj/commander.js#variadic-option
|
|
166
166
|
[json-pointer]: https://datatracker.ietf.org/doc/html/rfc6901
|
|
167
167
|
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
package/markdownlint.js
CHANGED
|
@@ -6,7 +6,7 @@ import Module from 'node:module';
|
|
|
6
6
|
import os from 'node:os';
|
|
7
7
|
import process from 'node:process';
|
|
8
8
|
import {program} from 'commander';
|
|
9
|
-
import {
|
|
9
|
+
import {globSync} from 'tinyglobby';
|
|
10
10
|
import {applyFixes} from 'markdownlint';
|
|
11
11
|
import {lint, readConfig} from 'markdownlint/sync';
|
|
12
12
|
import rc from 'run-con';
|
|
@@ -16,7 +16,7 @@ import jsonpointer from 'jsonpointer';
|
|
|
16
16
|
const require = Module.createRequire(import.meta.url);
|
|
17
17
|
const options = program.opts();
|
|
18
18
|
// The following two values are copied from package.json (and validated by tests)
|
|
19
|
-
const version = '0.
|
|
19
|
+
const version = '0.47.0';
|
|
20
20
|
const description = 'MarkdownLint Command Line Interface';
|
|
21
21
|
|
|
22
22
|
function markdownItFactory() {
|
|
@@ -48,7 +48,7 @@ function tomlParse(text) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const exitCodes = {
|
|
51
|
-
|
|
51
|
+
lintErrorsPresent: 1,
|
|
52
52
|
failedToWriteOutputFile: 2,
|
|
53
53
|
failedToLoadCustomRules: 3,
|
|
54
54
|
unexpectedError: 4
|
|
@@ -93,7 +93,9 @@ function readConfiguration(userConfigFile) {
|
|
|
93
93
|
function prepareFileList(files, fileExtensions, previousResults) {
|
|
94
94
|
const globOptions = {
|
|
95
95
|
dot: Boolean(options.dot),
|
|
96
|
-
|
|
96
|
+
onlyFiles: true,
|
|
97
|
+
expandDirectories: false,
|
|
98
|
+
caseSensitiveMatch: !(os.platform() === 'win32' || os.platform() === 'darwin')
|
|
97
99
|
};
|
|
98
100
|
let extensionGlobPart = '*.';
|
|
99
101
|
if (!fileExtensions) {
|
|
@@ -115,7 +117,7 @@ function prepareFileList(files, fileExtensions, previousResults) {
|
|
|
115
117
|
return previousResults.filter(fileInfo => matcher.match(fileInfo.absolute)).map(fileInfo => fileInfo.original);
|
|
116
118
|
}
|
|
117
119
|
|
|
118
|
-
return
|
|
120
|
+
return globSync(posixPath(path.join(file, '**', extensionGlobPart)), globOptions);
|
|
119
121
|
}
|
|
120
122
|
} catch {
|
|
121
123
|
// Not a directory, not a file, may be a glob
|
|
@@ -124,7 +126,7 @@ function prepareFileList(files, fileExtensions, previousResults) {
|
|
|
124
126
|
return previousResults.filter(fileInfo => matcher.match(fileInfo.absolute)).map(fileInfo => fileInfo.original);
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
return
|
|
129
|
+
return globSync(file, globOptions);
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
// File
|
|
@@ -152,7 +154,8 @@ function printResult(lintResult) {
|
|
|
152
154
|
lineNumber: result.lineNumber,
|
|
153
155
|
column: (result.errorRange && result.errorRange[0]) || 0,
|
|
154
156
|
names: result.ruleNames.join('/'),
|
|
155
|
-
description: result.ruleDescription + (result.errorDetail ? ' [' + result.errorDetail + ']' : '') + (result.errorContext ? ' [Context: "' + result.errorContext + '"]' : '')
|
|
157
|
+
description: result.ruleDescription + (result.errorDetail ? ' [' + result.errorDetail + ']' : '') + (result.errorContext ? ' [Context: "' + result.errorContext + '"]' : ''),
|
|
158
|
+
severity: result.severity
|
|
156
159
|
};
|
|
157
160
|
})
|
|
158
161
|
);
|
|
@@ -167,19 +170,22 @@ function printResult(lintResult) {
|
|
|
167
170
|
|
|
168
171
|
lintResultString = results
|
|
169
172
|
.map(result => {
|
|
170
|
-
const {file, lineNumber, column, names, description} = result;
|
|
173
|
+
const {file, lineNumber, column, names, description, severity} = result;
|
|
171
174
|
const columnText = column ? `:${column}` : '';
|
|
172
|
-
return `${file}:${lineNumber}${columnText} ${names} ${description}`;
|
|
175
|
+
return `${file}:${lineNumber}${columnText} ${severity} ${names} ${description}`;
|
|
173
176
|
})
|
|
174
177
|
.join('\n');
|
|
175
178
|
}
|
|
176
179
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
const errorsPresent = results.some(result => result.severity === 'error');
|
|
181
|
+
if (errorsPresent) {
|
|
182
|
+
// Note: process.exit(1) will end abruptly, interrupting asynchronous IO
|
|
183
|
+
// streams (e.g., when the output is being piped). Just set the exit code
|
|
184
|
+
// and let the program terminate normally.
|
|
185
|
+
// @see {@link https://nodejs.org/dist/latest-v8.x/docs/api/process.html#process_process_exit_code}
|
|
186
|
+
// @see {@link https://github.com/igorshubovych/markdownlint-cli/pull/29#issuecomment-343535291}
|
|
187
|
+
process.exitCode = exitCodes.lintErrorsPresent;
|
|
188
|
+
}
|
|
183
189
|
}
|
|
184
190
|
|
|
185
191
|
if (options.output) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "MarkdownLint Command Line Interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "markdownlint.js",
|
|
@@ -38,23 +38,24 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/igorshubovych/markdownlint-cli#readme",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"commander": "~
|
|
42
|
-
"
|
|
43
|
-
"ignore": "~7.0.
|
|
44
|
-
"js-yaml": "~4.1.
|
|
41
|
+
"commander": "~14.0.2",
|
|
42
|
+
"deep-extend": "~0.6.0",
|
|
43
|
+
"ignore": "~7.0.5",
|
|
44
|
+
"js-yaml": "~4.1.1",
|
|
45
45
|
"jsonc-parser": "~3.3.1",
|
|
46
46
|
"jsonpointer": "~5.0.1",
|
|
47
|
-
"markdownlint": "~0.
|
|
47
|
+
"markdownlint": "~0.40.0",
|
|
48
48
|
"markdown-it": "~14.1.0",
|
|
49
|
-
"minimatch": "~10.
|
|
49
|
+
"minimatch": "~10.1.1",
|
|
50
50
|
"run-con": "~1.3.2",
|
|
51
|
-
"smol-toml": "~1.
|
|
51
|
+
"smol-toml": "~1.5.2",
|
|
52
|
+
"tinyglobby": "~0.2.15"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"ava": "^6.
|
|
55
|
+
"ava": "^6.4.1",
|
|
55
56
|
"markdownlint-cli-local-test-rule": "./test/custom-rules/markdownlint-cli-local-test-rule",
|
|
56
|
-
"nano-spawn": "^
|
|
57
|
-
"xo": "^
|
|
57
|
+
"nano-spawn": "^2.0.0",
|
|
58
|
+
"xo": "^1.2.3"
|
|
58
59
|
},
|
|
59
60
|
"xo": {
|
|
60
61
|
"prettier": true,
|