Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added babel plugin to support numeric separators in test files #224

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@babel/parser": "^7.2.3",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.1.2",
"@babel/plugin-proposal-numeric-separator": "^7.16.7",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
"@babel/polyfill": "^7.0.0",
Expand Down
18 changes: 12 additions & 6 deletions server/services/ast/parser.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import * as parser from "@babel/parser";
import { extname } from "path";
import * as parser from '@babel/parser';
import { extname } from 'path';

export function parse(path: string, code: string) {
const isTS = [".ts", ".tsx"].indexOf(extname(path).toLowerCase()) > -1;
const additionalPlugin = isTS ? "typescript" : "flow";
const isTS = ['.ts', '.tsx'].indexOf(extname(path).toLowerCase()) > -1;
const additionalPlugin = isTS ? 'typescript' : 'flow';

return parser.parse(code, {
sourceType: "module",
plugins: ["jsx", "classProperties", "optionalChaining", additionalPlugin]
sourceType: 'module',
plugins: [
'jsx',
'classProperties',
'optionalChaining',
'numericSeparator',
additionalPlugin,
],
});
}