Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markdownlint-cli

Package Overview
Dependencies
Maintainers
3
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdownlint-cli - npm Package Compare versions

Comparing version 0.26.0 to 0.27.0

42

markdownlint.js

@@ -9,2 +9,3 @@ #!/usr/bin/env node

const program = require('commander');
const options = program.opts();
const differenceWith = require('lodash.differencewith');

@@ -18,2 +19,3 @@ const flatten = require('lodash.flatten');

const pkg = require('./package');
const os = require('os');

@@ -25,3 +27,3 @@ function jsoncParse(text) {

function jsYamlSafeLoad(text) {
return require('js-yaml').safeLoad(text);
return require('js-yaml').load(text);
}

@@ -82,2 +84,3 @@

const globOptions = {
dot: Boolean(options.dot),
nodir: true

@@ -168,7 +171,10 @@ };

if (program.output) {
if (options.output) {
lintResultString = lintResultString.length > 0 ?
lintResultString + os.EOL :
lintResultString;
try {
fs.writeFileSync(program.output, lintResultString);
fs.writeFileSync(options.output, lintResultString);
} catch (error) {
console.warn('Cannot write to output file ' + program.output + ': ' + error.message);
console.warn('Cannot write to output file ' + options.output + ': ' + error.message);
process.exitCode = 2;

@@ -190,9 +196,10 @@ }

.usage('[options] <files|directories|globs>')
.option('-c, --config [configFile]', 'configuration file (JSON, JSONC, JS, or YAML)')
.option('-d, --dot', 'include files/folders with a dot (for example `.github`)')
.option('-f, --fix', 'fix basic errors (does not work with STDIN)')
.option('-s, --stdin', 'read from STDIN (does not work with files)')
.option('-i, --ignore [file|directory|glob]', 'file(s) to ignore/exclude', concatArray, [])
.option('-o, --output [outputFile]', 'write issues to file (no console)')
.option('-c, --config [configFile]', 'configuration file (JSON, JSONC, JS, or YAML)')
.option('-i, --ignore [file|directory|glob]', 'file(s) to ignore/exclude', concatArray, [])
.option('-p, --ignore-path [file]', 'path to file with ignore pattern(s)')
.option('-r, --rules [file|directory|glob|package]', 'custom rule files', concatArray, []);
.option('-r, --rules [file|directory|glob|package]', 'custom rule files', concatArray, [])
.option('-s, --stdin', 'read from STDIN (does not work with files)');

@@ -207,2 +214,3 @@ program.parse(process.argv);

let paths = Module._nodeModulePaths(processCwd);
// eslint-disable-next-line unicorn/prefer-spread
paths = paths.concat(Module.globalPaths);

@@ -245,4 +253,4 @@ if (require.resolve.paths) {

let {existsSync} = fs;
if (program.ignorePath) {
ignorePath = program.ignorePath;
if (options.ignorePath) {
ignorePath = options.ignorePath;
existsSync = () => true;

@@ -261,4 +269,4 @@ }

.filter(value => ignoreFilter(value));
const ignores = prepareFileList(program.ignore, ['md', 'markdown'], files);
const customRules = loadCustomRules(program.rules);
const ignores = prepareFileList(options.ignore, ['md', 'markdown'], files);
const customRules = loadCustomRules(options.rules);
const diff = differenceWith(files, ignores, function (a, b) {

@@ -284,3 +292,3 @@ return a.absolute === b.absolute;

if (program.fix) {
if (options.fix) {
const fixOptions = {

@@ -291,3 +299,3 @@ ...lintOptions,

const markdownlintRuleHelpers = require('markdownlint-rule-helpers');
files.forEach(file => {
for (const file of files) {
fixOptions.files = [file];

@@ -303,3 +311,3 @@ const fixResult = markdownlint.sync(fixOptions);

}
});
}
}

@@ -311,5 +319,5 @@

if ((files.length > 0) && !program.stdin) {
if ((files.length > 0) && !options.stdin) {
lintAndPrint(null, diff);
} else if ((files.length === 0) && program.stdin && !program.fix) {
} else if ((files.length === 0) && options.stdin && !options.fix) {
const getStdin = require('get-stdin');

@@ -316,0 +324,0 @@ getStdin().then(lintAndPrint);

{
"name": "markdownlint-cli",
"version": "0.26.0",
"version": "0.27.0",
"description": "MarkdownLint Command Line Interface",

@@ -40,3 +40,3 @@ "main": "markdownlint.js",

"dependencies": {
"commander": "~6.2.1",
"commander": "~7.1.0",
"deep-extend": "~0.6.0",

@@ -46,8 +46,8 @@ "get-stdin": "~8.0.0",

"ignore": "~5.1.8",
"js-yaml": "~3.14.1",
"js-yaml": "^4.0.0",
"jsonc-parser": "~3.0.0",
"lodash.differencewith": "~4.5.0",
"lodash.flatten": "~4.4.0",
"markdownlint": "~0.22.0",
"markdownlint-rule-helpers": "~0.13.0",
"markdownlint": "~0.23.1",
"markdownlint-rule-helpers": "~0.14.0",
"minimatch": "~3.0.4",

@@ -58,8 +58,8 @@ "minimist": "~1.2.5",

"devDependencies": {
"ava": "^3.14.0",
"ava": "^3.15.0",
"execa": "^5.0.0",
"husky": "^4.3.6",
"husky": "^5.1.2",
"tap-growl": "^3.0.0",
"test-rule-package": "./test/custom-rules/test-rule-package",
"xo": "^0.36.1"
"xo": "^0.38.2"
},

@@ -66,0 +66,0 @@ "xo": {

@@ -32,9 +32,10 @@ # markdownlint-cli

-V, --version output the version number
-c, --config [configFile] configuration file (JSON, JSONC, JS, or YAML)
-d, --dot include files/folders with a dot (for example `.github`)
-f, --fix fix basic errors (does not work with STDIN)
-s, --stdin read from STDIN (does not work with files)
-i, --ignore [file|directory|glob] file(s) to ignore/exclude
-o, --output [outputFile] write issues to file (no console)
-c, --config [configFile] configuration file (JSON, JSONC, JS, or YAML)
-i, --ignore [file|directory|glob] file(s) to ignore/exclude
-p, --ignore-path [file] path to file with ignore pattern(s)
-r, --rules [file|directory|glob|package] custom rule files
-s, --stdin read from STDIN (does not work with files)
```

@@ -81,3 +82,3 @@

The example of configuration file:
A sample configuration file:

@@ -94,3 +95,3 @@ ```json

See [test configuration file][test-config] or [style folder][style-folder] for more examples.
For more examples, see [.markdownlint.jsonc][markdownlint-jsonc], [.markdownlint.yaml][markdownlint-yaml], or the [style folder][style-folder].

@@ -115,2 +116,13 @@ The CLI argument `--config` is not required.

## Use with pre-commit
To run `markdownlint-cli` as part of a [pre-commit](https://pre-commit.com/) workflow, add something like the below to the `repos` list in the project's `.pre-commit-config.yaml`:
```yaml
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.27.0
hooks:
- id: markdownlint
```
## Related

@@ -128,8 +140,8 @@

[actions-url]: https://github.com/igorshubovych/markdownlint-cli/actions?query=workflow%3ACI
[markdownlint]: https://github.com/DavidAnson/markdownlint
[markdownlint-jsonc]: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.jsonc
[markdownlint-yaml]: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
[rules]: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
[config]: https://github.com/DavidAnson/markdownlint#optionsconfig
[style-folder]: https://github.com/DavidAnson/markdownlint/tree/main/style
[test-config]: https://github.com/igorshubovych/markdownlint-cli/blob/master/test/test-config.json
[rc-standards]: https://www.npmjs.com/package/rc#standards

@@ -136,0 +148,0 @@ [glob]: https://github.com/isaacs/node-glob

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc