Files
meteor/docs/rules/session.md
2015-10-25 15:10:58 +01:00

1.3 KiB

Core API for Session (session)

Prevent misusage of Session.

Rule Details

This rule aims to prevent errors when using Publications and Subscriptions. It verifies Session is used in the correct environments.

The following patterns are considered warnings:


Session.set('foo')


Session.setDefault('foo')


Session.set('foo', true, 'bar')


if (Meteor.isServer) {
  Session.set('foo')
}


Session.get('foo', true)


Session.get()


Session.equals('foo')

The following patterns are not warnings:


Session.set('foo', true)


Session.setDefault('foo', true)


Session.get('foo')


Session.equals('foo', true)

Options

no-equal

By default this rule does not warn when trying to call Session.equal. Usually a call to Session.equals is meant instead. To warn when using Session.equal, configure the rule as


session: [2, "no-equal"]

With this configuration, the rule will warn on this pattern:


Session.equal('foo', 'bar')

When Not To Use It

Disable this rule if you are using no-session.

Further Reading