yannickcr/eslint-plugin-react

View on GitHub

Showing 710 of 710 total issues

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

    FunctionExpression(node) {
      if (node.async && node.generator) {
        components.add(node, 0);
        return;
      }
Severity: Major
Found in lib/util/Components.js and 1 other location - About 2 hrs to fix
lib/util/Components.js on lines 888..899

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 78.

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 (firstArg && firstArg.type === 'TSTypeReference') {
        const propType = typeAnnotations.get(firstArg.typeName.name)
          && typeAnnotations.get(firstArg.typeName.name)[0];
        if (propType && propType.members) {
          checkSorted(propType.members);
Severity: Major
Found in lib/rules/sort-prop-types.js and 1 other location - About 2 hrs to fix
lib/rules/sort-prop-types.js on lines 223..233

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 77.

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

    } else if (option === 'proportional-always' && node.type === 'JSXOpeningElement' && adjacent !== (node.loc.start.line === node.loc.end.line)) {
      report(context, messages.beforeCloseNeedSpace, 'beforeCloseNeedSpace', {
        node,
        loc: {
          start: leftToken.loc.end,
Severity: Major
Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 2 hrs to fix
lib/rules/jsx-tag-spacing.js on lines 225..247

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 77.

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

      } else if (firstArg && firstArg.type === 'GenericTypeAnnotation') {
        const propType = typeAnnotations.get(firstArg.id.name)
          && typeAnnotations.get(firstArg.id.name)[0];
        if (propType && propType.properties) {
          checkSorted(propType.properties);
Severity: Major
Found in lib/rules/sort-prop-types.js and 1 other location - About 2 hrs to fix
lib/rules/sort-prop-types.js on lines 213..233

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 77.

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

    } else if (option === 'always' && adjacent) {
      report(context, messages.beforeCloseNeedSpace, 'beforeCloseNeedSpace', {
        node,
        loc: {
          start: leftToken.loc.end,
Severity: Major
Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 2 hrs to fix
lib/rules/jsx-tag-spacing.js on lines 236..247

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 77.

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

Function validateClosingSlash has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function validateClosingSlash(context, node, option) {
  const sourceCode = getSourceCode(context);

  let adjacent;

Severity: Minor
Found in lib/rules/jsx-tag-spacing.js - About 2 hrs 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 JSXOpeningElement has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      JSXOpeningElement(node) {
        const openingElementName = node.name;
        if (openingElementName.type !== 'JSXMemberExpression') {
          // Has no member
          return;
Severity: Major
Found in lib/rules/jsx-no-constructed-context-values.js - About 2 hrs to fix

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

      meta: {
        docs: {
          description: 'Disallow using string references',
          category: 'Best Practices',
          recommended: true,
    Severity: Major
    Found in lib/rules/no-string-refs.js and 3 other locations - About 2 hrs to fix
    lib/rules/forbid-foreign-prop-types.js on lines 18..39
    lib/rules/jsx-no-duplicate-props.js on lines 22..41
    lib/rules/jsx-no-undef.js on lines 23..42

    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 76.

    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 4 locations. Consider refactoring.
    Open

      meta: {
        docs: {
          description: 'Disallow duplicate properties in JSX',
          category: 'Possible Errors',
          recommended: true,
    Severity: Major
    Found in lib/rules/jsx-no-duplicate-props.js and 3 other locations - About 2 hrs to fix
    lib/rules/forbid-foreign-prop-types.js on lines 18..39
    lib/rules/jsx-no-undef.js on lines 23..42
    lib/rules/no-string-refs.js on lines 24..43

    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 76.

    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 4 locations. Consider refactoring.
    Open

      meta: {
        docs: {
          description: 'Disallow undeclared variables in JSX',
          category: 'Possible Errors',
          recommended: true,
    Severity: Major
    Found in lib/rules/jsx-no-undef.js and 3 other locations - About 2 hrs to fix
    lib/rules/forbid-foreign-prop-types.js on lines 18..39
    lib/rules/jsx-no-duplicate-props.js on lines 22..41
    lib/rules/no-string-refs.js on lines 24..43

    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 76.

    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 4 locations. Consider refactoring.
    Open

      meta: {
        docs: {
          description: 'Disallow using another component\'s propTypes',
          category: 'Best Practices',
          recommended: false,
    Severity: Major
    Found in lib/rules/forbid-foreign-prop-types.js and 3 other locations - About 2 hrs to fix
    lib/rules/jsx-no-duplicate-props.js on lines 22..41
    lib/rules/jsx-no-undef.js on lines 23..42
    lib/rules/no-string-refs.js on lines 24..43

    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 76.

    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

    Function check has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function check(node, type) {
          if (!node || !jsxUtil.isJSX(node)) {
            return;
          }
    
    
    Severity: Major
    Found in lib/rules/jsx-wrap-multilines.js - About 2 hrs to fix

      Function isDestructuredFromPragmaImport has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function isDestructuredFromPragmaImport(context, node, variable) {
        const pragma = pragmaUtil.getFromContext(context);
        const variableInScope = variableUtil.getVariableFromContext(context, node, variable);
        if (variableInScope) {
          const latestDef = variableUtil.getLatestVariableDefinition(variableInScope);
      Severity: Major
      Found in lib/util/isDestructuredFromPragmaImport.js - About 2 hrs to fix

        Function checkPropValue has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function checkPropValue(node) {
              if (isArrayIndex(node)) {
                // key={bar}
                report(context, messages.noArrayIndex, 'noArrayIndex', {
                  node,
        Severity: Major
        Found in lib/rules/no-array-index-key.js - About 2 hrs to fix

          Function create has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            create: Components.detect((context, components) => {
              /**
               * Mark a return statement as present
               * @param {ASTNode} node The AST node being checked.
               */
          Severity: Major
          Found in lib/rules/require-render-return.js - About 2 hrs to fix

            File forbid-prop-types.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /**
             * @fileoverview Forbid certain propTypes
             */
            
            'use strict';
            Severity: Minor
            Found in lib/rules/forbid-prop-types.js - About 2 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                      if (
                        (lastChild || nextChild)
                        && (!lastChild || isInlineElement(lastChild))
                        && (child && (child.type === 'Literal' || child.type === 'JSXText'))
                        && (!nextChild || isInlineElement(nextChild))
              Severity: Critical
              Found in lib/rules/jsx-child-element-spacing.js - About 2 hrs to fix

                Function create has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  create(context) {
                    const config = context.options[0] || {};
                    const validStrategies = new Set(config.validStrategies || DEFAULT_VALID_STRATEGIES);
                    const fixStrategy = find(from(validStrategies), () => true);
                
                
                Severity: Minor
                Found in lib/rules/jsx-no-leaked-render.js - About 2 hrs to fix

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

                      function isFunctionInClass(node) {
                        let blockNode;
                        let scope = getScope(context, node);
                        while (scope) {
                          blockNode = scope.block;
                  Severity: Major
                  Found in lib/rules/require-optimization.js and 1 other location - About 2 hrs to fix
                  lib/rules/static-property-placement.js on lines 104..116

                  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 75.

                  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

                      function isContextInClass(node) {
                        let blockNode;
                        let scope = getScope(context, node);
                        while (scope) {
                          blockNode = scope.block;
                  Severity: Major
                  Found in lib/rules/static-property-placement.js and 1 other location - About 2 hrs to fix
                  lib/rules/require-optimization.js on lines 159..171

                  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 75.

                  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