Merge branch 'master' into js-deprecate-ast

This commit is contained in:
Clément Fournier
2020-04-20 11:02:27 +02:00
211 changed files with 3426 additions and 1035 deletions

View File

@ -18,6 +18,7 @@ Rules which enforce generally accepted best practices.
<description>Avoid using with - it's bad news</description>
<priority>1</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
@ -79,10 +80,11 @@ Global variables can lead to side-effects that are hard to debug.
</description>
<priority>1</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
//Assignment[Name/@GlobalName = 'true']
//Assignment[Name/@GlobalName = true()]
]]>
</value>
</property>
@ -116,6 +118,7 @@ is better to explicitly scope the variable name to the nearest enclosing scope w
</description>
<priority>1</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
@ -171,6 +174,7 @@ See also: [parseInt()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/R
</description>
<priority>1</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[

View File

@ -22,20 +22,21 @@ indicative of the bug where the assignment operator '=' was used instead of the
</description>
<priority>2</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
//IfStatement[$allowIf = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//IfStatement[$allowIf = false()]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
|
//WhileLoop[$allowWhile = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//WhileLoop[$allowWhile = false()]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
|
//DoLoop[$allowWhile = "false"]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//DoLoop[$allowWhile = false()]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
|
//ForLoop[$allowFor = "false"]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//ForLoop[$allowFor = false()]/child::node()[2]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
|
//ConditionalExpression[$allowTernary = "false"]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//ConditionalExpression[$allowTernary = false()]/child::node()[1]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
|
//ConditionalExpression[$allowTernaryResults = "false"]/child::node()[position() = 2 or position() = 3]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = "false" and (@Image = "--" or @Image = "++")]]
//ConditionalExpression[$allowTernaryResults = false()]/child::node()[position() = 2 or position() = 3]/descendant-or-self::node()[self::Assignment or self::UnaryExpression[$allowIncrementDecrement = false() and (@Image = "--" or @Image = "++")]]
]]>
</value>
</property>
@ -72,6 +73,7 @@ Avoid using 'for' statements without using curly braces.
</description>
<priority>3</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
@ -107,10 +109,11 @@ Avoid using if..else statements without using curly braces.
</description>
<priority>3</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
//ExpressionStatement[parent::IfStatement[@Else = "true"]]
//ExpressionStatement[parent::IfStatement[@Else = true()]]
[not(child::Scope)]
[not(child::IfStatement)]
]]>
@ -146,10 +149,11 @@ Avoid using if statements without using curly braces.
</description>
<priority>3</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
//IfStatement[@Else = "false" and not(child::Scope)]
//IfStatement[@Else = false() and not(child::Scope)]
]]>
</value>
</property>
@ -182,10 +186,11 @@ See also: &lt;http://eslint.org/docs/rules/no-else-return>
</description>
<priority>3</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
//IfStatement[@Else="true"][Scope[1]/ReturnStatement]
//IfStatement[@Else=true()][Scope[1]/ReturnStatement]
]]>
</value>
</property>
@ -221,6 +226,7 @@ be misleading. Considering removing this unnecessary Block.
</description>
<priority>3</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
@ -256,6 +262,7 @@ if (bar) {
<description>Unnecessary parentheses should be removed.</description>
<priority>4</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
@ -285,6 +292,7 @@ will never execute. This is a bug, or extremely poor style.
</description>
<priority>1</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
@ -326,6 +334,7 @@ Avoid using 'while' statements without using curly braces.
</description>
<priority>3</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[

View File

@ -20,12 +20,13 @@ This rule helps improve code portability due to differences in browser treatment
</description>
<priority>1</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
//ObjectLiteral[$allowObjectLiteral = "false" and @TrailingComma = 'true']
//ObjectLiteral[$allowObjectLiteral = false() and @TrailingComma = true()]
|
//ArrayLiteral[$allowArrayLiteral = "false" and @TrailingComma = 'true']
//ArrayLiteral[$allowArrayLiteral = false() and @TrailingComma = true()]
]]>
</value>
</property>
@ -57,14 +58,14 @@ same type. The === operator avoids the casting.
</description>
<priority>3</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
//InfixExpression[(@Image = "==" or @Image = "!=")
//InfixExpression[
(@Image = "==" or @Image = "!=")
and
(child::KeywordLiteral[@Image = "true" or @Image = "false"]
or
child::NumberLiteral)
(KeywordLiteral[@Image='true' or @Image = 'false'] or NumberLiteral)
]
]]>
</value>
@ -104,10 +105,11 @@ precision in a floating point number. This may result in numeric calculations b
</description>
<priority>2</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
//NumberLiteral[@NormalizedImage != @Number]
//NumberLiteral[@NormalizedImage != string(@Number)]
]]>
</value>
</property>