Skip to content

Commit 82a2434

Browse files
authored
Use Intl.ListFormat#format (#2122)
1 parent 7564135 commit 82a2434

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

rules/import-style.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,6 @@ const getActualAssignmentTargetImportStyles = assignmentTarget => {
103103
return [];
104104
};
105105

106-
const joinOr = words => words
107-
.map((word, index) => {
108-
if (index === words.length - 1) {
109-
return word;
110-
}
111-
112-
if (index === words.length - 2) {
113-
return word + ' or';
114-
}
115-
116-
return word + ',';
117-
})
118-
.join(' ');
119-
120106
const isAssignedDynamicImport = node =>
121107
node.parent.type === 'AwaitExpression'
122108
&& node.parent.argument === node
@@ -183,7 +169,7 @@ const create = context => {
183169
}
184170

185171
const data = {
186-
allowedStyles: joinOr([...allowedImportStyles.keys()]),
172+
allowedStyles: new Intl.ListFormat('en-US', {type: 'disjunction'}).format([...allowedImportStyles.keys()]),
187173
moduleName,
188174
};
189175

test/import-style.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ test({
592592
errors: [{
593593
messageId: 'importStyle',
594594
data: {
595-
allowedStyles: 'named, namespace or default',
595+
allowedStyles: 'named, namespace, or default',
596596
moduleName: 'no-unassigned',
597597
},
598598
}],

0 commit comments

Comments
 (0)