react-action-validation
Advanced tools
Comparing version
@@ -7,5 +7,15 @@ const fs = require('fs'); | ||
'parser': 'babel-eslint', | ||
'extends': ['prettier', 'plugin:import/errors'], | ||
'ignorePatterns': ['*.test.js', '*.spec.js', '*.config.js', '**/dist/*', '**/node_modules/*'], | ||
'plugins': ['prettier', 'import'], | ||
'env': { | ||
browser: true, | ||
node: true, | ||
jest: true, | ||
es6: true, | ||
}, | ||
'extends': [ | ||
'prettier', | ||
'plugin:import/errors', | ||
'plugin:jest/recommended' | ||
], | ||
'ignorePatterns': ['*.config.js', '**/dist/*', '**/node_modules/*'], | ||
'plugins': ['prettier', 'import', 'jest'], | ||
'rules': { | ||
@@ -33,3 +43,8 @@ 'prettier/prettier': ['error', prettierOptions], | ||
'no-console': 1, | ||
'jest/no-disabled-tests': 'warn', | ||
'jest/no-focused-tests': 'error', | ||
'jest/no-identical-title': 'error', | ||
'jest/prefer-to-have-length': 'warn', | ||
'jest/valid-expect': 'error' | ||
} | ||
}; |
module.exports = { | ||
env: { | ||
test: { | ||
plugins: ["@babel/plugin-transform-runtime"] | ||
} | ||
}, | ||
presets: [ | ||
@@ -3,0 +8,0 @@ '@babel/preset-env', |
@@ -93,16 +93,48 @@ import Joi from '@hapi/joi'; | ||
return function (next) { | ||
return function (action) { | ||
if (!validations[action.type]) { | ||
next(action); | ||
} else { | ||
var validation = new validations[action.type](); | ||
validation.validate(action.payload).then(function () { | ||
validation.accept(action.type); | ||
next(action); | ||
})["catch"](function (e) { | ||
console.error(e); | ||
validation.reject(action.type); | ||
}); | ||
} | ||
}; | ||
return /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(action) { | ||
var validation; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (validations[action.type]) { | ||
_context.next = 4; | ||
break; | ||
} | ||
next(action); | ||
_context.next = 16; | ||
break; | ||
case 4: | ||
validation = new validations[action.type](); | ||
_context.prev = 5; | ||
_context.next = 8; | ||
return validation.validate(action.payload); | ||
case 8: | ||
validation.accept(action.type); | ||
next(action); | ||
_context.next = 16; | ||
break; | ||
case 12: | ||
_context.prev = 12; | ||
_context.t0 = _context["catch"](5); | ||
console.error(_context.t0); | ||
validation.reject(action.type); | ||
case 16: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, null, [[5, 12]]); | ||
})); | ||
return function (_x) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
}; | ||
@@ -109,0 +141,0 @@ }; |
{ | ||
"name": "react-action-validation", | ||
"version": "0.0.4-alpha", | ||
"version": "0.0.5-alpha", | ||
"description": "validates the payload of the dispatched action", | ||
"main": "./dist/index.js", | ||
"scripts": { | ||
"build": "rollup --config ./rollup.config.js", | ||
"lint:staged": "lint-staged" | ||
"build": "rollup --config ./internals/rollup.config.js", | ||
"lint:staged": "lint-staged", | ||
"test": "jest", | ||
"coverage": "jest --coverage", | ||
"release": "node ./internals/publish.js" | ||
}, | ||
@@ -40,2 +43,3 @@ "repository": { | ||
"@babel/plugin-transform-object-assign": "^7.8.3", | ||
"@babel/plugin-transform-runtime": "^7.10.4", | ||
"@babel/preset-env": "^7.6.3", | ||
@@ -47,2 +51,3 @@ "babel-eslint": "^10.0.3", | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-jest": "^23.17.1", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
@@ -49,0 +54,0 @@ "jest": "^24.9.0", |
@@ -1,2 +0,2 @@ | ||
export default validations => () => next => action => { | ||
export default validations => () => next => async action => { | ||
if (!validations[action.type]) { | ||
@@ -6,13 +6,11 @@ next(action); | ||
const validation = new validations[action.type](); | ||
validation | ||
.validate(action.payload) | ||
.then(() => { | ||
validation.accept(action.type); | ||
next(action); | ||
}) | ||
.catch(e => { | ||
console.error(e); | ||
validation.reject(action.type); | ||
}); | ||
try { | ||
await validation.validate(action.payload); | ||
validation.accept(action.type); | ||
next(action); | ||
} catch (e) { | ||
console.error(e); | ||
validation.reject(action.type); | ||
} | ||
} | ||
}; |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
20470
37.42%19
35.71%429
65.64%20
11.11%2
100%1
Infinity%