for-of
loop for array JS-0361A for-of
loop is recommended when the loop index is only used to read from the collection.
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.
Name property in a SFC module is mostly a convenience for debugging. It's also helpful for recursion.
v-bind
directives JS-0717The v-bind
with a string literal value can be changed to a static attribute definition.
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
.
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.
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.
Ensures that any component or prop methods used to handle events are correctly prefixed.
$FlowFixMe
comments JS-0485The usage of $FlowFixMe
is not preferred. This is especially useful as a warning to ensure instances of $FlowFixMe
in your codebase get fixed over time.
Escaping non-special characters in strings, template literals, and regular expressions doesn't have any effect.
The display
descriptor for the Google font is either not assigned or set to auto
, fallback
, or block
.
A recommended way to resolve this is to set display
as optional
. Specifying display=optional
minimizes the risk of invisible text or layout shift. If it is essential to swap to a custom font after it has loaded, use display=swap
instead.
Regex literals should escape division operators.
$on
and $watch
deregistration callbacks to be saved in a variable JS-0529Watch and On methods on the scope object should be assigned to a variable, in order to be deleted in a $destroy
event handler Rule based on Angular 1.x
The mustache interpolation with a string literal value can be changed to a static contents.
It is considered a best practice to avoid 'polluting' the global scope with variables that are intended to be local to the script. Global variables created from a script can produce name collisions with global variables created from another script, which will usually lead to runtime errors or unexpected behavior. It is mostly useful for browser scripts.
In JavaScript, you can extend any object, including builtin or "native" objects. Sometimes people change the behavior of these native objects in ways that break the assumptions made about them in other parts of the code.
Using promises is forbidden in places where the TypeScript compiler allows them but they are not handled properly. These situations can often arise due to a missing await keyword or just a misunderstanding of the way async functions are handled/awaited.
React components use JSX, not HTML.
So we need to use JSX attributes and React replicate the respective HTML property/attribute while rendering.
Use of HTML property in JSX can sometimes lead to errors.
For example, class
is a keyword in JavaScript (JSX is an extension of JavaScript), so it will throw an error.
However, in HTML it is a valid attribute.
Note: If you use React with Web Components, use the class
attribute instead.
Nesting JSX elements too deeply can confuse developers reading the code. To make maintenance and refactoring easier, DeepSource recommends limiting the maximum JSX tree depth to 4.
Multiple non-null assertion operators (!
s) are redundant, and may confuse the reader. Moreover, foo?.bar
should always be preferred over foo!?.bar
.