Skip to content

Commit 4ded988

Browse files
committed
feat: upgrade common-errors to 1.x.x
BREAKING CHANGE: removed some babel transforms, requires node > 6.2.x, npm > 3.x.x Added ~1.x.x peerDependency of common-errors to make sure it's consistent across the project
1 parent 3b259d0 commit 4ded988

3 files changed

Lines changed: 27 additions & 26 deletions

File tree

.babelrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"plugins": [
33
"transform-strict-mode",
4-
"transform-es2015-spread",
5-
"transform-object-rest-spread",
6-
"transform-class-properties"
4+
"transform-class-properties",
5+
"transform-object-rest-spread"
76
]
87
}

package.json

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "ms-validation",
33
"description": "ajv-based validation utils for mservice architecture",
44
"main": "./lib/index.js",
5+
"engines": {
6+
"node": ">= 6.2.2",
7+
"npm": "~3.x.x"
8+
},
59
"scripts": {
610
"compile": "babel -d ./lib ./src",
711
"pretest": "npm run compile",
@@ -24,30 +28,29 @@
2428
},
2529
"homepage": "https://github.com/makeomatic/ms-validation#readme",
2630
"devDependencies": {
27-
"babel-cli": "^6.4.0",
28-
"babel-eslint": "^6.0.0",
29-
"babel-plugin-transform-class-properties": "^6.4.0",
30-
"babel-plugin-transform-es2015-destructuring": "^6.4.0",
31-
"babel-plugin-transform-es2015-parameters": "^6.4.0",
32-
"babel-plugin-transform-es2015-shorthand-properties": "^6.3.13",
33-
"babel-plugin-transform-es2015-spread": "^6.4.0",
34-
"babel-plugin-transform-object-rest-spread": "^6.3.13",
35-
"babel-plugin-transform-strict-mode": "^6.3.13",
36-
"babel-register": "^6.3.13",
31+
"babel-cli": "^6.11.4",
32+
"babel-eslint": "^6.1.2",
33+
"babel-plugin-transform-class-properties": "^6.11.5",
34+
"babel-plugin-transform-object-rest-spread": "^6.8.0",
35+
"babel-plugin-transform-strict-mode": "^6.11.3",
36+
"babel-register": "^6.11.6",
3737
"chai": "^3.4.1",
3838
"cz-conventional-changelog": "^1.1.5",
39-
"eslint": "^2.9.0",
40-
"eslint-config-airbnb-base": "^3.0.1",
41-
"eslint-plugin-import": "^1.8.0",
42-
"eslint-plugin-mocha": "^2.2.0",
43-
"mocha": "^2.3.4",
39+
"eslint": "^3.1.1",
40+
"eslint-config-airbnb-base": "^5.0.0",
41+
"eslint-plugin-import": "^1.12.0",
42+
"eslint-plugin-mocha": "^4.2.0",
43+
"mocha": "^2.5.3",
4444
"semantic-release": "^4.3.5"
4545
},
4646
"dependencies": {
47-
"ajv": "^4.0.5",
48-
"bluebird": "^3.1.1",
47+
"ajv": "^4.2.0",
48+
"bluebird": "^3.4.1",
4949
"callsite": "^1.0.0",
50-
"common-errors": "^0.5.3"
50+
"common-errors": "^1.0.0"
51+
},
52+
"peerDependencies": {
53+
"common-errors": "~1.x.x"
5154
},
5255
"release": {
5356
"verifyConditions": []

src/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ const Promise = require('bluebird');
22
const ajv = require('ajv');
33
const path = require('path');
44
const fs = require('fs');
5-
const Errors = require('common-errors');
65
const callsite = require('callsite');
7-
const { ValidationError } = Errors;
6+
const { ValidationError, io, NotFoundError } = require('common-errors');
87

98
/**
109
* Patch it! We rely on isntanceof Error when serializing and deserializing errors and
@@ -130,7 +129,7 @@ class Validator {
130129
try {
131130
list = fs.readdirSync(dir);
132131
} catch (err) {
133-
const error = new Errors.io.IOError(`was unable to read ${dir}`, err);
132+
const error = new io.IOError(`was unable to read ${dir}`, err);
134133

135134
if (isAsync) {
136135
return Promise.reject(error);
@@ -141,7 +140,7 @@ class Validator {
141140

142141
const filenames = list.filter(this.filterOpt);
143142
if (filenames.length === 0) {
144-
const error = new Errors.io.FileNotFoundError(`no schemas found in dir '${dir}'`);
143+
const error = new io.FileNotFoundError(`no schemas found in dir '${dir}'`);
145144
if (isAsync) {
146145
return Promise.reject(error);
147146
}
@@ -170,7 +169,7 @@ class Validator {
170169
const validate = this.$ajv.getSchema(schema);
171170

172171
if (!validate) {
173-
return { error: new Errors.NotFoundError(`validator "${schema}" not found`) };
172+
return { error: new NotFoundError(`validator "${schema}" not found`) };
174173
}
175174

176175
validate(data);

0 commit comments

Comments
 (0)