Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix: validation schema with latest ajv
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Jun 6, 2017
1 parent d0e88d0 commit 0ec10e6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 28 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var ExtractedModule = require("./ExtractedModule");
var Chunk = require("webpack/lib/Chunk");
var OrderUndefinedError = require("./OrderUndefinedError");
var loaderUtils = require("loader-utils");
var schemaTester = require('./schema/validator');
var validateOptions = require('schema-utils');
var loaderSchema = require('./schema/loader-schema');
var pluginSchema = require('./schema/plugin-schema.json');

Expand Down Expand Up @@ -122,7 +122,7 @@ function ExtractTextPlugin(options) {
if(isString(options)) {
options = { filename: options };
} else {
schemaTester(pluginSchema, options);
validateOptions(pluginSchema, options, ' Extract Text Plugin');
}
this.filename = options.filename;
this.id = options.id != null ? options.id : ++nextId;
Expand Down Expand Up @@ -201,7 +201,7 @@ ExtractTextPlugin.prototype.extract = function(options) {
if(Array.isArray(options) || isString(options) || typeof options.options === "object" || typeof options.query === 'object') {
options = { loader: options };
} else {
schemaTester(loaderSchema, options);
validateOptions(loaderSchema, options, 'Extract Text Loader');
}
var loader = options.use ||  options.loader;
var before = options.fallback || options.fallbackLoader || [];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"webpack": "^2.2.0"
},
"dependencies": {
"ajv": "^4.11.2",
"schema-utils": "^0.3.0",
"async": "^2.1.2",
"loader-utils": "^1.0.2",
"webpack-sources": "^0.1.0"
Expand Down
1 change: 0 additions & 1 deletion schema/loader-schema.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down
12 changes: 3 additions & 9 deletions schema/plugin-schema.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"additionalProperties": false,
"properties": {
Expand All @@ -14,16 +13,13 @@
"fallback": {
"description": "A loader that webpack can fall back to if the original one fails.",
"modes": {
"type": "string",
"type": "object",
"type": "array"
"type": ["string", "object", "array"]
}
},
"filename": {
"description": "The filename and path that ExtractTextPlugin will extract to",
"modes": {
"type": "string",
"type": "function"
"type": ["string", "function"]
}
},
"ignoreOrder": {
Expand All @@ -33,9 +29,7 @@
"loader": {
"description": "The loader that ExtractTextPlugin will attempt to load through.",
"modes": {
"type": "string",
"type": "object",
"type": "array"
"type": ["string", "object", "array"]
}
},
"publicPath": {
Expand Down
13 changes: 0 additions & 13 deletions schema/validator.js

This file was deleted.

5 changes: 4 additions & 1 deletion test/extract.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ describe("ExtractTextPlugin.extract()", function() {
ExtractTextPlugin.extract({style: 'file.css'});
},
function(err) {
return err.message === 'data[\'style\'] should NOT have additional properties';
console.log(err.message)
return err.message === 'Validation Error\n\n' +
'Extract Text Loader Invalid Options\n\n'
+ 'options[\'style\'] should NOT have additional properties\n';
}
);
});
Expand Down

0 comments on commit 0ec10e6

Please sign in to comment.