yannickcr/eslint-plugin-react

View on GitHub

Showing 710 of 710 total issues

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

            } 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        create: Components.detect((context, components) => {
          const defaults = { skipShapeProps: true, customValidators: [], ignore: [] };
          const configuration = Object.assign({}, defaults, context.options[0] || {});
      
          /**
      Severity: Minor
      Found in lib/rules/no-unused-prop-types.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

                  } 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 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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

              MemberExpression(node) {
                if (!isDefaultPropsDeclaration(node)) {
                  return;
                }
        
        
        Severity: Minor
        Found in lib/rules/jsx-sort-default-props.js and 1 other location - About 45 mins to fix
        lib/rules/sort-default-props.js on lines 171..177

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 50.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

              return function fix(fixer) {
                return fixer.replaceTextRange(
                  [node.range[0] - node.loc.start.column, node.range[0]],
                  indent
                );
        Severity: Minor
        Found in lib/rules/jsx-indent.js and 1 other location - About 45 mins to fix
        lib/rules/jsx-closing-tag-location.js on lines 125..130

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 50.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

              MemberExpression(node) {
                if (!isDefaultPropsDeclaration(node)) {
                  return;
                }
        
        
        Severity: Minor
        Found in lib/rules/sort-default-props.js and 1 other location - About 45 mins to fix
        lib/rules/jsx-sort-default-props.js on lines 177..183

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 50.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                values(components.list())
                  .filter((component) => mustBeValidated(component))
                  .forEach((component) => {
                    handleCustomValidators(component);
                  });
          Severity: Minor
          Found in lib/util/usedPropTypes.js and 1 other location - About 45 mins to fix
          lib/rules/no-unused-prop-types.js on lines 163..167

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                    if (astUtil.isNodeFirstInLine(context, node)) {
                      return fixer.replaceTextRange(
                        [node.range[0] - node.loc.start.column, node.range[0]],
                        indent
                      );
          Severity: Minor
          Found in lib/rules/jsx-closing-tag-location.js and 1 other location - About 45 mins to fix
          lib/rules/jsx-indent.js on lines 139..144

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  values(components.list())
                    .filter((component) => mustBeValidated(component))
                    .forEach((component) => {
                      reportUnusedPropTypes(component);
                    });
          Severity: Minor
          Found in lib/rules/no-unused-prop-types.js and 1 other location - About 45 mins to fix
          lib/util/usedPropTypes.js on lines 577..581

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            const messages = {
              typoPropTypeChain: 'Typo in prop type chain qualifier: {{name}}',
              typoPropType: 'Typo in declared prop type: {{name}}',
              typoStaticClassProp: 'Typo in static class property declaration',
              typoPropDeclaration: 'Typo in property declaration',
            Severity: Minor
            Found in lib/rules/no-typos.js and 1 other location - About 45 mins to fix
            lib/rules/jsx-no-literals.js on lines 37..46

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            const messages = {
              invalidPropValue: 'Invalid prop value: "{{text}}"',
              invalidPropValueInElement: 'Invalid prop value: "{{text}}" in {{element}}',
              noStringsInAttributes: 'Strings not allowed in attributes: "{{text}}"',
              noStringsInAttributesInElement: 'Strings not allowed in attributes: "{{text}}" in {{element}}',
            Severity: Minor
            Found in lib/rules/jsx-no-literals.js and 1 other location - About 45 mins to fix
            lib/rules/no-typos.js on lines 21..30

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      node.type === 'ObjectExpression'
                      && node.parent
                      && node.parent.parent
                      && node.parent.parent.type === 'VariableDeclarator'
              Severity: Minor
              Found in lib/rules/display-name.js and 1 other location - About 40 mins to fix
              lib/rules/display-name.js on lines 119..122

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      if (configuration === 'element') {
                        report(context, messages.preferPragma, 'preferPragma', {
                          node,
                          data: {
                            react: reactPragma,
              Severity: Minor
              Found in lib/rules/jsx-fragments.js and 1 other location - About 40 mins to fix
              lib/rules/jsx-fragments.js on lines 193..202

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                all: {
                  plugins: { react: plugin },
                  rules: configs.all.rules,
                  languageOptions: { parserOptions: configs.all.parserOptions },
                },
              Severity: Minor
              Found in index.js and 1 other location - About 40 mins to fix
              index.js on lines 102..106

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language