Skip to content
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
2 changes: 2 additions & 0 deletions src/lib/complexity/strategies/cyclomatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function calculate(path: string): number | UnsupportedExtension {
function fromJavaScript(path: string): number {
const content = readFileSync(path, { encoding: "utf8" });
const babelResult = transformSync(content, {
filename: path,
presets: ["@babel/preset-env"],
});
if (!babelResult) throw new Error(`Error while parsing file ${path}`);
Expand All @@ -37,6 +38,7 @@ function fromJavaScript(path: string): number {
function fromTypeScript(path: string): number {
const content = readFileSync(path, { encoding: "utf8" });
const babelResult = transformSync(content, {
filename: path,
plugins: ["@babel/plugin-transform-typescript"],
presets: ["@babel/preset-env"],
});
Expand Down
2 changes: 2 additions & 0 deletions src/lib/complexity/strategies/halstead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function calculate(path: string): number | UnsupportedExtension {
function fromJavaScript(path: string): number {
const content = readFileSync(path, { encoding: "utf8" });
const babelResult = transformSync(content, {
filename: path,
presets: ["@babel/preset-env"],
});
if (!babelResult) throw new Error(`Error while parsing file ${path}`);
Expand All @@ -36,6 +37,7 @@ function fromJavaScript(path: string): number {
function fromTypeScript(path: string): number {
const content = readFileSync(path, { encoding: "utf8" });
const babelResult = transformSync(content, {
filename: path,
plugins: ["@babel/plugin-transform-typescript"],
presets: ["@babel/preset-env"],
});
Expand Down