mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
This further gets rid of all environment checks, keeping it simple no longer support environments
29 lines
803 B
JavaScript
29 lines
803 B
JavaScript
/**
|
|
* @fileoverview Prevent usage of Meteor.setTimeout with zero delay
|
|
* @author Dominik Ferber
|
|
*/
|
|
|
|
import { isMeteorCall } from '../util/ast'
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Rule Definition
|
|
// -----------------------------------------------------------------------------
|
|
|
|
module.exports = context => ({
|
|
CallExpression: (node) => {
|
|
if (isMeteorCall(node, 'setTimeout')) {
|
|
if (node.arguments.length === 1) {
|
|
context.report(node, 'Implicit timeout of 0')
|
|
} else if (
|
|
node.arguments.length > 1 &&
|
|
node.arguments[1].type === 'Literal' &&
|
|
node.arguments[1].value === 0
|
|
) {
|
|
context.report(node, 'Timeout of 0. Use `Meteor.defer` instead')
|
|
}
|
|
}
|
|
},
|
|
})
|
|
|
|
module.exports.schema = []
|