ESLint Unexpected Session statement

Not sure why but when I use session, I’m getting the ESLint error (meteor/no-session) “Unexpected Session statement”

Here’s a sample:

import { Session } from 'meteor/session';
const redirect = Session.get('redirect');

Are you accessing the session outside the context of a function?

I believe sessions are frowned upon using the meteor eslint plugin.

Yep. From the docs:

This rule prevents any usage of Session. Session variables live in a global namespace, which is bad practice. reactive-dict should be used instead.

You can disable this (and any other eslint rule by adding the following to rules dictionary in eslint config:

        "meteor/no-session": [
            0
        ],
1 Like

I’m using session in my Accounts.onLogin to handle redirects to the forwarding page after login:

Accounts.onLogin(()=> {
    const redirect = Session.get('redirect');

In this case it makes sense, so I would just ignore the warning.