assertEsLintSupport.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. var __importStar = (this && this.__importStar) || function (mod) {
  3. if (mod && mod.__esModule) return mod;
  4. var result = {};
  5. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  6. result["default"] = mod;
  7. return result;
  8. };
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. const semver = __importStar(require("semver"));
  11. function assertEsLintSupport(configuration) {
  12. if (semver.lt(process.version, '8.10.0')) {
  13. throw new Error(`To use 'eslint' option, please update to Node.js >= v8.10.0 ` +
  14. `(current version is ${process.version})`);
  15. }
  16. let eslintVersion;
  17. try {
  18. eslintVersion = require('eslint').Linter.version;
  19. }
  20. catch (error) {
  21. throw new Error(`When you use 'eslint' option, make sure to install 'eslint'.`);
  22. }
  23. if (semver.lt(eslintVersion, '6.0.0')) {
  24. throw new Error(`Cannot use current eslint version of ${eslintVersion}, the minimum required version is 6.0.0`);
  25. }
  26. if (!configuration.files) {
  27. throw new Error('The `eslint.files` settings is required for EsLint reporter to work.');
  28. }
  29. }
  30. exports.assertEsLintSupport = assertEsLintSupport;