yannickcr/eslint-plugin-react

View on GitHub

Showing 710 of 710 total issues

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

/**
 * @fileoverview Enforce or disallow spaces inside of curly braces in JSX attributes.
 * @author Jamund Ferguson
 * @author Brandyn Bennett
 * @author Michael Ficarra
Severity: Minor
Found in lib/rules/jsx-curly-spacing.js - About 3 hrs to fix

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

      create(context) {
        const configuration = context.options[0] || {};
        const ignoreCase = configuration.ignoreCase || false;
    
        /**
    Severity: Major
    Found in lib/rules/jsx-sort-default-props.js - About 3 hrs to fix

      Function isConstruction has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function isConstruction(node, callScope) {
        switch (node.type) {
          case 'Literal':
            if (node.regex != null) {
              return { type: 'regular expression', node };
      Severity: Major
      Found in lib/rules/jsx-no-constructed-context-values.js - About 3 hrs to fix

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

                  function spaceBetweenNext() {
                    return ((nextChild.type === 'Literal' || nextChild.type === 'JSXText') && /^ /.test(nextChild.raw))
                      || ((child.type === 'Literal' || child.type === 'JSXText') && / $/.test(child.raw))
                      || getSourceCode(context).isSpaceBetweenTokens(child, nextChild);
                  }
        Severity: Major
        Found in lib/rules/jsx-one-expression-per-line.js and 1 other location - About 3 hrs to fix
        lib/rules/jsx-one-expression-per-line.js on lines 171..175

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

        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 spaceBetweenPrev() {
                    return ((prevChild.type === 'Literal' || prevChild.type === 'JSXText') && / $/.test(prevChild.raw))
                      || ((child.type === 'Literal' || child.type === 'JSXText') && /^ /.test(child.raw))
                      || getSourceCode(context).isSpaceBetweenTokens(prevChild, child);
                  }
        Severity: Major
        Found in lib/rules/jsx-one-expression-per-line.js and 1 other location - About 3 hrs to fix
        lib/rules/jsx-one-expression-per-line.js on lines 177..181

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

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

          create(context) {
            const sourceCode = getSourceCode(context);
        
            function getPropName(propNode) {
              switch (propNode.type) {
        Severity: Major
        Found in lib/rules/jsx-props-no-multi-spaces.js - About 3 hrs to fix

          Function create has 84 lines of code (exceeds 25 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: Major
          Found in lib/rules/no-direct-mutation-state.js - About 3 hrs to fix

            Function getRefPropIndexes has 82 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function getRefPropIndexes(method) {
                  const methodGroupIndexes = [];
            
                  methodsOrder.forEach((currentGroup, groupIndex) => {
                    if (currentGroup === 'getters') {
            Severity: Major
            Found in lib/rules/sort-comp.js - About 3 hrs to fix

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

                create(context) {
                  const config = context.options[0];
                  let option = defaultOption;
              
                  if (typeof config === 'string') {
              Severity: Minor
              Found in lib/rules/jsx-closing-tag-location.js - About 3 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 81 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                create(context) {
                  function isPrefixDisabled(prefix) {
                    return prefix === false;
                  }
              
              
              Severity: Major
              Found in lib/rules/jsx-handler-names.js - About 3 hrs to fix

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

                  create(context) {
                    const config = context.options[0] || {};
                    const allowInPropTypes = config.allowInPropTypes || false;
                
                    // --------------------------------------------------------------------------
                Severity: Major
                Found in lib/rules/forbid-foreign-prop-types.js - About 3 hrs to fix

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

                    create(context) {
                      const configuration = context.options[0] || {};
                      const ignoreCase = configuration.ignoreCase || false;
                  
                      /**
                  Severity: Major
                  Found in lib/rules/sort-default-props.js - About 3 hrs to fix

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

                      create: Components.detect((context, components) => {
                        /**
                         * @param {Array} properties list of component properties
                         */
                        function reportNoArrowFunctionLifecycle(properties) {
                    Severity: Major
                    Found in lib/rules/no-arrow-function-lifecycle.js - About 3 hrs to fix

                      Function JSXOpeningElement has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            JSXOpeningElement(node) {
                              const targetIndex = findLastIndex(node.attributes, (attr) => attr.name && attr.name.name === 'target');
                              const spreadAttributeIndex = findLastIndex(node.attributes, (attr) => (attr.type === 'JSXSpreadAttribute'));
                      
                              if (linkComponents.has(node.name.name)) {
                      Severity: Major
                      Found in lib/rules/jsx-no-target-blank.js - About 3 hrs to fix

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

                          create(context) {
                            const options = Object.assign({}, optionDefaults, context.options[0]);
                        
                            function nodeKey(node) {
                              return `${node.loc.start.line},${node.loc.start.column}`;
                        Severity: Minor
                        Found in lib/rules/jsx-one-expression-per-line.js - About 3 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 22 (exceeds 5 allowed). Consider refactoring.
                        Open

                          create(context) {
                            const sourceCode = getSourceCode(context);
                        
                            function getPropName(propNode) {
                              switch (propNode.type) {
                        Severity: Minor
                        Found in lib/rules/jsx-props-no-multi-spaces.js - About 3 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 convertReturnTypeToPropTypes has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            convertReturnTypeToPropTypes(node, rootNode) {
                              // ReturnType<T> should always have one parameter
                              const nodeTypeArguments = propsUtil.getTypeArguments(node);
                              if (nodeTypeArguments) {
                                if (nodeTypeArguments.params.length === 1) {
                        Severity: Major
                        Found in lib/util/propTypes.js - About 3 hrs to fix

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

                            create(context) {
                              function getIgnoreConfig() {
                                return (context.options[0] && context.options[0].ignore) || DEFAULTS.ignore;
                              }
                          
                          
                          Severity: Major
                          Found in lib/rules/no-unknown-property.js - About 3 hrs to fix

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

                              create(context) {
                                const configuration = context.options[0] || {};
                                const forbid = new Map((configuration.forbid || DEFAULTS).map((value) => {
                                  const propName = typeof value === 'string' ? value : value.propName;
                                  const propPattern = value.propNamePattern;
                            Severity: Major
                            Found in lib/rules/forbid-component-props.js - About 3 hrs to fix

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

                                  getRelatedComponent(node) {
                                    let i;
                                    let j;
                                    let k;
                                    let l;
                              Severity: Major
                              Found in lib/util/Components.js - About 3 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language