Skip to content

Commit

Permalink
- Linting (ESLint): Avoid "useless" catch error; adhere to stricter j…
Browse files Browse the repository at this point in the history
…sdoc context checking

- Minor fixes for template files for gitignore/package.json/README
- npm: update devDeps
  • Loading branch information
brettz9 committed Jun 28, 2019
1 parent b3a5346 commit d5c5407
Show file tree
Hide file tree
Showing 12 changed files with 657 additions and 126 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
},
extends: [
'@passport-next/eslint-config-passport-next/sauron-node.js',
// Override ash-nazg's current preference for ESM
// Override eslint-config-passport-next's current preference for ESM
'plugin:node/recommended-script'
],
settings: {
Expand Down Expand Up @@ -74,7 +74,7 @@ module.exports = {
// Disable until ready to tackle
'require-jsdoc': 0,

// Disable current preferences of ash-nazg
// Disable current preferences of eslint-config-passport-next
'import/no-commonjs': 0,
'node/exports-style': 0,

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
reports/
docs/jsdoc
.github/docs/jsdoc
var/


Expand Down
1 change: 1 addition & 0 deletions lib/http/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const req = exports = module.exports = {};
* try {
* await req.logIn(user);
* } catch (err) {
* console.error(err);
* throw err;
* }
* // session saved
Expand Down
6 changes: 5 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ const SessionStrategy = require('./strategies/session');
* @typedef {external:HttpServerResponse} Response
*/

/**
* @external ConnectNextCallback
*/

/**
* This middleware conforms to Connect/Express middleware by
* the arguments it accepts.
* @see Conforms to {@link external:ConnectMiddleware}
* @callback ConnectMiddleware
* @param {Request} req
* @param {Response} res
* @param {Function} next
* @param {ConnectNextCallback} next
* @returns {void}
*/

Expand Down
5 changes: 3 additions & 2 deletions lib/middleware/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const AuthenticationError = require('../errors/authenticationerror');
* @param {Error|null} error
* @param {false|User} user Set to the authenticated user on a successful
* authentication attempt, or `false` otherwise.
* @param {*} [info] Contains additional details provided by the strategy's verify
* @param {Any} [info] Contains additional details provided by the strategy's verify
* callback - this could be information about a successful authentication or a
* challenge message for a failed authentication.
* @param {*} [status] Passed when authentication fails - this could
* @param {Any} [status] Passed when authentication fails - this could
* be an HTTP response code for a remote authentication failure or similar.
* @returns {void}
* @example
Expand Down Expand Up @@ -329,6 +329,7 @@ module.exports = function authenticate(passport, name, options, callback) {
if (options.authInfo !== false) {
try {
const tinfo = await passport.transformAuthInfo(info, req);
// eslint-disable-next-line require-atomic-updates
req.authInfo = tinfo;
complete();
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions lib/sessionmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class SessionManager {
}
return;
}
/* eslint-disable require-atomic-updates */
if (!req._passport.session) {
req._passport.session = {};
}
Expand All @@ -63,6 +64,7 @@ class SessionManager {
req.session = {};
}
req.session[this._key] = req._passport.session;
/* eslint-enable require-atomic-updates */
// eslint-disable-next-line no-unused-expressions
cb && cb();
}
Expand Down
1 change: 1 addition & 0 deletions lib/strategies/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class SessionStrategy extends Strategy {
} else {
// TODO: Remove instance access (set by `initialize`)
const property = req._passport.instance._userProperty || 'user';
// eslint-disable-next-line require-atomic-updates
req[property] = user;
}
this.pass();
Expand Down
Loading

0 comments on commit d5c5407

Please sign in to comment.