Skip to content

Commit

Permalink
review eslint core rules: disallow "Yoda" conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Aug 16, 2023
1 parent 56cd6ff commit acaadf7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core-js/modules/es.date.set-year.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $({ target: 'Date', proto: true }, {
// validate
thisTimeValue(this);
var yi = toIntegerOrInfinity(year);
var yyyy = 0 <= yi && yi <= 99 ? yi + 1900 : yi;
var yyyy = yi >= 0 && yi <= 99 ? yi + 1900 : yi;
return setFullYear(this, yyyy);
}
});
4 changes: 2 additions & 2 deletions packages/core-js/modules/web.url.constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ URLState.prototype = {
if (search === '') {
this.query = null;
} else {
if ('?' === charAt(search, 0)) search = stringSlice(search, 1);
if (charAt(search, 0) === '?') search = stringSlice(search, 1);
this.query = '';
this.parse(search, QUERY);
}
Expand All @@ -933,7 +933,7 @@ URLState.prototype = {
this.fragment = null;
return;
}
if ('#' === charAt(hash, 0)) hash = stringSlice(hash, 1);
if (charAt(hash, 0) === '#') hash = stringSlice(hash, 1);
this.fragment = '';
this.parse(hash, FRAGMENT);
},
Expand Down
2 changes: 2 additions & 0 deletions tests/eslint/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ const base = {
}],
// require strict mode directives
strict: [ERROR, 'global'],
// disallow "Yoda" conditions
yoda: [ERROR, NEVER],

// layout & formatting:
// enforce spacing inside array brackets
Expand Down

0 comments on commit acaadf7

Please sign in to comment.