Skip to content

Commit

Permalink
Merge pull request #188 from Automattic/add/no-constant-binary-expres…
Browse files Browse the repository at this point in the history
…sion

Add no-constant-binary-expression rule
  • Loading branch information
chriszarate committed Nov 24, 2023
2 parents 08c5fed + 09245dc commit a9c6a2e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions __fixtures__/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ nonExistent();
export function base64encode( str ) {
return Buffer.from( str ).toString( 'base64' );
}

export const constantBinary = x() || x() !== {};
22 changes: 11 additions & 11 deletions __tests__/__snapshots__/check-fixtures.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,6 @@ import { unusedEs6Import } from './stub/unusedEs6Import';
"ruleId": "id-length",
"severity": 1,
},
{
"column": 10,
"endColumn": 11,
"endLine": 15,
"line": 15,
"message": "'x' is defined but never used.",
"messageId": "unusedVar",
"nodeType": "Identifier",
"ruleId": "no-unused-vars",
"severity": 2,
},
{
"column": 13,
"endColumn": 14,
Expand Down Expand Up @@ -231,6 +220,17 @@ import { unusedEs6Import } from './stub/unusedEs6Import';
"ruleId": "no-undef",
"severity": 2,
},
{
"column": 46,
"endColumn": 48,
"endLine": 55,
"line": 55,
"message": "Unexpected comparison to newly constructed object. These two values can never be equal.",
"messageId": "alwaysNew",
"nodeType": "ObjectExpression",
"ruleId": "no-constant-binary-expression",
"severity": 2,
},
]
`;

Expand Down
1 change: 1 addition & 0 deletions configs/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = {
'no-compare-neg-zero': 'error',
// 'no-cond-assign': 'error', // extended below
'no-const-assign': 'error',
'no-constant-binary-expression': 'error',
'no-constant-condition': 'error',
'no-control-regex': 'error',
'no-debugger': 'error',
Expand Down

0 comments on commit a9c6a2e

Please sign in to comment.