Changeset View
Changeset View
Standalone View
Standalone View
build/arclint/configs/eslintrules/no-in-world-check.js
/** | |||||
* @fileoverview Rule to check Mirage interface usage. | |||||
*/ | |||||
"use strict"; | |||||
module.exports = { | |||||
"meta": { | |||||
"type": "suggestion", | |||||
"docs": { | |||||
"description": "disallow unnecessary semicolons", | |||||
"category": "Possible Errors", | |||||
"recommended": true, | |||||
"url": "https://eslint.org/docs/rules/no-extra-semi" | |||||
}, | |||||
"fixable": "code", | |||||
"schema": [] // no options | |||||
}, | |||||
"create": function(context) { | |||||
return { | |||||
"CallExpression[callee.property.name='QueryInterface']": function(node) { | |||||
// Find all usage of this variable. | |||||
if (node.arguments[0].name === "SYSTEM_ENTITY" || | |||||
node.arguments[1].name !== "IID_Position") | |||||
return; | |||||
let variable = context.getDeclaredVariables(node.parent)[0]; | |||||
if (!variable) | |||||
return; | |||||
let usages = variable.references.filter(x => x.identifier.parent.type === "MemberExpression"); | |||||
if (!usages.length) | |||||
return; | |||||
let checkBefore = usages.findIndex(x => [ | |||||
"GetPosition", "GetPosition2D", | |||||
"GetPreviousPosition", "GetPreviousPosition2D" | |||||
].indexOf(x.identifier.parent.property.name) !== -1); | |||||
if (checkBefore === -1) | |||||
return; | |||||
let checkAt = usages.findIndex(x => x.identifier.parent.property.name === "IsInWorld"); | |||||
if (checkAt !== -1 && checkAt < checkBefore) | |||||
return; | |||||
context.report({ | |||||
"node": usages[checkBefore].identifier, | |||||
"message": "Call to a position-related method without checking IsInWorld." | |||||
}); | |||||
} | |||||
}; | |||||
} | |||||
}; |
Wildfire Games · Phabricator