JavaScript

JavaScript

Made by DeepSource
Use for-of loop for array JS-0361
Anti-pattern
Minor

A for-of loop is recommended when the loop index is only used to read from the collection.

Syntax error JS-0833
Bug risk
Minor

Found non-compliant syntax. Confirm that there are no syntax errors before committing your code to a version control system.

Disallow unnecessary route path option JS-0809
Bug risk
Minor
Autofix

When defining a route, it's not necessary to specify the path option if it matches the route name.

Invalid custom TypeScript modules declaration JS-0364
Anti-pattern
Minor
Autofix

In an effort to prevent further confusion between custom TypeScript modules and the new ES2015 modules, starting with TypeScript v1.5 the keyword namespace is now the preferred way to declare custom TypeScript modules. Use the namespace keyword instead of the module keyword to declare custom TypeScript modules.

Found usage of deprecated javascript: URLs JS-0421
Bug risk
Critical

URLs starting with javascript: are a dangerous attack surface because it's easy to accidentally include the unsanitized output in a tag like <a href> and create a security hole for XSS. The developers can use the React event handlers e.g. onChange, onClick etc.

Found control characters in regular expressions JS-0004
Bug risk
Major

Control characters are special, invisible characters in the ASCII range 0-31. These characters are rarely used in JavaScript strings, so a regular expression containing these characters is most likely a mistake.

Invalid regular expression strings present in RegExp constructors JS-0017
Bug risk
Major

An invalid pattern in a regular expression literal results in a SyntaxError when the code is parsed, but an invalid string in a RegExp constructor throws a SyntaxError only when the code is executed.

Use head property in component as a function JS-W1013
Bug risk
Major
Autofix

It is recommended to use head as a function as it provides access to more data through this.

Require a name property in Vue components JS-0720
Anti-pattern
Minor

Name property in a SFC module is mostly a convenience for debugging. It's also helpful for recursion.

Found reassigning const variables JS-0230
Bug risk
Major

Re-assigning a variable that was declared with the const keyword can lead to a TypeError.

Properties of $slots should be used as a function JS-0658
Bug risk
Major

this.$slots.default was an array of VNode in Vue.js 2.x, but changed to a function that returns an array of VNode in Vue.js 3.x.

Disallow the use of reserved names in component definitions JS-0707
Bug risk
Minor

There should not be name collisions between Vue components, standard HTML elements and built-in components.

Disallow unused properties JS-0715
Bug risk
Minor

Unused properties should be eliminated.

Disallow unnecessary v-bind directives JS-0717
Anti-pattern
Minor

The v-bind with a string literal value can be changed to a static attribute definition.

Use of deprecated $cookieStore JS-0530
Bug risk
Major
Autofix

The $cookieStore service has been deprecated since Angular 1.4. Use the $cookies service instead.

Comparisons found where both the sides are exactly the same JS-0089
Anti-pattern
Major

Comparing a variable against itself is usually an error, either a typo or refactoring error. It is confusing to the reader and may potentially introduce a runtime error. The only time you would compare a variable against itself is when you are testing for NaN.

Prefer not to use labels that share a name with a variable JS-0121
Bug risk
Minor

Create clearer code by disallowing the bad practice of creating a label that shares a name with a variable that is in scope.

Should not use needs to load other controllers JS-0770
Bug risk
Minor

Avoid using needs to load other controllers. Inject the required controller instead. needs was deprecated in ember 1.x and removed in 2.0.

Detected empty functions JS-0321
Anti-pattern
Minor

Having empty functions hurts readability, and is considered a code-smell. There's almost always a way to avoid using them. If you must use one, consider adding a comment to inform the reader of its purpose.

Forbid certain props on DOM Nodes JS-0395
Anti-pattern
Major

This rule prevents passing of props to elements. This rule only applies to DOM Nodes (e.g. <div />) and not Components (e.g. <Component />). The list of forbidden props can be customized with the forbid option.