<commit_before>/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author <NAME> @gajus
*/
var webpackOptionsSchema = require("../schemas/webpackOptionsSchema.json");

function WebpackOptionsValidationError(validationErrors) {
	Error.call(this);
	Error.captureStackTrace(this, WebpackOptionsValidationError);
	this.name = "WebpackOptionsValidationError";
	this.message = "Invalid configuration object. " +
		"Webpack has been initialised using a configuration object that does not match the API schema.\n" +
		validationErrors.map(function(err) {
			return " - " + indent(WebpackOptionsValidationError.formatValidationError(err), "   ", false);
		}).join("\n");
	this.validationErrors = validationErrors;
}
module.exports = WebpackOptionsValidationError;

WebpackOptionsValidationError.prototype = Object.create(Error.prototype);
WebpackOptionsValidationError.prototype.constructor = WebpackOptionsValidationError;

WebpackOptionsValidationError.formatValidationError = function formatValidationError(err) {
	var dataPath = "configuration" + err.dataPath;
	switch(err.keyword) {
		case "additionalProperties":
			var baseMessage = dataPath + " has an unknown property '" + err.params.additionalProperty + "'. These properties are valid:\n" +
				getSchemaPartText(err.parentSchema);
			if(!err.dataPath) {
				return baseMessage + "\n" +
					"For typos: please correct them.\n" +
					"For loader options: webpack 2 no longer allows custom properties in configuration.\n" +
					"  Loaders should be updated to allow passing options via loader options in module.rules.\n" +
					"  Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:\n" +
					"  plugins: {\n" +
					"    new webpack.LoaderOptionsPlugin({\n" +
					"      options: {\n" +
					"        " + err.params.additionalProperty + ": ...\n" +
					"      }\n" +
					"    })\n" +
					"  }";
			}
			return baseMessage;
		case "oneOf":
		case "anyOf":
		case "enum":
			return dataPath + " should be one of these:\n" +
				getSchemaPartText(err.parentSchema);
		case "allOf":
			return dataPath + " should be:\n" +
				getSchemaPartText(err.parentSchema);
		case "type":<commit_msg>added another custom error message for the debug property<commit_after>/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author <NAME> @gajus
*/
var webpackOptionsSchema = require("../schemas/webpackOptionsSchema.json");

function WebpackOptionsValidationError(validationErrors) {
	Error.call(this);
	Error.captureStackTrace(this, WebpackOptionsValidationError);
	this.name = "WebpackOptionsValidationError";
	this.message = "Invalid configuration object. " +
		"Webpack has been initialised using a configuration object that does not match the API schema.\n" +
		validationErrors.map(function(err) {
			return " - " + indent(WebpackOptionsValidationError.formatValidationError(err), "   ", false);
		}).join("\n");
	this.validationErrors = validationErrors;
}
module.exports = WebpackOptionsValidationError;

WebpackOptionsValidationError.prototype = Object.create(Error.prototype);
WebpackOptionsValidationError.prototype.constructor = WebpackOptionsValidationError;

WebpackOptionsValidationError.formatValidationError = function formatValidationError(err) {
	var dataPath = "configuration" + err.dataPath;
	switch(err.keyword) {
		case "additionalProperties":
			var baseMessage = dataPath + " has an unknown property '" + err.params.additionalProperty + "'. These properties are valid:\n" +
				getSchemaPartText(err.parentSchema);
			if(!err.dataPath) {
				switch(err.params.additionalProperty) {
					case "debug":
						return baseMessage + "\n" +
							"The 'debug' property was removed in webpack 2.\n" +
							"Loaders should be updated to allow passing this option via loader options in module.rules.\n" +
							"Until loaders are updated one can use the LoaderOptionsPlugin to switch loaders into debug mode:\n" +
							"plugins: {\n" +
							"  new webpack.LoaderOptionsPlugin({\n" +
							"    debug: true\n" +
							"  })\n" +
							"}";
				}
				return baseMessage + "\n" +
					"For typos: please correct them.\n" +
					"For loader options: webpack 2 no longer allows custom properties in configuration.\n" +
					"  Loaders should be updated to allow passing options via loader options in module.rules.\n" +
					"  Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:\n" +
					"  plugins: {\n" +
					"    new webpack.LoaderOptionsPlugin({\n" +
					"      options: {\n" +
					"        " + err.params.additionalProperty + ": ...\n" +
					"      }\n" +
					"    })\n" +
					"  }";
			}
			return baseMessage;
		case "oneOf":
		case "anyOf":
		case "enum":
			return dataPath + " should be one of these:\n" +
				getSchemaPartText(err.parentSchema);
		case "allOf":
			return dataPath + " should be:\n" +
				getSchemaPartText(err.parentSchema);
		case "type":
{'fraction_non_alphanumeric': 0.11686479951642152, 'fraction_numerical': 0.0006044731009470078, 'mean_word_length': 3.7186311787072244, 'pattern_counts': {'":': 15, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7642385', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1399, 'n_words': 371}