yannickcr/eslint-plugin-react

View on GitHub

Showing 502 of 700 total issues

Consider simplifying this complex logical expression.
Open

        if (
          relatedComponent
            && (componentUtil.isES6Component(relatedComponent.node, context) || (
              relatedComponent.node.type !== 'ClassDeclaration' && utils.isReturningJSX(relatedComponent.node)))
            && (node.parent && node.parent.type === 'AssignmentExpression' && node.parent.right)
Severity: Major
Found in lib/rules/no-typos.js - About 1 hr to fix

    Function loopNodes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    function loopNodes(nodes) {
      for (let i = nodes.length - 1; i >= 0; i--) {
        if (nodes[i].type === 'ReturnStatement') {
          return nodes[i];
        }
    Severity: Minor
    Found in lib/util/ast.js - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function isPropTypesUsageByMemberExpression has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    function isPropTypesUsageByMemberExpression(context, node, utils, checkAsyncSafeLifeCycles) {
      const unwrappedObjectNode = ast.unwrapTSAsExpression(node.object);
    
      if (isInClassComponent(context, node)) {
        // this.props.*
    Severity: Minor
    Found in lib/util/usedPropTypes.js - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function inLifeCycleMethod has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    function inLifeCycleMethod(context, node, checkAsyncSafeLifeCycles) {
      let scope = getScope(context, node);
      while (scope) {
        if (scope.block && scope.block.parent && scope.block.parent.key) {
          const name = scope.block.parent.key.name;
    Severity: Minor
    Found in lib/util/usedPropTypes.js - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function checkAttribute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    function checkAttribute(context, node) {
      const attribute = node.name.name;
    
      const parentNodeName = node.parent.name.name;
      if (!COMPONENT_ATTRIBUTE_MAP.has(attribute) || !COMPONENT_ATTRIBUTE_MAP.get(attribute).has(parentNodeName)) {
    Severity: Minor
    Found in lib/rules/no-invalid-html-attribute.js - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      create(context) {
        return {
          CallExpression(node) {
            if (isCreateElement(context, node) && node.arguments.length > 0 && node.arguments[0].type === 'Literal') {
              const name = node.arguments[0].value;
    Severity: Minor
    Found in lib/rules/no-namespace.js - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function validateReservedFirstConfig has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    function validateReservedFirstConfig(context, reservedFirst) {
      if (reservedFirst) {
        if (Array.isArray(reservedFirst)) {
          // Only allow a subset of reserved words in customized lists
          const nonReservedWords = reservedFirst.filter((word) => !isReservedPropName(
    Severity: Minor
    Found in lib/rules/jsx-sort-props.js - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function sorter has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function sorter(a, b, context, ignoreCase, requiredFirst, callbacksLast, noSortAlphabetically) {
    Severity: Major
    Found in lib/util/propTypesSort.js - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      if (name) {
                        classInfo.aliases.add(name);
                      } else if (prop.value.type === 'ObjectPattern') {
                        handleStateDestructuring(prop.value);
                      }
      Severity: Major
      Found in lib/rules/no-unused-state.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if (returnTypeFunction.length === 0) {
                        // Cannot find identifier in current scope. It might be an exported type.
                        this.shouldIgnorePropTypes = true;
                        return;
                      }
        Severity: Major
        Found in lib/util/propTypes.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          if (isFunctionType(func)) {
                            let res = func.body;
                            if (res.type === 'BlockStatement') {
                              res = astUtil.findReturnStatement(func);
                              if (res) {
          Severity: Major
          Found in lib/util/propTypes.js - About 45 mins to fix

            Function getKeyValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function getKeyValue(context, node) {
              if (node.type === 'ObjectTypeProperty') {
                const tokens = getFirstTokens(context, node, 2);
                return (tokens[0].value === '+' || tokens[0].value === '-'
                  ? tokens[1].value
            Severity: Minor
            Found in lib/util/ast.js - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Avoid deeply nested control flow statements.
            Open

                      if (!siblings.has(lastValue)) {
                        const message = secondValue ? messages.notPaired : messages.notAlone;
                        const messageId = secondValue ? 'notPaired' : 'notAlone';
                        report(context, message, messageId, {
                          node,
            Severity: Major
            Found in lib/rules/no-invalid-html-attribute.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            if (c === entities[j]) {
                              report(context, messages.unescapedEntity, 'unescapedEntity', {
                                node,
                                loc: { line: i, column: start + index },
                                data: {
              Severity: Major
              Found in lib/rules/no-unescaped-entities.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            } else if (c === entities[j].char) {
                              report(context, messages.unescapedEntityAlts, 'unescapedEntityAlts', {
                                node,
                                loc: { line: i, column: start + index },
                                data: {
                Severity: Major
                Found in lib/rules/no-unescaped-entities.js - About 45 mins to fix

                  Function validateAfterOpening has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function validateAfterOpening(context, node, option) {
                    const sourceCode = getSourceCode(context);
                    const openingToken = sourceCode.getTokenBefore(node.name);
                  
                    if (option === 'allow-multiline') {
                  Severity: Minor
                  Found in lib/rules/jsx-tag-spacing.js - About 45 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Avoid deeply nested control flow statements.
                  Open

                            if (attributeline + 1 === commentline && nextAttribute) {
                              attributeMap.set(attribute, { end: nextAttribute.range[1], hasComment: true });
                              addtoSortableAttributeGroups(attribute);
                              i += 1;
                            } else if (attributeline === commentline) {
                  Severity: Major
                  Found in lib/rules/jsx-sort-props.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if (typeof relAttribute.value.expression.value === 'string') {
                                          const parts = relAttribute.value.expression.value
                                            .split('noreferrer')
                                            .filter(Boolean);
                                          return fixer.replaceText(relAttribute.value.expression, `"${parts.concat('noreferrer').join(' ')}"`);
                    Severity: Major
                    Found in lib/rules/jsx-no-target-blank.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                              } else if (comment.length > 1 && attributeline + 1 === comment[1].loc.start.line && nextAttribute) {
                                const commentNextAttribute = sourceCode.getCommentsAfter(nextAttribute);
                                attributeMap.set(attribute, { end: nextAttribute.range[1], hasComment: true });
                                if (
                                  commentNextAttribute.length === 1
                      Severity: Major
                      Found in lib/rules/jsx-sort-props.js - About 45 mins to fix

                        Function validateBeforeSelfClosing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function validateBeforeSelfClosing(context, node, option) {
                          const sourceCode = getSourceCode(context);
                          const leftToken = getTokenBeforeClosingBracket(node);
                          const closingSlash = sourceCode.getTokenAfter(leftToken);
                        
                        
                        Severity: Minor
                        Found in lib/rules/jsx-tag-spacing.js - About 45 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Severity
                        Category
                        Status
                        Source
                        Language