Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 7c751cf

Browse files
committed
Use babylon parser directly to disable strict mode
We shouldn't assume that all JavaScript analyzed by this engine will adhere to strict ES6 rules. Instead, use the parser as loosely as possible when analyzing for duplication.
1 parent 91af8e9 commit 7c751cf

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/cc/engine/analyzers/javascript/parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var babel = require('babel');
1+
var babylon = require("babylon");
22

33
process.stdin.resume();
44

@@ -19,7 +19,7 @@ process.stdin.on('data', function(chunk) {
1919
});
2020

2121
process.stdin.on('end', function() {
22-
var ast = babel.transform(source).ast;
22+
var ast = babylon.parse(source, { plugins: ["jsx"], strictMode: false, sourceType: "module" });
2323
var program = ast.program;
2424
console.log(
2525
JSON.stringify(format(program))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"url": "[email protected]:codeclimate/codeclimate-duplication.git"
99
},
1010
"dependencies": {
11-
"babel": "^5.8.23"
11+
"babylon": "^6.1.2"
1212
}
1313
}

0 commit comments

Comments
 (0)