mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
feat(audit-arguments-check): audit when fn is defined by computed props as well
This commit is contained in:
@@ -55,12 +55,14 @@ module.exports = function (context) {
|
||||
CallExpression: (node) => {
|
||||
if (
|
||||
node.callee.type === 'MemberExpression' &&
|
||||
!node.callee.computed &&
|
||||
node.callee.object.type === 'Identifier' && node.callee.object.name === 'Meteor'
|
||||
) {
|
||||
|
||||
// publications
|
||||
if (node.callee.property.name === 'publish') {
|
||||
if (
|
||||
(node.callee.property.type === 'Identifier' && node.callee.property.name === 'publish') ||
|
||||
(node.callee.property.type === 'Literal' && node.callee.property.value === 'publish')
|
||||
) {
|
||||
if (node.arguments.length < 2) {
|
||||
return;
|
||||
}
|
||||
@@ -69,7 +71,10 @@ module.exports = function (context) {
|
||||
}
|
||||
|
||||
// method
|
||||
if (node.callee.property.name === 'methods') {
|
||||
if (
|
||||
(node.callee.property.type === 'Identifier' && node.callee.property.name === 'methods') ||
|
||||
(node.callee.property.type === 'Literal' && node.callee.property.value === 'methods')
|
||||
) {
|
||||
if (
|
||||
node.arguments.length > 0 &&
|
||||
node.arguments[0].type === 'ObjectExpression'
|
||||
|
||||
@@ -32,6 +32,7 @@ ruleTester.run('audit-argument-checks', rule, {
|
||||
|
||||
'Meteor.methods()',
|
||||
'Meteor.methods({ x: function () {} })',
|
||||
'Meteor["methods"]({ x: function () {} })',
|
||||
'Meteor.methods({ x: true })',
|
||||
{code: 'Meteor.methods({ x () {} })', parser: 'babel-eslint'},
|
||||
'Meteor.methods({ x: function (bar) { check(bar, Match.Any); } })',
|
||||
@@ -46,6 +47,13 @@ ruleTester.run('audit-argument-checks', rule, {
|
||||
type: 'Identifier'
|
||||
}]
|
||||
},
|
||||
{
|
||||
code: 'Meteor["publish"]("foo", function (bar) { foo(); })',
|
||||
errors: [{
|
||||
message: 'bar is not checked',
|
||||
type: 'Identifier'
|
||||
}]
|
||||
},
|
||||
{
|
||||
code: 'Meteor.publish("foo", function (bar) {})',
|
||||
errors: [{
|
||||
|
||||
Reference in New Issue
Block a user