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

markdownlint-cli2

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdownlint-cli2 - npm Package Compare versions

Comparing version 0.8.1 to 0.9.0

npm-shrinkwrap.json

155

markdownlint-cli2.js

@@ -13,3 +13,4 @@ #!/usr/bin/env node

// Requires
const path = require("node:path");
const pathDefault = require("node:path");
const pathPosix = pathDefault.posix;
const { pathToFileURL } = require("node:url");

@@ -29,3 +30,3 @@ const markdownlintLibrary = require("markdownlint");

const packageName = "markdownlint-cli2";
const packageVersion = "0.8.1";
const packageVersion = "0.9.0";
const libraryName = "markdownlint";

@@ -54,7 +55,7 @@ const libraryVersion = markdownlintLibrary.getVersion();

// Return a posix path (even on Windows)
const posixPath = (p) => p.split(path.sep).join(path.posix.sep);
const posixPath = (p) => p.split(pathDefault.sep).join(pathPosix.sep);
// Read a JSON(C) or YAML file and return the object
const readConfig = (fs, dir, name, otherwise) => {
const file = path.posix.join(dir, name);
const file = pathPosix.join(dir, name);
return () => fs.promises.access(file).

@@ -86,3 +87,3 @@ then(

const fileUrlString =
pathToFileURL(path.resolve(dir, expandId)).toString();
pathToFileURL(pathDefault.resolve(dir, expandId)).toString();
// eslint-disable-next-line no-inline-comments

@@ -121,18 +122,30 @@ const module = await import(/* webpackIgnore: true */ fileUrlString);

// Import or require a JavaScript file and return the exported object
const importOrRequireConfig = (fs, dir, name, noRequire, otherwise) => (
() => (noRequire
// eslint-disable-next-line prefer-promise-reject-errors
? Promise.reject()
: fs.promises.access(path.posix.join(dir, name))
).
const importOrRequireConfig = (fs, dir, name, noRequire, otherwise) => {
const id = pathPosix.join(dir, name);
return () => fs.promises.access(id).
then(
() => importOrRequireResolve(dir, `./${name}`),
() => (noRequire ? {} : importOrRequireResolve(dir, id)),
otherwise
)
);
);
};
// Extend a config object if it has 'extends' property
const getExtendedConfig = async (config, configPath, fs) => {
if (config.extends) {
const jsoncParse = await getJsoncParse();
return markdownlintExtendConfig(
config,
configPath,
[ jsoncParse, yamlParse ],
fs
);
}
return config;
};
// Read an options or config file in any format and return the object
const readOptionsOrConfig = async (configPath, fs, noRequire) => {
const basename = path.basename(configPath);
const dirname = path.dirname(configPath);
const basename = pathPosix.basename(configPath);
const dirname = pathPosix.dirname(configPath);
let options = null;

@@ -175,3 +188,12 @@ let config = null;

}
return options || { config };
if (options) {
if (options.config) {
options.config = await getExtendedConfig(options.config, configPath, fs);
}
return options;
}
config = await getExtendedConfig(config, configPath, fs);
return { config };
};

@@ -183,5 +205,5 @@

return micromatch(
files.map((file) => path.posix.relative(dir, file)),
files.map((file) => pathPosix.relative(dir, file)),
ignores
).map((file) => path.posix.join(dir, file));
).map((file) => pathPosix.join(dir, file));
};

@@ -244,2 +266,3 @@

- .markdownlint.cjs or .markdownlint.mjs
- package.json

@@ -261,3 +284,3 @@ Cross-platform compatibility:

const getAndProcessDirInfo =
(fs, tasks, dirToDirInfo, dir, relativeDir, noRequire, func) => {
(fs, tasks, dirToDirInfo, dir, relativeDir, noRequire, allowPackageJson) => {
let dirInfo = dirToDirInfo[dir];

@@ -277,5 +300,6 @@ if (!dirInfo) {

const markdownlintCli2Jsonc =
path.posix.join(dir, ".markdownlint-cli2.jsonc");
pathPosix.join(dir, ".markdownlint-cli2.jsonc");
const markdownlintCli2Yaml =
path.posix.join(dir, ".markdownlint-cli2.yaml");
pathPosix.join(dir, ".markdownlint-cli2.yaml");
const packageJson = pathPosix.join(dir, "package.json");
tasks.push(

@@ -305,3 +329,17 @@ fs.promises.access(markdownlintCli2Jsonc).

noRequire,
noop
() => (allowPackageJson
? fs.promises.access(packageJson)
// eslint-disable-next-line prefer-promise-reject-errors
: Promise.reject()
).
then(
() => fs.promises.
readFile(packageJson, utf8).
then(
(content) => getJsoncParse().
then((jsoncParse) => jsoncParse(content)).
then((obj) => obj[packageName])
),
noop
)
)

@@ -315,13 +353,8 @@ )

options.config &&
options.config.extends &&
getJsoncParse().
then(
(jsoncParse) => markdownlintExtendConfig(
options.config,
// Just needs to identify a file in the right directory
markdownlintCli2Jsonc,
[ jsoncParse, yamlParse ],
fs
)
).
getExtendedConfig(
options.config,
// Just needs to identify a file in the right directory
markdownlintCli2Jsonc,
fs
).
then((config) => {

@@ -375,5 +408,2 @@ options.config = config;

}
if (func) {
func(dirInfo);
}
return dirInfo;

@@ -401,3 +431,4 @@ };

relativeDir,
noRequire
noRequire,
true
);

@@ -454,3 +485,3 @@ await Promise.all(tasks);

literalFiles.push(
posixPath(path.resolve(baseDirSystem, globPattern.slice(1)))
posixPath(pathDefault.resolve(baseDirSystem, globPattern.slice(1)))
);

@@ -477,9 +508,11 @@ return false;

: globPattern;
const globPath =
(path.posix.isAbsolute(barePattern) || path.isAbsolute(barePattern))
? barePattern
: path.posix.join(baseDir, barePattern);
const globPath = (
pathPosix.isAbsolute(barePattern) ||
pathDefault.isAbsolute(barePattern)
)
? barePattern
: pathPosix.join(baseDir, barePattern);
return fs.promises.stat(globPath).
then((stats) => (stats.isDirectory()
? path.posix.join(globPattern, "**")
? pathPosix.join(globPattern, "**")
: globPattern)).

@@ -497,4 +530,4 @@ catch(() => globPattern);

for (const file of files) {
const dir = path.posix.dirname(file);
getAndProcessDirInfo(
const dir = pathPosix.dirname(file);
const dirInfo = getAndProcessDirInfo(
fs,

@@ -506,6 +539,5 @@ tasks,

noRequire,
(dirInfo) => {
dirInfo.files.push(file);
}
false
);
dirInfo.files.push(file);
}

@@ -524,3 +556,3 @@ await Promise.all(tasks);

baseDirParents[baseDirParent] = true;
baseDirParent = path.posix.dirname(baseDirParent);
baseDirParent = pathPosix.dirname(baseDirParent);
} while (!baseDirParents[baseDirParent]);

@@ -534,7 +566,7 @@

!baseDirParents[dir] &&
(dir = path.posix.dirname(dir)) &&
(dir = pathPosix.dirname(dir)) &&
(dir !== lastDir)
) {
lastDir = dir;
lastDirInfo =
const dirInfo =
getAndProcessDirInfo(

@@ -547,7 +579,6 @@ fs,

noRequire,
// eslint-disable-next-line no-loop-func
(dirInfo) => {
lastDirInfo.parent = dirInfo;
}
false
);
lastDirInfo.parent = dirInfo;
lastDirInfo = dirInfo;
}

@@ -785,3 +816,3 @@

for (const errorInfo of errorInfos) {
const fileNameRelative = path.posix.relative(baseDir, fileName);
const fileNameRelative = pathPosix.relative(baseDir, fileName);
summary.push({

@@ -856,3 +887,3 @@ "fileName": fileNameRelative,

const baseDirSystem =
(directory && path.resolve(directory)) ||
(directory && pathDefault.resolve(directory)) ||
process.cwd();

@@ -886,5 +917,7 @@ const baseDir = posixPath(baseDirSystem);

if (configPath) {
const resolvedConfigPath =
posixPath(pathDefault.resolve(baseDirSystem, configPath));
optionsArgv =
await readOptionsOrConfig(configPath, fs, noRequire);
relativeDir = path.dirname(configPath);
await readOptionsOrConfig(resolvedConfigPath, fs, noRequire);
relativeDir = pathPosix.dirname(resolvedConfigPath);
}

@@ -914,3 +947,3 @@ // Process arguments and get base options

for (const file in fileContents) {
const resolvedFile = posixPath(path.resolve(baseDirSystem, file));
const resolvedFile = posixPath(pathDefault.resolve(baseDirSystem, file));
resolvedFileContents[resolvedFile] =

@@ -917,0 +950,0 @@ fileContents[file];

{
"name": "markdownlint-cli2",
"version": "0.8.1",
"version": "0.9.0",
"description": "A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the `markdownlint` library",

@@ -34,3 +34,3 @@ "author": {

"docker-npm-run-upgrade": "docker run --rm --tty --name npm-run-upgrade --volume $PWD:/home/workdir --workdir /home/workdir --user node node:latest npm run upgrade",
"lint": "eslint --max-warnings 0 .",
"lint": "eslint --max-warnings 0 --no-eslintrc --config .eslintrc.json .",
"lint-dockerfile": "docker run --rm -i hadolint/hadolint:latest-alpine < docker/Dockerfile",

@@ -44,3 +44,3 @@ "lint-watch": "git ls-files | entr npm run lint",

"test-docker-hub-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2-rules:v$VERSION davidanson/markdownlint-cli2-rules:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:latest \"*.md\"",
"test-cover": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 npm test",
"test-cover": "c8 --100 npm test -- --concurrency=1",
"test-watch": "git ls-files | entr npm run test",

@@ -63,10 +63,11 @@ "update-snapshots": "ava --timeout=1m --update-snapshots test/markdownlint-cli2-test-exec.js test/markdownlint-cli2-test-fs.js test/markdownlint-cli2-test-main.js",

"merge-options.js",
"npm-shrinkwrap.json",
"resolve-and-require.js"
],
"dependencies": {
"globby": "13.1.4",
"markdownlint": "0.29.0",
"globby": "13.2.2",
"markdownlint": "0.30.0",
"markdownlint-cli2-formatter-default": "0.0.4",
"micromatch": "4.0.5",
"strip-json-comments": "5.0.0",
"strip-json-comments": "5.0.1",
"yaml": "2.3.1"

@@ -76,10 +77,10 @@ },

"@iktakahiro/markdown-it-katex": "4.0.1",
"ava": "5.3.0",
"c8": "7.14.0",
"ava": "5.3.1",
"c8": "8.0.1",
"cpy": "10.1.0",
"del": "7.0.0",
"eslint": "8.42.0",
"eslint-plugin-n": "16.0.0",
"eslint-plugin-unicorn": "47.0.0",
"execa": "7.1.1",
"eslint": "8.47.0",
"eslint-plugin-n": "16.0.1",
"eslint-plugin-unicorn": "48.0.1",
"execa": "8.0.1",
"markdown-it-emoji": "2.0.2",

@@ -91,2 +92,3 @@ "markdown-it-for-inline": "0.1.1",

"markdownlint-cli2-formatter-pretty": "0.0.4",
"markdownlint-cli2-formatter-sarif": "0.0.1",
"markdownlint-cli2-formatter-summarize": "0.0.6",

@@ -93,0 +95,0 @@ "markdownlint-rule-titlecase": "0.1.0",

@@ -96,2 +96,3 @@ # markdownlint-cli2

- .markdownlint.cjs or .markdownlint.mjs
- package.json

@@ -142,3 +143,3 @@ Cross-platform compatibility:

of a project, the `--config` argument can be used to provide a path to any
supported configuration file:
supported configuration file (except `package.json`):

@@ -171,3 +172,3 @@ ```bash

```bash
docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.8.1 "**/*.md" "#node_modules"
docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.9.0 "**/*.md" "#node_modules"
```

@@ -189,3 +190,3 @@

```bash
docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.8.1 "**/*.md" "#node_modules"
docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.9.0 "**/*.md" "#node_modules"
```

@@ -199,3 +200,3 @@

> ```bash
> docker run -v $PWD:/workdir --entrypoint="markdownlint-cli2-fix" davidanson/markdownlint-cli2:v0.8.1 "**/*.md" "#node_modules"
> docker run -v $PWD:/workdir --entrypoint="markdownlint-cli2-fix" davidanson/markdownlint-cli2:v0.9.0 "**/*.md" "#node_modules"
> ```

@@ -241,5 +242,20 @@

`markdownlint-cli2` behavior and are also used by `vscode-markdownlint`.
- If multiple of these files are present in the same directory, only one is
used according to the following precedence:
1. `.markdownlint-cli2.jsonc`
2. `.markdownlint-cli2.yaml`
3. `.markdownlint-cli2.cjs`
4. `.markdownlint-cli2.mjs`
5. `package.json` (only supported in the current directory)
- Configuration files like `.markdownlint.*` allow control over only the
`markdownlint` `config` object and tend to be supported more broadly (such
as by `markdownlint-cli`).
- If multiple of these files are present in the same directory, only one is
used according to the following precedence:
1. `.markdownlint.jsonc`
2. `.markdownlint.json`
3. `.markdownlint.yaml`
4. `.markdownlint.yml`
5. `.markdownlint.cjs`
6. `.markdownlint.mjs`
- The VS Code extension `vscode-markdownlint` includes a schema definition for

@@ -331,4 +347,2 @@ the `JSON(C)` configuration files described below. This adds auto-complete and

- Other details are the same as for `.markdownlint-cli2.jsonc` described above.
- If a `.markdownlint-cli2.jsonc` file is present in the same directory, it
takes precedence.
- For example: [`.markdownlint-cli2.yaml`][markdownlint-cli2-yaml] with all

@@ -346,8 +360,14 @@ properties set

- Other details are the same as for `.markdownlint-cli2.jsonc` described above.
- If a `.markdownlint-cli2.jsonc` or `.markdownlint-cli2.yaml` file is present
in the same directory, it takes precedence; `.markdownlint-cli2.cjs` takes
precedence over `.markdownlint-cli2.mjs`.
- For example: [`.markdownlint-cli2.cjs`][markdownlint-cli2-cjs] or
[`.markdownlint-cli2.mjs`][markdownlint-cli2-mjs]
### `package.json`
- The format of this file is a standard [npm `package.json`][package-json] file
including a `markdownlint-cli2` property at the root and a value corresponding
to the object described above for `.markdownlint-cli2.jsonc`.
- `package.json` is only supported in the current directory.
- `package.json` is not supported by the `--config` argument.
- For example: [`package-json-sample`][package-json-sample]
### `.markdownlint.jsonc` or `.markdownlint.json`

@@ -360,4 +380,2 @@

directory (up to the current directory).
- If `jsonc` and `json` files are present in the same directory, the `jsonc`
version takes precedence.
- To merge the settings of these files or share configuration, use the `extends`

@@ -373,6 +391,2 @@ property (documented in the link above).

- Other details are the same as for `jsonc`/`json` files described above.
- If `yaml` and `yml` files are present in the same directory, the `yaml`
version takes precedence.
- If a `jsonc` or `json` file is present in the same directory, it takes
precedence.
- For example: [`.markdownlint.yaml`][markdownlint-yaml]

@@ -386,5 +400,2 @@

- Other details are the same as for `jsonc`/`json` files described above.
- If a `.markdownlint.jsonc`, `.json`, `.yaml`, or `.yml` file is present in the
same directory, it takes precedence; `.markdownlint.cjs` takes precedence over
`.markdownlint.mjs`.
- For example: [`.markdownlint.cjs`][markdownlint-cjs] or

@@ -415,3 +426,3 @@ [`.markdownlint.mjs`][markdownlint-mjs]

- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.8.1
rev: v0.9.0
hooks:

@@ -428,4 +439,2 @@ - id: markdownlint-cli2

<!-- markdownlint-disable line-length -->
[commonmark]: https://commonmark.org/

@@ -481,2 +490,4 @@ [commonjs-module]: https://nodejs.org/api/modules.html#modules_modules_commonjs_modules

[output-formatters]: doc/OutputFormatters.md
[package-json]: https://docs.npmjs.com/cli/v9/configuring-npm/package-json
[package-json-sample]: test/package-json/package.json
[pre-commit]: https://pre-commit.com/

@@ -483,0 +494,0 @@ [pre-commit-version]: https://pre-commit.com/#overriding-language-version

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