Found non-compliant syntax. Confirm that there are no syntax errors before committing your code to a version control system.
path
option JS-0809When defining a route, it's not necessary to specify the path
option if it matches the route name.
javascript:
URLs JS-0421URLs 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.
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.
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.
head
property in component as a function JS-W1013It is recommended to use head
as a function as it provides access to more data through this
.
Re-assigning a variable that was declared with the const
keyword can lead to a TypeError
.
$slots
should be used as a function JS-0658this.$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.
There should not be name collisions between Vue components, standard HTML elements and built-in components.
Unused properties should be eliminated.
$cookieStore
JS-0530The $cookieStore
service has been deprecated since Angular 1.4.
Use the $cookies
service instead.
Create clearer code by disallowing the bad practice of creating a label that shares a name with a variable that is in scope.
needs
to load other controllers JS-0770Avoid using needs
to load other controllers. Inject the required controller instead. needs
was deprecated in ember 1.x and removed in 2.0.
this.state
JS-0444The only good place to assign this.state
is in an ES6 class
component constructor.
It is not recommended to mutate this.state
directly, as calling setState()
afterward may replace the mutation. You should treat this.state
as if it were immutable.
If more than one parameter in the function definition has the same name, the last occurrence "shadows" the preceding occurrences. A duplicated name might be a typo, and may confuse anyone reading the code.
When writing asynchronous code, it is possible to create subtle race condition bugs. Consider the following example:
function
or var declarations in nested blocks is not preferred JS-0016Function declarations (with the function
keyword) and variable declarations should preferably be in the root of a program or the body of a function. Having nested function declarations inside blocks may have unexpected results at runtime due to hoisting.
This rule is aimed at disallowing exports = {}
, but allows module.exports = exports = {}
to avoid conflict with node/exports-style rule's allowBatchAssign
option.
The var
keyword is soft-deprecated, and should not be used to redeclare existing variables.
An unused expression that does not affect the state of the program indicates a logic error.