You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

v8r

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

v8r - npm Package Compare versions

Comparing version

to
4.4.0

20

CHANGELOG.md
# Changelog
## 📦 [4.4.0](https://www.npmjs.com/package/v8r/v/4.4.0) - 2025-04-26
Version 4.4.0 is a deprecation release. This release adds deprecation warnings for
upcoming breaking changes that will be made in version 5.0
* This release adds the `--output-format` CLI argument and `outputFormat` config file key.
In v8r 4.4.0 `--format` and `format` can still be used as aliases.
In version 5 `--format` and `format` will be removed.
It is recommended to switch to using `--output-format` and `outputFormat` now.
* Starting from v8r version 5, v8r will ignore patterns in `.gitignore` by default.
* In v8r version 5 the `fileLocation` argument of `getSingleResultLogMessage` will be removed.
The signature will become `getSingleResultLogMessage(result, format)`.
Plugins implementing the `getSingleResultLogMessage` plugin hook will need to to update
the signature to be compatible with version 5.
If you are using `fileLocation` in the `getSingleResultLogMessage` function body,
switch to using `result.fileLocation`.
* Starting from v8r version 5 file paths will no longer be passed to plugins in dot-relative notation.
Plugins implementing the `getSingleResultLogMessage`, `getAllResultsLogMessage` and `parseInputFile`
plugin hooks may need to be updated.
## 📦 [4.3.0](https://www.npmjs.com/package/v8r/v/4.3.0) - 2025-04-21

@@ -4,0 +24,0 @@

14

config-schema.json

@@ -6,2 +6,9 @@ {

"additionalProperties": false,
"allOf": [
{
"not": {
"required": ["format", "outputFormat"]
}
}
],
"properties": {

@@ -61,6 +68,11 @@ "cacheTtl": {

},
"format": {
"outputFormat": {
"description": "Output format for validation results. 'text' and 'json' are always valid. Plugins may define additional values which are valid here.",
"type": "string"
},
"format": {
"description": "Output format for validation results. 'text' and 'json' are always valid. Plugins may define additional values which are valid here.",
"type": "string",
"deprecated": true
},
"ignoreErrors": {

@@ -67,0 +79,0 @@ "description": "Exit with code 0 even if an error was encountered. True means a non-zero exit code is only issued if validation could be completed successfully and one or more files were invalid",

2

package.json
{
"name": "v8r",
"version": "4.3.0",
"version": "4.4.0",
"description": "A command-line JSON, YAML and TOML validator that's on your wavelength",

@@ -5,0 +5,0 @@ "scripts": {

@@ -56,2 +56,4 @@ import { createRequire } from "node:module";

}
// https://github.com/chris48s/v8r/issues/494
delete mergedConfig.format;
return mergedConfig;

@@ -124,2 +126,9 @@ }

}
// https://github.com/chris48s/v8r/issues/494
if (process.argv.includes("--format")) {
logger.warning(
"In v8r version 5 the --format argument will be removed. Switch to using --output-format",
);
}
},

@@ -182,7 +191,10 @@ )

})
.option("format", {
.option("output-format", {
type: "string",
choices: outputFormats,
default: "text",
describe: "Output format for validation results",
// https://github.com/chris48s/v8r/issues/494
describe:
"Output format for validation results. The '--format' alias is deprecated.",
alias: "format",
})

@@ -199,3 +211,3 @@ .example([

for (const [key, value] of Object.entries(config.config)) {
if (["cacheTtl", "format", "ignoreErrors", "verbose"].includes(key)) {
if (["cacheTtl", "outputFormat", "ignoreErrors", "verbose"].includes(key)) {
parser.default(

@@ -246,2 +258,10 @@ decamelize(key, { separator: "-" }),

// https://github.com/chris48s/v8r/issues/494
if (configFile.config.format) {
logger.warning(
"In v8r version 5 the 'format' config file key will be removed. Switch to using 'outputFormat'",
);
configFile.config.outputFormat = configFile.config.format;
}
// load both core and user plugins

@@ -262,2 +282,7 @@ let plugins = resolveUserPlugins(configFile.config.plugins || []);

// https://github.com/chris48s/v8r/issues/599
logger.warning(
"Starting from v8r version 5, v8r will ignore patterns in .gitignore by default.",
);
return {

@@ -264,0 +289,0 @@ config: mergeConfigs(args, configFile),

@@ -148,3 +148,3 @@ import fs from "node:fs";

filename,
config.format,
config.outputFormat,
);

@@ -195,3 +195,6 @@ if (message != null) {

for (const plugin of plugins) {
const message = plugin.getAllResultsLogMessage(results, config.format);
const message = plugin.getAllResultsLogMessage(
results,
config.outputFormat,
);
if (message != null) {

@@ -198,0 +201,0 @@ logger.log(message);

@@ -50,2 +50,8 @@ import chalk from "chalk";

warning(message) {
const formatedMessage = chalk.yellow.bold("▲ ") + message;
this.stderr.push(formatedMessage);
this.writeErr(formatedMessage);
}
error(message) {

@@ -52,0 +58,0 @@ const formatedMessage = chalk.red.bold("✖ ") + message;

import path from "node:path";
import logger from "./logger.js";

@@ -56,4 +57,4 @@ /**

* formats that can be generated. Any formats registered with this hook become
* valid values for the `format` property in the config file and the
* `--format` command line argument.
* valid values for the `outputFormat` property in the config file and the
* `--output-format` command line argument.
*

@@ -84,3 +85,3 @@ * @returns {string[]} Output formats to register

* @param {string} format - The user's requested output format as specified in
* the config file or via the `--format` command line argument.
* the config file or via the `--output-format` command line argument.
* @returns {string | undefined} Log message

@@ -107,3 +108,3 @@ */

* @param {string} format - The user's requested output format as specified in
* the config file or via the `--format` command line argument.
* the config file or via the `--output-format` command line argument.
* @returns {string | undefined} Log message

@@ -129,3 +130,7 @@ */

function validatePlugin(plugin) {
function hasProperty(plugin, prop) {
return Object.prototype.hasOwnProperty.call(plugin.prototype, prop);
}
function validatePlugin(plugin, warnings) {
if (

@@ -157,2 +162,25 @@ typeof plugin.name !== "string" ||

}
if (warnings === true) {
// https://github.com/chris48s/v8r/issues/500
if (hasProperty(plugin, "getSingleResultLogMessage")) {
logger.warning(
"In v8r version 5 the fileLocation argument of getSingleResultLogMessage will be removed.\n" +
" The signature will become getSingleResultLogMessage(result, format).\n" +
` ${plugin.name} will need to be updated`,
);
}
// https://github.com/chris48s/v8r/issues/600
if (
hasProperty(plugin, "getSingleResultLogMessage") ||
hasProperty(plugin, "getAllResultsLogMessage") ||
hasProperty(plugin, "parseInputFile")
) {
logger.warning(
"Starting from v8r version 5 file paths will no longer be passed to plugins in dot-relative notation.\n" +
` ${plugin.name} may need to be updated`,
);
}
}
}

@@ -173,3 +201,3 @@

async function loadPlugins(plugins) {
async function loadPlugins(plugins, warnings) {
let loadedPlugins = [];

@@ -180,3 +208,3 @@ for (const plugin of plugins) {

loadedPlugins = loadedPlugins.map((plugin) => plugin.default);
loadedPlugins.forEach((plugin) => validatePlugin(plugin));
loadedPlugins.forEach((plugin) => validatePlugin(plugin, warnings));
loadedPlugins = loadedPlugins.map((plugin) => new plugin());

@@ -187,3 +215,3 @@ return loadedPlugins;

async function loadAllPlugins(userPlugins) {
const loadedUserPlugins = await loadPlugins(userPlugins);
const loadedUserPlugins = await loadPlugins(userPlugins, true);

@@ -198,3 +226,3 @@ const corePlugins = [

];
const loadedCorePlugins = await loadPlugins(corePlugins);
const loadedCorePlugins = await loadPlugins(corePlugins, false);

@@ -201,0 +229,0 @@ return {