i18next/react-i18next

View on GitHub

Showing 43 of 43 total issues

Avoid too many return statements within this function.
Open

  if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
Severity: Major
Found in src/utils.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

      return false;
    Severity: Major
    Found in src/utils.js - About 30 mins to fix

      Function withTranslation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export function withTranslation(ns, options = {}) {
        return function Extend(WrappedComponent) {
          function I18nextWithTranslation({ forwardedRef, ...rest }) {
            const [t, i18n, ready] = useTranslation(ns, rest);
      
      
      Severity: Minor
      Found in src/withTranslation.js - About 25 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

      Definition for rule 'jsx-a11y/anchor-is-valid' was not found
      Open

      const { createMacro } = require('babel-plugin-macros');
      Severity: Minor
      Found in icu.macro.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Definition for rule 'jsx-a11y/anchor-is-valid' was not found
      Open

      export { Trans } from './Trans';
      Severity: Minor
      Found in src/index.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Assignment to function parameter 'mem'.
      Open

          if (t.isJSXText(ele) && ele.value) mem += trimIndent(ele.value);
      Severity: Minor
      Found in icu.macro.js by eslint

      Disallow Reassignment of Function Parameters (no-param-reassign)

      Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the arguments object. Often, assignment to function parameters is unintended and indicative of a mistake or programmer error.

      This rule can be also configured to fail when function parameters are modified. Side effects on parameters can cause counter-intuitive execution flow and make errors difficult to track down.

      Rule Details

      This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

      Examples of incorrect code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          bar = 13;
      }
      
      function foo(bar) {
          bar++;
      }

      Examples of correct code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          var baz = bar;
      }

      Options

      This rule takes one option, an object, with a boolean property "props" and an array "ignorePropertyModificationsFor". "props" is false by default. If "props" is set to true, this rule warns against the modification of parameter properties unless they're included in "ignorePropertyModificationsFor", which is an empty array by default.

      props

      Examples of correct code for the default { "props": false } option:

      /*eslint no-param-reassign: ["error", { "props": false }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of incorrect code for the { "props": true } option:

      /*eslint no-param-reassign: ["error", { "props": true }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of correct code for the { "props": true } option with "ignorePropertyModificationsFor" set:

      /*eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["bar"] }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      When Not To Use It

      If you want to allow assignment to function parameters, then you can safely disable this rule.

      Further Reading

      Assignment to function parameter 'mem'.
      Open

          if (ele.expression && ele.expression.value) mem += ele.expression.value;
      Severity: Minor
      Found in icu.macro.js by eslint

      Disallow Reassignment of Function Parameters (no-param-reassign)

      Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the arguments object. Often, assignment to function parameters is unintended and indicative of a mistake or programmer error.

      This rule can be also configured to fail when function parameters are modified. Side effects on parameters can cause counter-intuitive execution flow and make errors difficult to track down.

      Rule Details

      This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

      Examples of incorrect code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          bar = 13;
      }
      
      function foo(bar) {
          bar++;
      }

      Examples of correct code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          var baz = bar;
      }

      Options

      This rule takes one option, an object, with a boolean property "props" and an array "ignorePropertyModificationsFor". "props" is false by default. If "props" is set to true, this rule warns against the modification of parameter properties unless they're included in "ignorePropertyModificationsFor", which is an empty array by default.

      props

      Examples of correct code for the default { "props": false } option:

      /*eslint no-param-reassign: ["error", { "props": false }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of incorrect code for the { "props": true } option:

      /*eslint no-param-reassign: ["error", { "props": true }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of correct code for the { "props": true } option with "ignorePropertyModificationsFor" set:

      /*eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["bar"] }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      When Not To Use It

      If you want to allow assignment to function parameters, then you can safely disable this rule.

      Further Reading

      Definition for rule 'jsx-a11y/anchor-is-valid' was not found
      Open

      import { useState, useEffect, useContext } from 'react';
      Severity: Minor
      Found in src/useTranslation.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Assignment to function parameter 'mem'.
      Open

            mem += `{${ele.expression.expressions
      Severity: Minor
      Found in icu.macro.js by eslint

      Disallow Reassignment of Function Parameters (no-param-reassign)

      Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the arguments object. Often, assignment to function parameters is unintended and indicative of a mistake or programmer error.

      This rule can be also configured to fail when function parameters are modified. Side effects on parameters can cause counter-intuitive execution flow and make errors difficult to track down.

      Rule Details

      This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

      Examples of incorrect code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          bar = 13;
      }
      
      function foo(bar) {
          bar++;
      }

      Examples of correct code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          var baz = bar;
      }

      Options

      This rule takes one option, an object, with a boolean property "props" and an array "ignorePropertyModificationsFor". "props" is false by default. If "props" is set to true, this rule warns against the modification of parameter properties unless they're included in "ignorePropertyModificationsFor", which is an empty array by default.

      props

      Examples of correct code for the default { "props": false } option:

      /*eslint no-param-reassign: ["error", { "props": false }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of incorrect code for the { "props": true } option:

      /*eslint no-param-reassign: ["error", { "props": true }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of correct code for the { "props": true } option with "ignorePropertyModificationsFor" set:

      /*eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["bar"] }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      When Not To Use It

      If you want to allow assignment to function parameters, then you can safely disable this rule.

      Further Reading

      Assignment to function parameter 'mem'.
      Open

            mem += `<${componentFoundIndex}>${mergeChildren(
      Severity: Minor
      Found in icu.macro.js by eslint

      Disallow Reassignment of Function Parameters (no-param-reassign)

      Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the arguments object. Often, assignment to function parameters is unintended and indicative of a mistake or programmer error.

      This rule can be also configured to fail when function parameters are modified. Side effects on parameters can cause counter-intuitive execution flow and make errors difficult to track down.

      Rule Details

      This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

      Examples of incorrect code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          bar = 13;
      }
      
      function foo(bar) {
          bar++;
      }

      Examples of correct code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          var baz = bar;
      }

      Options

      This rule takes one option, an object, with a boolean property "props" and an array "ignorePropertyModificationsFor". "props" is false by default. If "props" is set to true, this rule warns against the modification of parameter properties unless they're included in "ignorePropertyModificationsFor", which is an empty array by default.

      props

      Examples of correct code for the default { "props": false } option:

      /*eslint no-param-reassign: ["error", { "props": false }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of incorrect code for the { "props": true } option:

      /*eslint no-param-reassign: ["error", { "props": true }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of correct code for the { "props": true } option with "ignorePropertyModificationsFor" set:

      /*eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["bar"] }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      When Not To Use It

      If you want to allow assignment to function parameters, then you can safely disable this rule.

      Further Reading

      Definition for rule 'jsx-a11y/anchor-is-valid' was not found
      Open

      import React from 'react';
      Severity: Minor
      Found in src/context.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Definition for rule 'jsx-a11y/anchor-is-valid' was not found
      Open

      import React from 'react';
      Severity: Minor
      Found in src/I18nextProvider.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Definition for rule 'jsx-a11y/anchor-is-valid' was not found
      Open

      import React from 'react';
      Severity: Minor
      Found in src/withSSR.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Unary operator '++' used.
      Open

            componentFoundIndex++;
      Severity: Minor
      Found in icu.macro.js by eslint

      disallow the unary operators ++ and -- (no-plusplus)

      Because the unary ++ and -- operators are subject to automatic semicolon insertion, differences in whitespace can change semantics of source code.

      var i = 10;
      var j = 20;
      
      i ++
      j
      // i = 11, j = 20
      var i = 10;
      var j = 20;
      
      i
      ++
      j
      // i = 10, j = 21

      Rule Details

      This rule disallows the unary operators ++ and --.

      Examples of incorrect code for this rule:

      /*eslint no-plusplus: "error"*/
      
      var foo = 0;
      foo++;
      
      var bar = 42;
      bar--;
      
      for (i = 0; i < l; i++) {
          return;
      }

      Examples of correct code for this rule:

      /*eslint no-plusplus: "error"*/
      
      var foo = 0;
      foo += 1;
      
      var bar = 42;
      bar -= 1;
      
      for (i = 0; i < l; i += 1) {
          return;
      }

      Options

      This rule has an object option.

      • "allowForLoopAfterthoughts": true allows unary operators ++ and -- in the afterthought (final expression) of a for loop.

      allowForLoopAfterthoughts

      Examples of correct code for this rule with the { "allowForLoopAfterthoughts": true } option:

      /*eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }]*/
      
      for (i = 0; i < l; i++) {
          return;
      }
      
      for (i = 0; i < l; i--) {
          return;
      }

      Source: http://eslint.org/docs/rules/

      Definition for rule 'jsx-a11y/anchor-is-valid' was not found
      Open

      export function warn(...args) {
      Severity: Minor
      Found in src/utils.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Definition for rule 'jsx-a11y/anchor-is-valid' was not found
      Open

      import { useContext } from 'react';
      Severity: Minor
      Found in src/useSSR.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Definition for rule 'jsx-a11y/anchor-is-valid' was not found
      Open

      import { useTranslation } from './useTranslation';
      Severity: Minor
      Found in src/Translation.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Definition for rule 'jsx-a11y/anchor-is-valid' was not found
      Open

      import React, { useContext } from 'react';
      Severity: Minor
      Found in src/Trans.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Assignment to function parameter 'mem'.
      Open

            mem = mem.concat(getValues(ele.children, babel));
      Severity: Minor
      Found in icu.macro.js by eslint

      Disallow Reassignment of Function Parameters (no-param-reassign)

      Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the arguments object. Often, assignment to function parameters is unintended and indicative of a mistake or programmer error.

      This rule can be also configured to fail when function parameters are modified. Side effects on parameters can cause counter-intuitive execution flow and make errors difficult to track down.

      Rule Details

      This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

      Examples of incorrect code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          bar = 13;
      }
      
      function foo(bar) {
          bar++;
      }

      Examples of correct code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          var baz = bar;
      }

      Options

      This rule takes one option, an object, with a boolean property "props" and an array "ignorePropertyModificationsFor". "props" is false by default. If "props" is set to true, this rule warns against the modification of parameter properties unless they're included in "ignorePropertyModificationsFor", which is an empty array by default.

      props

      Examples of correct code for the default { "props": false } option:

      /*eslint no-param-reassign: ["error", { "props": false }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of incorrect code for the { "props": true } option:

      /*eslint no-param-reassign: ["error", { "props": true }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of correct code for the { "props": true } option with "ignorePropertyModificationsFor" set:

      /*eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["bar"] }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      When Not To Use It

      If you want to allow assignment to function parameters, then you can safely disable this rule.

      Further Reading

      Assignment to function parameter 'mem'.
      Open

          if (ele.expression && ele.expression.name) mem += `{${ele.expression.name}}`;
      Severity: Minor
      Found in icu.macro.js by eslint

      Disallow Reassignment of Function Parameters (no-param-reassign)

      Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the arguments object. Often, assignment to function parameters is unintended and indicative of a mistake or programmer error.

      This rule can be also configured to fail when function parameters are modified. Side effects on parameters can cause counter-intuitive execution flow and make errors difficult to track down.

      Rule Details

      This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

      Examples of incorrect code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          bar = 13;
      }
      
      function foo(bar) {
          bar++;
      }

      Examples of correct code for this rule:

      /*eslint no-param-reassign: "error"*/
      
      function foo(bar) {
          var baz = bar;
      }

      Options

      This rule takes one option, an object, with a boolean property "props" and an array "ignorePropertyModificationsFor". "props" is false by default. If "props" is set to true, this rule warns against the modification of parameter properties unless they're included in "ignorePropertyModificationsFor", which is an empty array by default.

      props

      Examples of correct code for the default { "props": false } option:

      /*eslint no-param-reassign: ["error", { "props": false }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of incorrect code for the { "props": true } option:

      /*eslint no-param-reassign: ["error", { "props": true }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      Examples of correct code for the { "props": true } option with "ignorePropertyModificationsFor" set:

      /*eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["bar"] }]*/
      
      function foo(bar) {
          bar.prop = "value";
      }
      
      function foo(bar) {
          delete bar.aaa;
      }
      
      function foo(bar) {
          bar.aaa++;
      }

      When Not To Use It

      If you want to allow assignment to function parameters, then you can safely disable this rule.

      Further Reading

      Severity
      Category
      Status
      Source
      Language