Skip to content

Commit

Permalink
enable eslint no-else-return allowElseIf: false option
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Jul 2, 2024
1 parent 2f4207e commit 65dd82a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
3 changes: 2 additions & 1 deletion packages/core-js-compat/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function getModules(filter) {
if (typeof filter == 'string') {
if (has(entries, filter)) return entries[filter];
return atLeastSomeModules(allModules.filter(it => it.startsWith(filter)), filter);
} else if (filter instanceof RegExp) return atLeastSomeModules(allModules.filter(it => filter.test(it)), filter);
}
if (filter instanceof RegExp) return atLeastSomeModules(allModules.filter(it => filter.test(it)), filter);
throwInvalidFilter(filter);
}

Expand Down
7 changes: 2 additions & 5 deletions packages/core-js/modules/es.string.replace-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ $({ target: 'String', proto: true }, {
if (!~indexOf(flags, 'g')) throw new $TypeError('`.replaceAll` does not allow non-global regexes');
}
replacer = getMethod(searchValue, REPLACE);
if (replacer) {
return call(replacer, searchValue, O, replaceValue);
} else if (IS_PURE && IS_REG_EXP) {
return replace(toString(O), searchValue, replaceValue);
}
if (replacer) return call(replacer, searchValue, O, replaceValue);
if (IS_PURE && IS_REG_EXP) return replace(toString(O), searchValue, replaceValue);
}
string = toString(O);
searchString = toString(searchValue);
Expand Down
12 changes: 9 additions & 3 deletions packages/core-js/modules/web.url.constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,19 @@ var findLongestZeroSequence = function (ipv6) {
// https://url.spec.whatwg.org/#host-serializing
var serializeHost = function (host) {
var result, index, compress, ignore0;

// ipv4
if (typeof host == 'number') {
result = [];
for (index = 0; index < 4; index++) {
unshift(result, host % 256);
host = floor(host / 256);
} return join(result, '.');
}
return join(result, '.');
}

// ipv6
} else if (typeof host == 'object') {
if (typeof host == 'object') {
result = '';
compress = findLongestZeroSequence(host);
for (index = 0; index < 8; index++) {
Expand All @@ -232,7 +236,9 @@ var serializeHost = function (host) {
}
}
return '[' + result + ']';
} return host;
}

return host;
};

var C0ControlPercentEncodeSet = {};
Expand Down
2 changes: 1 addition & 1 deletion tests/eslint/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const base = {
// disallow deletion of variables
'no-delete-var': ERROR,
// disallow else after a return in an if
'no-else-return': ERROR,
'no-else-return': [ERROR, { allowElseIf: false }],
// disallow empty statements
'no-empty': ERROR,
// disallow empty functions, except for standalone funcs/arrows
Expand Down

0 comments on commit 65dd82a

Please sign in to comment.