Skip to content

Commit

Permalink
Align babel plugin list with Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
birkskyum committed Aug 7, 2022
2 parents 73bb2a4 + 5d66953 commit f513485
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
12 changes: 12 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

--------------------------------------------------------------------------------

Contains sections of prettier

Copyright © James Long and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 changes: 16 additions & 2 deletions src/parsers/parse_to_ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,28 @@ const TYPESCRIPT_EXTS = {
'.tsx': ['typescript', 'jsx']
};

// this list is roughly the same as the one in prettier
// https://github.com/prettier/prettier/blob/24d39a906834cf449304dc684b280a5ca9a0a6d7/src/language-js/parser-babel.js#L23
export const standardBabelParserPlugins = [
'classPrivateMethods',
'classPrivateProperties',
'classProperties',
'classStaticBlock',
'decimal',
['decorators', { decoratorsBeforeExport: false }],
'doExpressions',
'exportDefaultFrom',
'functionBind',
'functionSent',
'importAssertions',
'moduleBlocks',
'moduleStringNames',
'partialApplication',
['pipelineOperator', { proposal: 'minimal' }],
'throwExpressions'
'privateIn',
['recordAndTuple', { syntaxType: 'hash' }],
'throwExpressions',
'v8intrinsic'
];

function getParserOpts(file) {
Expand All @@ -21,7 +36,6 @@ function getParserOpts(file) {
sourceType: 'module',
plugins: [
...standardBabelParserPlugins,
['decorators', { decoratorsBeforeExport: false }],
...(TYPESCRIPT_EXTS[path.extname(file || '')] || ['flow', 'jsx'])
]
};
Expand Down

0 comments on commit f513485

Please sign in to comment.