api.js 740 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * @fileoverview Expose out ESLint and CLI to require.
  3. * @author Ian Christian Myers
  4. */
  5. "use strict";
  6. const { CLIEngine } = require("./cli-engine");
  7. const { ESLint } = require("./eslint");
  8. const { Linter } = require("./linter");
  9. const { RuleTester } = require("./rule-tester");
  10. const { SourceCode } = require("./source-code");
  11. module.exports = {
  12. Linter,
  13. CLIEngine,
  14. ESLint,
  15. RuleTester,
  16. SourceCode
  17. };
  18. // DOTO: remove deprecated API.
  19. let deprecatedLinterInstance = null;
  20. Object.defineProperty(module.exports, "linter", {
  21. enumerable: false,
  22. get() {
  23. if (!deprecatedLinterInstance) {
  24. deprecatedLinterInstance = new Linter();
  25. }
  26. return deprecatedLinterInstance;
  27. }
  28. });