Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
feat: improved validation error messages (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Jul 18, 2019
1 parent aebfd74 commit 6cf76b8
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 265 deletions.
8 changes: 8 additions & 0 deletions .github/CONTRIBUTING.md
Expand Up @@ -147,6 +147,14 @@ module. Thankfully, Github provides a means to do this. Add a dependency to the

Where `{id}` is the # ID of your Pull Request.

## Contributor License Agreement

When submitting your contribution, a CLA (Contributor License Agreement) bot will come by to verify that you signed the [CLA](https://cla.js.foundation/webpack-contrib/raw-loader).
If it is your first time, it will link you to the right place to sign it.
However, if you have committed your contributions using an email that is not the same as your email used on GitHub, the CLA bot can't accept your contribution.

Run `git config user.email` to see your Git email, and verify it with [your GitHub email](https://github.com/settings/emails).

## Thanks

For your interest, time, understanding, and for following this simple guide.
2 changes: 1 addition & 1 deletion lint-staged.config.js
@@ -1,4 +1,4 @@
module.exports = {
'*.js': ['prettier --write', 'eslint --fix', 'git add'],
'(!CHANGELOG.md).{json,md,yml,css}': ['prettier --write', 'git add'],
'*.{json,md,yml,css}': ['prettier --write', 'git add'],
};
540 changes: 298 additions & 242 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Expand Up @@ -38,34 +38,34 @@
},
"dependencies": {
"loader-utils": "^1.1.0",
"schema-utils": "^1.0.0"
"schema-utils": "^2.0.1"
},
"devDependencies": {
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.6",
"@babel/preset-env": "^7.1.6",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"@webpack-contrib/defaults": "^5.0.0",
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"@webpack-contrib/defaults": "^5.0.2",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^24.5.0",
"babel-jest": "^24.8.0",
"commitlint-azure-pipelines-cli": "^1.0.2",
"cross-env": "^5.2.0",
"del": "^5.0.0",
"del-cli": "^2.0.0",
"eslint": "^6.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-prettier": "^3.1.0",
"husky": "^3.0.0",
"jest": "^24.5.0",
"jest": "^24.8.0",
"jest-junit": "^6.4.0",
"lint-staged": "^9.2.0",
"memory-fs": "^0.4.1",
"npm-run-all": "^4.1.5",
"prettier": "^1.11.1",
"prettier": "^1.18.2",
"standard-version": "^6.0.1",
"webpack": "^4.3.0"
"webpack": "^4.36.1"
},
"keywords": [
"webpack"
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Expand Up @@ -6,7 +6,10 @@ import schema from './options.json';
export default function rawLoader(source) {
const options = getOptions(this) || {};

validateOptions(schema, options, 'Raw Loader');
validateOptions(schema, options, {
name: 'Raw Loader',
baseDataPath: 'options',
});

const json = JSON.stringify(source)
.replace(/\u2028/g, '\\u2028')
Expand Down
7 changes: 7 additions & 0 deletions test/__snapshots__/validate-options.test.js.snap
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`validate options 1`] = `
"Invalid options object. Raw Loader has been initialised using an options object that does not match the API schema.
- options has an unknown property 'unknown'. These properties are valid:
object {}"
`;
8 changes: 0 additions & 8 deletions test/__snapshots__/validation.test.js.snap

This file was deleted.

2 changes: 1 addition & 1 deletion test/validation.test.js → test/validate-options.test.js
@@ -1,6 +1,6 @@
import loader from '../src';

it('validation', () => {
it('validate options', () => {
const validate = (options) =>
loader.call(
Object.assign(
Expand Down

0 comments on commit 6cf76b8

Please sign in to comment.