yannickcr/eslint-plugin-react

View on GitHub

Showing 502 of 700 total issues

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

function checkProps(context, node) {
  let sandboxAttributeFound = false;
  if (node.arguments.length > 1) {
    const props = node.arguments[1];
    const sandboxProp = props.properties && props.properties.find((x) => x.type === 'Property' && x.key.name === 'sandbox');
Severity: Minor
Found in lib/rules/iframe-missing-sandbox.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 (targetTestCond === relTestCond) {
            const targetBlankIndex = [targetValue.expression.consequent.value, targetValue.expression.alternate.value].indexOf('_blank');
            return relValues[targetBlankIndex];
          }
Severity: Major
Found in lib/rules/jsx-no-target-blank.js - About 45 mins to fix

    Function ruleFixer has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function ruleFixer(context, fixStrategy, fixer, reportedNode, leftNode, rightNode) {
    Severity: Minor
    Found in lib/rules/jsx-no-leaked-render.js - About 45 mins to fix

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

        create(context) {
          const options = context.options;
          const hasLegacyOption = Array.isArray(options[0]);
          const legacyOptions = hasLegacyOption ? options[0] : [];
          // eslint-disable-next-line no-nested-ternary
      Severity: Minor
      Found in lib/rules/jsx-no-script-url.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

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

        create(context) {
          const config = context.options[0] || {};
          const checkAliases = config.checkAliases || false;
      
          const isApplicable = testReactVersion(context, '>= 16.3.0');
      Severity: Minor
      Found in lib/rules/no-unsafe.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

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

        create: Components.detect((context, components, utils) => {
          /**
           * Checks if the component is valid
           * @param {Object} component The component to process
           * @returns {Boolean} True if the component is valid, false if not.
      Severity: Minor
      Found in lib/rules/no-set-state.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 (method.staticVariable) {
                  methodGroupIndexes.push(groupIndex);
                }
      Severity: Major
      Found in lib/rules/sort-comp.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                } else if (currentGroup === 'static-methods') {
                  if (method.staticMethod) {
                    methodGroupIndexes.push(groupIndex);
                  }
                } else if (currentGroup === 'instance-variables') {
        Severity: Major
        Found in lib/rules/sort-comp.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                  if (firstArg.properties) {
                    checkSorted(firstArg.properties);
                  }
          Severity: Major
          Found in lib/rules/sort-prop-types.js - About 45 mins to fix

            Consider simplifying this complex logical expression.
            Open

              if (
                node.expression
                && node.expression.type === 'AssignmentExpression'
                && node.expression.operator === '='
                && node.expression.right.type === 'CallExpression'
            Severity: Major
            Found in lib/util/isCreateContext.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                  if (
                    unwrappedParentCalleeNode
                    && unwrappedParentCalleeNode.property
                    && unwrappedParentCalleeNode.property.name === 'setState'
                    // Make sure we are in the updater not the callback
              Severity: Major
              Found in lib/util/usedPropTypes.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                            if (((n.type === 'AssignmentExpression') && propsUtil.isPropTypesDeclaration(n.left))
                              || ((n.type === 'ClassProperty' || n.type === 'PropertyDefinition' || n.type === 'Property') && propsUtil.isPropTypesDeclaration(n))) {
                              // Found a propType used inside of another propType. This is not considered usage, we'll still validate
                              // this component.
                              isUsedInPropTypes = true;
                Severity: Major
                Found in lib/util/propTypes.js - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                        if (
                          !component.node.parent
                          || component.node.parent.type !== 'VariableDeclarator'
                          || !component.node.parent.id
                          || component.node.parent.id.type !== 'Identifier'
                  Severity: Major
                  Found in lib/rules/boolean-prop-naming.js - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                          } else if (
                            expressionType === 'TemplateLiteral'
                            && expression.expressions.length === 0
                            && expression.quasis[0].value.raw.indexOf('\n') === -1
                            && !isStringWithTrailingWhiteSpaces(expression.quasis[0].value.raw)
                    Severity: Major
                    Found in lib/rules/jsx-curly-brace-presence.js - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                              if (
                                classComponent && destructuringClass && configuration === 'never'
                                && !(ignoreClassFields && (node.parent.type === 'ClassProperty' || node.parent.type === 'PropertyDefinition'))
                              ) {
                                report(context, messages.noDestructAssignment, 'noDestructAssignment', {
                      Severity: Major
                      Found in lib/rules/destructuring-assignment.js - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if (
                                  !isRender
                                  || (allowNull && (isReturningJSX || isReturningNull))
                                  || (!allowNull && isReturningJSX)
                                ) {
                        Severity: Major
                        Found in lib/rules/prefer-stateless-function.js - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  if (
                                    SFCComponent
                                    && destructuringSFC
                                    && configuration === 'always'
                                    && destructureInSignature === 'always'
                          Severity: Major
                          Found in lib/rules/destructuring-assignment.js - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                      if (isSingleGetter && isUseStateCalledWithSingleArgument) {
                                        const useMemoReactImportSpecifier = namedReactImports
                                          && namedReactImports.find((specifier) => specifier.imported.name === 'useMemo');
                            
                                        let useMemoCode;
                            Severity: Major
                            Found in lib/rules/hook-use-state.js - About 40 mins to fix

                              Function fixByTrimmingWhitespace has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  function fixByTrimmingWhitespace(fixer, fromLoc, toLoc, mode, spacing) {
                              Severity: Minor
                              Found in lib/rules/jsx-curly-spacing.js - About 35 mins to fix

                                Function checkLiteralValueNode has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                function checkLiteralValueNode(context, attributeName, node, parentNode, parentNodeName) {
                                Severity: Minor
                                Found in lib/rules/no-invalid-html-attribute.js - About 35 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language