eslint-plugin-react-func
Advanced tools
Comparing version
@@ -165,14 +165,6 @@ /** | ||
function checkIsJSXElement(item) { | ||
const type = lodash.get(item, 'argument.type'); | ||
let isContainJSXElement = isContainJSX(type); | ||
function checkIsJSXElement(node) { | ||
const functionText = sourceCode.getText(node) || ''; | ||
if (type === 'ConditionalExpression') { | ||
const consequentType = lodash.get(item, 'argument.consequent.type'); | ||
const alternateType = lodash.get(item, 'argument.alternate.type'); | ||
if (isContainJSX(consequentType) || isContainJSX(alternateType)) isContainJSXElement = true; | ||
} | ||
return isContainJSXElement; | ||
return (functionText.includes('<') && (functionText.includes('/>') || functionText.includes('</'))); | ||
} | ||
@@ -184,13 +176,3 @@ | ||
function getFunctionBodyRecursively(node) { | ||
const body = lodash.get(node, 'body.body', []); | ||
const isValidBody = Array.isArray(body); | ||
const isNestBody = !isValidBody && typeof body === 'object'; | ||
if (isValidBody) return body; | ||
if (isNestBody) return getFunctionBodyRecursively(body); | ||
} | ||
function isReactEle(node) { | ||
const body = getFunctionBodyRecursively(node); | ||
const bodyType = lodash.get(node, 'body.type', ''); | ||
@@ -201,3 +183,3 @@ const keyName = lodash.get(node, 'key.name', ''); | ||
const isClassComponent = keyName === 'render'; | ||
const isJSXElement = isContainJSX(bodyType) || body.some(checkIsJSXElement); | ||
const isJSXElement = isContainJSX(bodyType) || checkIsJSXElement(node); | ||
const isCustomHook = checkIsCustomHook(functionName) || checkIsCustomHook(parentName); | ||
@@ -296,7 +278,8 @@ | ||
} | ||
lineCount++; | ||
} | ||
lineCount = lineCount - argumentsLineNum; | ||
const baseFunctionLineNum = 2 | ||
lineCount = lineCount - argumentsLineNum - baseFunctionLineNum; | ||
@@ -303,0 +286,0 @@ const isOverLength = lineCount > maxLines; |
{ | ||
"name": "eslint-plugin-react-func", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"description": "max lines per function for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
23335
-2.9%499
-2.54%