Skip to content

Linting fixes and simplification

These changes fix issues detected by JSHint and simplify expressions to increase readability.

Fixed linting issues (96 in total, jshint@2.7.0):

  • Accidentally globally defined variables
  • Redefined variables
  • Typo in identifier name
  • Duplicate object key
  • Coercing equal
  • Confusing negation of 'lesser than' comparison
  • Undefined globals from libraries
  • Missing blocks for conditions
  • Functions defined inside of loops (performance)

Simplified expressions:

  • Check for thruthy/falsy values when possible instead of type checking against 'undefined'
  • Use logical OR for fallback values (instead of x = x ? x : y;)
  • Remove explicit type conversion in conditions (if (!!x)) and in places where the variable already is a boolean
  • Replace ternary IF with a boolean result by the condition itself
  • Refactored:
    if (newValue === 0 &&
        typeof this.someProperty === "undefined" ||
        newValue === this.someProperty) { }
    to:
    if (newValue === (this.someProperty || 0)) { }

Minor code style fixes:

  • Indentation
  • Capitalization

Removed code:

  • Obsolete commented out code
  • Code for IE < 4 and NS < 6 (really! 😀)

Merge request reports