yannickcr/eslint-plugin-react

View on GitHub

Showing 710 of 710 total issues

Function checkSorted has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function checkSorted(declarations) {
      // Declarations will be `undefined` if the `shape` is not a literal. For
      // example, if it is a propType imported from another file.
      if (!declarations) {
        return;
Severity: Major
Found in lib/rules/sort-prop-types.js - About 3 hrs to fix

    File ast.js has 291 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * @fileoverview Utility functions for AST
     */
    
    'use strict';
    Severity: Minor
    Found in lib/util/ast.js - About 3 hrs to fix

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

              if (node.parent.type === 'ArrowFunctionExpression' && node.parent.parent.type === 'AssignmentExpression' && !isPropertyAssignment && utils.isReturningJSXOrNull(node)) {
                if (isFirstLetterCapitalized(node.parent.parent.left.name)) {
                  return node;
                }
                return undefined;
      Severity: Major
      Found in lib/util/Components.js and 1 other location - About 2 hrs to fix
      lib/util/Components.js on lines 537..542

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

      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 (node.parent.type === 'ArrowFunctionExpression' && node.parent.parent.type === 'Property' && !isPropertyAssignment && utils.isReturningJSXOrNull(node)) {
                if (isFirstLetterCapitalized(node.parent.parent.key.name)) {
                  return node;
                }
                return undefined;
      Severity: Major
      Found in lib/util/Components.js and 1 other location - About 2 hrs to fix
      lib/util/Components.js on lines 529..534

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

      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

                    {
                      type: 'object',
                      properties: {
                        propName: { type: 'string' },
                        allowedFor: {
      Severity: Major
      Found in lib/rules/forbid-component-props.js and 1 other location - About 2 hrs to fix
      lib/rules/forbid-component-props.js on lines 88..105

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

      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

                    {
                      type: 'object',
                      properties: {
                        propNamePattern: { type: 'string' },
                        allowedFor: {
      Severity: Major
      Found in lib/rules/forbid-component-props.js and 1 other location - About 2 hrs to fix
      lib/rules/forbid-component-props.js on lines 46..63

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

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

        create(context) {
          const pragma = pragmaUtil.getFromContext(context);
          const deprecated = getDeprecated(pragma);
      
          function isDeprecated(method) {
      Severity: Minor
      Found in lib/rules/no-deprecated.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 create has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        create(context) {
          const configuration = context.options[0] || {};
          const allowAllCaps = configuration.allowAllCaps || false;
          const allowLeadingUnderscore = configuration.allowLeadingUnderscore || false;
          const allowNamespace = configuration.allowNamespace || false;
      Severity: Minor
      Found in lib/rules/jsx-pascal-case.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

      File jsx-indent.js has 287 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * @fileoverview Validate JSX indentation
       * @author Yannick Croissant
      
       * This rule has been ported and modified from eslint and nodeca.
      Severity: Minor
      Found in lib/rules/jsx-indent.js - About 2 hrs to fix

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

          create(context) {
            const jsxElementParents = new Set();
        
            function isBlockCommentInCurlyBraces(element) {
              const elementRawValue = getText(context, element);
        Severity: Major
        Found in lib/rules/jsx-newline.js - About 2 hrs to fix

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

                  if (
                    isNever(configuration, exceptions, propName)
                    && configObject.assumeUndefinedIsFalse
                    && value
                    && value.type === 'JSXExpressionContainer'
          Severity: Major
          Found in lib/rules/jsx-boolean-value.js and 1 other location - About 2 hrs to fix
          lib/rules/jsx-boolean-value.js on lines 133..148

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

          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 (
                    isNever(configuration, exceptions, propName)
                    && value
                    && value.type === 'JSXExpressionContainer'
                    && value.expression.value === true
          Severity: Major
          Found in lib/rules/jsx-boolean-value.js and 1 other location - About 2 hrs to fix
          lib/rules/jsx-boolean-value.js on lines 149..165

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

          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 searchDeclarationByName has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              searchDeclarationByName(node) {
                let typeName;
                if (astUtil.isTSTypeReference(node)) {
                  typeName = node.typeName.name;
                  const leftMostName = getLeftMostTypeName(node.typeName);
          Severity: Major
          Found in lib/util/propTypes.js - About 2 hrs to fix

            File jsx-tag-spacing.js has 284 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /**
             * @fileoverview Validates whitespace in and around the JSX opening and closing brackets
             * @author Diogo Franco (Kovensky)
             */
            
            
            Severity: Minor
            Found in lib/rules/jsx-tag-spacing.js - About 2 hrs to fix

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

              function isContextTypesDeclaration(node) {
                if (node && (node.type === 'ClassProperty' || node.type === 'PropertyDefinition')) {
                  // Flow support
                  if (node.typeAnnotation && node.key.name === 'context') {
                    return true;
              Severity: Major
              Found in lib/util/props.js and 1 other location - About 2 hrs to fix
              lib/util/props.js on lines 14..22

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

              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

              function isPropTypesDeclaration(node) {
                if (node && (node.type === 'ClassProperty' || node.type === 'PropertyDefinition')) {
                  // Flow support
                  if (node.typeAnnotation && node.key.name === 'props') {
                    return true;
              Severity: Major
              Found in lib/util/props.js and 1 other location - About 2 hrs to fix
              lib/util/props.js on lines 29..37

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

              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 (context.settings.react && context.settings.react.flowVersion) {
                  let flowVersion = context.settings.react.flowVersion;
                  if (flowVersion === 'detect') {
                    flowVersion = detectFlowVersion(context);
                  }
              Severity: Major
              Found in lib/util/version.js and 1 other location - About 2 hrs to fix
              lib/util/version.js on lines 114..128

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

              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 (context.settings && context.settings.react && context.settings.react.version) {
                  let settingsVersion = context.settings.react.version;
                  if (settingsVersion === 'detect') {
                    settingsVersion = detectReactVersion(context);
                  }
              Severity: Major
              Found in lib/util/version.js and 1 other location - About 2 hrs to fix
              lib/util/version.js on lines 158..170

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

              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 fixPropTypesSort has 69 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function fixPropTypesSort(
                context,
                fixer,
                declarations,
                ignoreCase,
              Severity: Major
              Found in lib/util/propTypesSort.js - About 2 hrs to fix

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

                  create: Components.detect((context, components, utils) => {
                    // variables should be defined here
                    const options = context.options;
                    const defaultCheckType = options[0] || STATIC_PUBLIC_FIELD;
                    const hasAdditionalConfig = options.length > 1;
                Severity: Major
                Found in lib/rules/static-property-placement.js - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language