Skip to content

Commit

Permalink
Fix node-saml#392 Switching from jshint to eslint
Browse files Browse the repository at this point in the history
 - Fix also Travis to run eslint instead of jshint
 - Upgrade eslint dep
 - fix lint violations
  • Loading branch information
walokra authored and markstos committed Oct 1, 2019
1 parent dd1699a commit 7d71fe2
Show file tree
Hide file tree
Showing 4 changed files with 1,059 additions and 436 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ node_js:

script:
- npm test
- ./node_modules/.bin/jshint lib
- ./node_modules/.bin/eslint lib
12 changes: 6 additions & 6 deletions lib/passport-saml/saml.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SAML.prototype.initialize = function (options) {
options = {};
}

if (options.hasOwnProperty('cert') && !options.cert) {
if (Object.prototype.hasOwnProperty.call(options, 'cert') && !options.cert) {
throw new Error('Invalid property: cert must not be empty');
}

Expand Down Expand Up @@ -591,7 +591,7 @@ SAML.prototype.validatePostResponse = function (container, callback) {
doc = new xmldom.DOMParser({
}).parseFromString(xml);

if (!doc.hasOwnProperty('documentElement'))
if (!Object.prototype.hasOwnProperty.call(doc, 'documentElement'))
throw new Error('SAMLResponse is not valid base64-encoded XML');

inResponseTo = xpath(doc, "/*[local-name()='Response']/@InResponseTo");
Expand Down Expand Up @@ -840,13 +840,13 @@ function validateSignatureForRedirect (urlString, signature, alg, cert) {
function hasMatch (ourAlgo) {
// The incoming algorithm is forwarded as a URL.
// We trim everything before the last # get something we can compare to the Node.js list
const algFromURI = alg.toLowerCase().replace(/.*#(.*)$/,'$1')
return ourAlgo.toLowerCase() === algFromURI
const algFromURI = alg.toLowerCase().replace(/.*#(.*)$/,'$1');
return ourAlgo.toLowerCase() === algFromURI;
}
let i = crypto.getHashes().findIndex(hasMatch);
let matchingAlgo;
if (i > -1) {
matchingAlgo = crypto.getHashes()[i]
matchingAlgo = crypto.getHashes()[i];
}
else {
throw alg + ' is not supported';
Expand Down Expand Up @@ -1038,7 +1038,7 @@ SAML.prototype.processValidlySignedAssertion = function(xml, samlResponseXml, in

if (attributes) {
attributes.forEach(function (attribute) {
if(!attribute.hasOwnProperty('AttributeValue')) {
if(!Object.prototype.hasOwnProperty.call(attribute, 'AttributeValue')) {
// if attributes has no AttributeValue child, continue
return;
}
Expand Down
25 changes: 22 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
},
"devDependencies": {
"body-parser": "^1.17.1",
"eslint": "^6.5.1",
"express": "^4.16.2",
"jshint": "^2.10.1",
"mocha": "^6.0.2",
"passport": "0.4.x",
"request": "^2.83.0",
Expand All @@ -50,7 +50,26 @@
"node": ">= 8"
},
"scripts": {
"test": "mocha",
"jshint": "./node_modules/.bin/jshint lib"
"test": "npm run lint && mocha",
"lint": "./node_modules/.bin/eslint lib",
"lint:fix": "./node_modules/.bin/eslint --fix lib"
},
"eslintConfig": {
"env": {
"node": true,
"es6": false
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"no-undefined": "off",
"no-unused-vars": "off",
"semi": [
"error",
"always"
]
}
}
}
Loading

0 comments on commit 7d71fe2

Please sign in to comment.