JavaScript

JavaScript

Made by DeepSource
Found unreachable code JS-0025
Performance
Major

Some code paths are unreachable because the return, throw, break, and continue statements unconditionally exit a block of code. The code statements after the above keywords (which exit the code block) will not execute.

Avoid using setState in componentDidMount JS-0442
Performance
Major

componentDidMount() is invoked immediately after a component is mounted. This method is a good place to load data from an endpoint as it is invoked before the browser updates the screen. Using setState() in componentDidMount() will trigger an extra rendering, so it causes performance issues as render() will be called twice.

arguments.caller or arguments.callee should not be used JS-0053
Performance
Minor

The use of arguments.caller and arguments.callee make several code optimizations impossible. They have been deprecated in future versions of JavaScript and their use is forbidden in ECMAScript 5 while in strict mode.

Module imported is not necessary JS-0234
Performance
Minor

Imports are an ES6/ES2015 standard for making the functionality of other modules available in your current module. In CommonJS this is implemented through the require() call. Why would you want to restrict imports?

Require symbol description JS-0250
Performance
Minor

The Symbol function may have an optional description:

Found unused variables in TypeScript code JS-0356
Performance
Major

Unused variables are generally considered a code smell and should be avoided.

Unnecessary catch clauses found JS-0112
Performance
Minor

A catch clause that only rethrows the original error is redundant, and has no effect on the runtime behavior of the program. These redundant clauses can be a source of confusion and code bloat, so it's better to disallow these unnecessary catch clauses.

Unnecessary return await function found JS-0111
Performance
Major

Returning an awaited value (like with return await f()) has two problems: - It queues an extra microtask, blocking the callstack until return is executed.

Prefer explicit role property in HTML tags JS-0764
Performance
Minor

Some HTML elements have native semantics that are implemented by the browser. This includes default/implicit ARIA roles. Setting an ARIA role that matches its default/implicit role is redundant since it is already set by the browser.

Prefer not to use words image, photo in image alt content JS-0750
Performance
Minor

Enforce img alt attribute does not contain the word image, picture, or photo. Screenreaders already announce img elements as an image. There is no need to use words such as image, photo, and/or picture.

Interactive elements should be focusable JS-0751
Performance
Minor

Elements with an interactive role and interaction handlers (mouse or key press) must be focusable as it will be helpful for keyboard and screen reader users.

Consider using onFocus/onBlur with onMouseOver/onMouseOut event JS-0755
Performance
Minor

Enforce onmouseover/onmouseout are accompanied by onfocus/onblur. Coding for the keyboard is important for users with physical disabilities who cannot use a mouse, AT compatibility, and screenreader users.

Prefer that no distracting elements are used JS-0758
Performance
Minor

Enforces that no distracting elements are used. Elements that can be visually distracting can cause accessibility issues with visually impaired users. Such elements are most likely deprecated, and should be avoided. By default, the following elements are visually distracting: <marquee> and <blink>.

tabIndex declared on a non-interactive element JS-0762
Performance
Minor

Tab key navigation should be limited to elements on the page that can be interacted with. Thus it is not necessary to add a tabindex to items in an unordered list, for example, to make them navigable through assistive technology. These applications already afford page traversal mechanisms based on the HTML of the page. Generally, we should try to reduce the size of the page's tab ring rather than increasing it.

Should not use attrs in ember hooks JS-0777
Performance
Minor

In 2.0.0, didReceiveAttrs and didUpdateAttrs hooks were introduced. These hooks are called whenever the references of arguments to a component change. These hooks receive arguments, however one should not use them as they can be very costly when you have a lot of components on the page.

Avoid using @each in deeply nested computed property JS-0780
Performance
Minor

Ember does not allow deeply-nested computed property dependent keys with @each. At runtime, it will show a warning about this. You should use @each only one level deep otherwise it will create a complex equation and effect your application performance.

Interactive elements should not be assigned non-interactive roles JS-0759
Performance
Minor

Interactive HTML elements indicate controls in the user interface. Interactive elements include <a href>, <button>, <input>, <select>, <textarea>. Non-interactive HTML elements and non-interactive ARIA roles indicate content and containers in the user interface. Non-interactive elements include <main>, <area>, <h1> (,<h2>, etc), <img>, <li>, <ul> and <ol>.

Non-interactive elements should not be assigned interactive roles JS-0761
Performance
Minor

Non-interactive HTML elements indicate content and containers in the user interface. Non-interactive elements include <main>, <area>, <h1> (,<h2>, etc), <img>, <li>, <ul> and <ol>. Interactive HTML elements indicate controls in the user interface. Interactive elements include <a href>, <button>, <input>, <select>, <textarea>.