Skip to content

Commit

Permalink
Simplify englishishJoinWords (#1726)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Feb 10, 2022
1 parent 4370602 commit e8ab176
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions rules/filename-case.js
Expand Up @@ -130,17 +130,7 @@ Turns `[a, b, c]` into `a, b, or c`.
@param {string[]} words
@returns {string}
*/
function englishishJoinWords(words) {
if (words.length === 1) {
return words[0];
}

if (words.length === 2) {
return `${words[0]} or ${words[1]}`;
}

return `${words.slice(0, -1).join(', ')}, or ${words[words.length - 1]}`;
}
const englishishJoinWords = words => new Intl.ListFormat('en-US', {type: 'disjunction'}).format(words);

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => {
Expand Down

0 comments on commit e8ab176

Please sign in to comment.