Skip to content

Commit 1385310

Browse files
committed
Fix: When forcing the JS parser, use the modern name (#212)
This avoids a deprecation notice
1 parent bca77e6 commit 1385310

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

eslint-plugin-prettier.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,13 @@ module.exports = {
210210
if (
211211
parserBlocklist.indexOf(prettierFileInfo.inferredParser) !== -1
212212
) {
213-
initialOptions.parser = 'babylon';
213+
// Prettier v1.16.0 renamed the `babylon` parser to `babel`
214+
// Use the modern name if available
215+
const supportBabelParser = prettier
216+
.getSupportInfo()
217+
.languages.some(language => language.parsers.includes('babel'));
218+
219+
initialOptions.parser = supportBabelParser ? 'babel' : 'babylon';
214220
}
215221

216222
const prettierOptions = Object.assign(

0 commit comments

Comments
 (0)