index.js 680 B

12345678910111213141516171819202122
  1. "use strict";
  2. exports.parse = function(code, options) {
  3. return exports.parseForESLint(code, options).ast;
  4. };
  5. exports.parseForESLint = function(code, options) {
  6. options = options || {};
  7. options.ecmaVersion = options.ecmaVersion || 2018;
  8. options.sourceType = options.sourceType || "module";
  9. options.allowImportExportEverywhere =
  10. options.allowImportExportEverywhere || false;
  11. if (options.eslintVisitorKeys && options.eslintScopeManager) {
  12. return require("./parse-with-scope")(code, options);
  13. }
  14. return { ast: require("./parse-with-patch")(code, options) };
  15. };
  16. exports.parseNoPatch = function(code, options) {
  17. return require("./parse")(code, options);
  18. };