eslint-plugin-react-native
Advanced tools
Comparing version 4.1.0 to 5.0.0
@@ -102,3 +102,3 @@ /** | ||
function componentRule(rule, context) { | ||
function componentRule(rule, context, _node) { | ||
const sourceCode = context.getSourceCode(); | ||
@@ -169,7 +169,7 @@ const components = new Components(); | ||
*/ | ||
getParentComponent: function () { | ||
getParentComponent: function (_n) { | ||
return ( | ||
utils.getParentES6Component() | ||
|| utils.getParentES5Component() | ||
|| utils.getParentStatelessComponent() | ||
utils.getParentES6Component(_n) | ||
|| utils.getParentES5Component(_n) | ||
|| utils.getParentStatelessComponent(_n) | ||
); | ||
@@ -183,5 +183,5 @@ }, | ||
*/ | ||
getParentES5Component: function () { | ||
getParentES5Component: function (_n) { | ||
// eslint-disable-next-line react/destructuring-assignment | ||
let scope = context.getScope(); | ||
let scope = (context.sourceCode || context).getScope(_n); | ||
while (scope) { | ||
@@ -202,4 +202,4 @@ const node = scope.block && scope.block.parent && scope.block.parent.parent; | ||
*/ | ||
getParentES6Component: function () { | ||
let scope = context.getScope(); | ||
getParentES6Component: function (_n) { | ||
let scope = (context.sourceCode || context).getScope(_n); | ||
while (scope && scope.type !== 'class') { | ||
@@ -220,5 +220,5 @@ scope = scope.upper; | ||
*/ | ||
getParentStatelessComponent: function () { | ||
getParentStatelessComponent: function (_n) { | ||
// eslint-disable-next-line react/destructuring-assignment | ||
let scope = context.getScope(); | ||
let scope = (context.sourceCode || context).getScope(_n); | ||
while (scope) { | ||
@@ -271,3 +271,3 @@ const node = scope.block; | ||
let variableInScope; | ||
const { variables } = context.getScope(); | ||
const { variables } = (context.sourceCode || context).getScope(_node); | ||
for (i = 0, j = variables.length; i < j; i++) { // eslint-disable-line no-plusplus | ||
@@ -332,4 +332,4 @@ if (variables[i].name === variableName) { | ||
ClassProperty: function () { | ||
const node = utils.getParentComponent(); | ||
ClassProperty: function (_n) { | ||
const node = utils.getParentComponent(_n); | ||
if (!node) { | ||
@@ -348,4 +348,4 @@ return; | ||
FunctionExpression: function () { | ||
const node = utils.getParentComponent(); | ||
FunctionExpression: function (_n) { | ||
const node = utils.getParentComponent(_n); | ||
if (!node) { | ||
@@ -357,4 +357,4 @@ return; | ||
FunctionDeclaration: function () { | ||
const node = utils.getParentComponent(); | ||
FunctionDeclaration: function (_n) { | ||
const node = utils.getParentComponent(_n); | ||
if (!node) { | ||
@@ -366,4 +366,4 @@ return; | ||
ArrowFunctionExpression: function () { | ||
const node = utils.getParentComponent(); | ||
ArrowFunctionExpression: function (_n) { | ||
const node = utils.getParentComponent(_n); | ||
if (!node) { | ||
@@ -379,4 +379,4 @@ return; | ||
ThisExpression: function () { | ||
const node = utils.getParentComponent(); | ||
ThisExpression: function (_n) { | ||
const node = utils.getParentComponent(_n); | ||
if (!node || !/Function/.test(node.type)) { | ||
@@ -393,3 +393,3 @@ return; | ||
} | ||
const parentNode = utils.getParentComponent(); | ||
const parentNode = utils.getParentComponent(node); | ||
if (!parentNode) { | ||
@@ -396,0 +396,0 @@ return; |
@@ -14,4 +14,4 @@ /** | ||
*/ | ||
function markVariableAsUsed(context, name) { | ||
let scope = context.getScope(); | ||
function markVariableAsUsed(context, name, _node) { | ||
let scope = (context.sourceCode || context).getScope(_node); | ||
let variables; | ||
@@ -62,2 +62,9 @@ let i; | ||
function getScope(context, node) { | ||
if (context.sourceCode && context.sourceCode.getScope) { | ||
return context.sourceCode.getScope(node); | ||
} | ||
return context.getScope(); | ||
} | ||
/** | ||
@@ -72,4 +79,4 @@ * List all variable in a given scope | ||
*/ | ||
function variablesInScope(context) { | ||
let scope = context.getScope(); | ||
function variablesInScope(context, _n) { | ||
let scope = getScope(context, _n); | ||
let { variables } = scope; | ||
@@ -76,0 +83,0 @@ |
{ | ||
"name": "eslint-plugin-react-native", | ||
"version": "4.1.0", | ||
"version": "5.0.0", | ||
"author": "Tom Hastjarjanto <tom@intellicode.nl>", | ||
@@ -39,3 +39,3 @@ "description": "React Native specific linting rules for ESLint", | ||
"peerDependencies": { | ||
"eslint": "^3.17.0 || ^4 || ^5 || ^6 || ^7 || ^8" | ||
"eslint": "^3.17.0 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9" | ||
}, | ||
@@ -42,0 +42,0 @@ "keywords": [ |
53115
1470