Skip to content

Commit

Permalink
fix: allow .js.flow extension (#103)
Browse files Browse the repository at this point in the history
* Fix `.js.flow` bug

Extensions can contain '.js.flow' but `extname` only returns the last one, so it never matches.

https://github.com/prettier/prettier/blob/ef880ec4b93230ac1c45be830ff060e78e0740d8/src/language-js/index.js#L22
https://nodejs.org/api/path.html#path_path_extname_path

* Fix lint

Co-authored-by: Lucas Azzola <[email protected]>
  • Loading branch information
lukeapage and azz authored Aug 21, 2020
1 parent 3370668 commit 5360691
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/isSupportedExtension.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { extname } from 'path';
import { getSupportInfo } from 'prettier';

const extensions = getSupportInfo().languages.reduce(
(prev, language) => prev.concat(language.extensions || []),
[],
);

export default file => extensions.includes(extname(file));
export default file => extensions.some(ext => file.endsWith(ext));

0 comments on commit 5360691

Please sign in to comment.