mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
fix(pubsub): Remove publish handler object from Arrow Functions
Arrow functions can not access the publish handler object. Do not warn in them.
This commit is contained in:
@@ -59,7 +59,7 @@ module.exports = getMeta => context => {
|
||||
noPublishOnClient(node)
|
||||
} else {
|
||||
expectTwoArguments(node)
|
||||
if (node.arguments.length >= 2) {
|
||||
if (node.arguments.length >= 2 && node.arguments[1].type !== 'ArrowFunctionExpression') {
|
||||
markAsMeteorPublicationFn(node.arguments[1])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,18 +23,16 @@ const commonValidTests = [
|
||||
`if (Meteor.isCordova) { Meteor.subscribe('foo', { bar: true }) }`,
|
||||
`if (Meteor.isServer) { Meteor.publish('foo', function () {}) }`,
|
||||
`if (Meteor.isServer) { Meteor.publish('foo', function (a) {}) }`,
|
||||
{
|
||||
code: `if (Meteor.isServer) { Meteor.publish('foo', (a) => { return [] }) }`,
|
||||
parser: 'babel-eslint'
|
||||
},
|
||||
{
|
||||
code: `
|
||||
if (Meteor.isServer) {
|
||||
Meteor.publish('foo', () => {
|
||||
Meteor.publish('foo', (a) => {
|
||||
|
||||
// no publish handler object available in arrow functions,
|
||||
// but valid anyways
|
||||
return []
|
||||
})
|
||||
}
|
||||
`,
|
||||
}`,
|
||||
parser: 'babel-eslint'
|
||||
},
|
||||
`
|
||||
@@ -126,7 +124,18 @@ ruleTester.run('pubsub - universal', rule(() => ({env: UNIVERSAL})), {
|
||||
Meteor.subscribe() // not checked because unreachable
|
||||
}
|
||||
}
|
||||
`
|
||||
`,
|
||||
{
|
||||
code: `
|
||||
if (Meteor.isServer) {
|
||||
Meteor.publish('foo', () => {
|
||||
this.userId() // valid because this is not a publication fn
|
||||
return []
|
||||
})
|
||||
}
|
||||
`,
|
||||
parser: 'babel-eslint'
|
||||
}
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user