yannickcr/eslint-plugin-react

View on GitHub

Showing 710 of 710 total issues

Function JSXOpeningElement:exit has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      'JSXOpeningElement:exit'(node) {
        const attributeNode = lastAttributeNode[getOpeningElementId(node)];
        const cachedLastAttributeEndPos = attributeNode ? attributeNode.range[1] : null;

        let expectedNextLine;
Severity: Minor
Found in lib/rules/jsx-closing-bracket-location.js - About 1 hr to fix

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

      create(context) {
        const TEXT_FOLLOWING_ELEMENT_PATTERN = /^\s*\n\s*\S/;
        const TEXT_PRECEDING_ELEMENT_PATTERN = /\S\s*\n\s*$/;
    
        const elementName = (node) => (
    Severity: Minor
    Found in lib/rules/jsx-child-element-spacing.js - About 1 hr to fix

      Function JSXAttribute has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            JSXAttribute(node) {
              const propName = node.name && node.name.name;
              const value = node.value;
      
              if (
      Severity: Minor
      Found in lib/rules/jsx-boolean-value.js - About 1 hr to fix

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

          if (
            name.type === 'JSXMemberExpression'
            && name.object.type === 'JSXIdentifier'
            && name.object.name === reactPragma
            && name.property.type === 'JSXIdentifier'
        Severity: Major
        Found in lib/util/jsx.js and 1 other location - About 1 hr to fix
        lib/rules/jsx-fragments.js on lines 117..125

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

        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 (
                variableInit.type === 'MemberExpression'
                && variableInit.object.type === 'Identifier'
                && variableInit.object.name === reactPragma
                && variableInit.property.type === 'Identifier'
        Severity: Major
        Found in lib/rules/jsx-fragments.js and 1 other location - About 1 hr to fix
        lib/util/jsx.js on lines 43..51

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

        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 (!attributeValuePossiblyBlank(node.attributes[targetIndex])) {
                    const hasSpread = spreadAttributeIndex >= 0;
        
                    if (warnOnSpreadAttributes && hasSpread) {
                      // continue to check below
        Severity: Major
        Found in lib/rules/jsx-no-target-blank.js and 1 other location - About 1 hr to fix
        lib/rules/jsx-no-target-blank.js on lines 252..264

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

        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 (!attributeValuePossiblyBlank(node.attributes[targetIndex])) {
                    const hasSpread = spreadAttributeIndex >= 0;
        
                    if (warnOnSpreadAttributes && hasSpread) {
                      // continue to check below
        Severity: Major
        Found in lib/rules/jsx-no-target-blank.js and 1 other location - About 1 hr to fix
        lib/rules/jsx-no-target-blank.js on lines 189..197

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

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

        function generateFixerFunction(node, context, reservedList) {
          const attributes = node.attributes.slice(0);
          const configuration = context.options[0] || {};
          const ignoreCase = configuration.ignoreCase || false;
          const callbacksLast = configuration.callbacksLast || false;
        Severity: Minor
        Found in lib/rules/jsx-sort-props.js - About 1 hr to fix

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

            create(context) {
              const configuration = context.options[0] || {};
              const forbidConfiguration = configuration.forbid || [];
          
              /** @type {Record<string, { element: string, message?: string }>} */
          Severity: Minor
          Found in lib/rules/forbid-elements.js - About 1 hr to fix

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

                  JSXOpeningElement(node) {
                    node.attributes.forEach((attrNode) => {
                      if (!hasEqual(attrNode)) {
                        return;
                      }
            Severity: Minor
            Found in lib/rules/jsx-equals-spacing.js - About 1 hr to fix

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

                create(context) {
                  const configuration = context.options[0] || 'multiline-multiprop';
              
                  function isMultilineJSX(jsxNode) {
                    return jsxNode.loc.start.line < jsxNode.loc.end.line;
              Severity: Minor
              Found in lib/rules/jsx-first-prop-new-line.js - About 1 hr 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 validateBeforeClosing has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              function validateBeforeClosing(context, node, option) {
                // Don't enforce this rule for self closing tags
                if (!node.selfClosing) {
                  const sourceCode = getSourceCode(context);
                  const leftToken = option === 'proportional-always'
              Severity: Minor
              Found in lib/rules/jsx-tag-spacing.js - About 1 hr 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 attributeValuePossiblyBlank has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              function attributeValuePossiblyBlank(attribute) {
                if (!attribute || !attribute.value) {
                  return false;
                }
                const value = attribute.value;
              Severity: Minor
              Found in lib/rules/jsx-no-target-blank.js - About 1 hr 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 checkCreateProps has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              function checkCreateProps(context, node, attribute) {
                const propsArg = node.arguments[1];
              
                if (!propsArg || propsArg.type !== 'ObjectExpression') {
                  return; // can't check variables, computed, or shorthands
              Severity: Minor
              Found in lib/rules/no-invalid-html-attribute.js - About 1 hr 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 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  create(context) {
                    const mode = context.options[0] || 'allow-in-func';
              
                    function nameMatches(name) {
                      if (name === methodName) {
              Severity: Minor
              Found in lib/util/makeNoMethodSetStateRule.js - About 1 hr to fix

                Function checkCreateProps has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function checkCreateProps(context, node, attribute) {
                  const propsArg = node.arguments[1];
                
                  if (!propsArg || propsArg.type !== 'ObjectExpression') {
                    return; // can't check variables, computed, or shorthands
                Severity: Minor
                Found in lib/rules/no-invalid-html-attribute.js - About 1 hr to fix

                  Function ruleFixer has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function ruleFixer(context, fixStrategy, fixer, reportedNode, leftNode, rightNode) {
                    const rightSideText = getText(context, rightNode);
                  
                    if (fixStrategy === COERCE_STRATEGY) {
                      const expressions = extractExpressionBetweenLogicalAnds(leftNode);
                  Severity: Minor
                  Found in lib/rules/jsx-no-leaked-render.js - About 1 hr to fix

                    Function handleClosingElement has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function handleClosingElement(node) {
                          if (!node.parent) {
                            return;
                          }
                          const sourceCode = getSourceCode(context);
                    Severity: Minor
                    Found in lib/rules/jsx-closing-tag-location.js - About 1 hr to fix

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

                        create(context) {
                          const configuration = context.options[0] || {};
                          const ignoreHtmlTags = (configuration.html || DEFAULTS.html) === OPTIONS.ignore;
                          const ignoreCustomTags = (configuration.custom || DEFAULTS.custom) === OPTIONS.ignore;
                          const ignoreExplicitSpread = (configuration.explicitSpread || DEFAULTS.explicitSpread) === OPTIONS.ignore;
                      Severity: Minor
                      Found in lib/rules/jsx-props-no-spreading.js - About 1 hr to fix

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

                          create(context) {
                            const checkRefsUsage = testReactVersion(context, '< 18.3.0'); // `this.refs` is writable in React 18.3.0 and later, see https://github.com/facebook/react/pull/28867
                            const detectTemplateLiterals = context.options[0] ? context.options[0].noTemplateLiterals : false;
                            /**
                             * Checks if we are using refs
                        Severity: Minor
                        Found in lib/rules/no-string-refs.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language