Update invariant to version 2.1.2 🚀
ESLint-plugin-Meteor
Meteor specific linting rules for ESLint
This gif shows integration of ESLint-plugin-Meteor into Atom with linter and linter-eslint. Find out more in the setup guide.
Installation
Install ESLint either locally or globally.
$ npm install eslint
If you installed ESLint globally, you have to install Meteor plugin globally too. Otherwise, install it locally.
$ npm install eslint-plugin-meteor
Configuration
Add plugins section and specify ESLint-plugin-Meteor as a plugin.
{
"plugins": [
"meteor"
]
}
Finally, enable all of the rules that you would like to use.
{
"rules": {
// Core API
"meteor/globals": 2,
"meteor/core": 2,
"meteor/pubsub": 2,
"meteor/methods": 2,
"meteor/check": 2,
"meteor/connections": 2,
"meteor/collections": 2,
// Best Practices
"meteor/audit-argument-checks": 2,
"meteor/no-session": 2,
"meteor/no-blaze-lifecycle-assignment": 2,
"meteor/no-zero-timeout": 2
}
}
For a more thorough introduction, read setting up a Meteor project. A complete example of how to set up ESLint-plugin-Meteor in a Meteor project can be found here.
List of supported rules
Core API
- globals: Definitions for global Meteor variables based on environment
- core: Meteor Core API
- pubsub: Prevent misusage of Publish and Subscribe
- methods: Prevent misusage of methods
- check: Core API for check and Match
- connections: Core API for connections
- collections: Core API for collections
- session: Core API for Session
Best Practices
- audit-argument-checks: Enforce check on all arguments passed to methods and publish functions
- no-session: Prevent usage of Session
- no-blaze-lifecycle-assignment: Prevent deprecated template lifecycle callback assignments
- no-zero-timeout: Prevent usage of Meteor.setTimeout with zero delay
To Do
- Implement basic rules for Meteor API
Limitations
Executor checks
Executors (client, browser, server, cordova) are detected by looking at the location of the linted file relative to the Meteor project root. Locus checks such as if (Meteor.isClient) {..} are respected as well. They may be any logical expression as long as all expressions consist purely of Meteor.isClient, Meteor.isServer and Meteor.isCordova. So, this would work
if ((Meteor.isClient || Meteor.isCordova) && !Meteor.isServer) { .. }
If a test in a locus check is paired with any other expression that specific locus check will be ignored.
Package files
ESLint-plugin-Meteor is not able to detect where files in inlined packages are going to be executed. It needs hints to work around this. See this guide for details.
Contributing
Read about set up of the development environment.
Thanks
This plugin is inspired by eslint-plugin-react.
License
ESLint-plugin-Meteor is licensed under the MIT License.