EsLintReporterConfiguration.js 1.2 KB

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const path_1 = require("path");
  4. function castToArray(value) {
  5. if (!value) {
  6. return [];
  7. }
  8. else if (!Array.isArray(value)) {
  9. return [value];
  10. }
  11. else {
  12. return value;
  13. }
  14. }
  15. function createEsLintReporterConfiguration(compiler, options) {
  16. const filesPatterns = (typeof options === 'object' ? castToArray(options.files) : []).map((filesPattern) =>
  17. // ensure that `filesPattern` is an absolute path
  18. path_1.isAbsolute(filesPattern)
  19. ? filesPattern
  20. : path_1.join(compiler.options.context || process.cwd(), filesPattern));
  21. return Object.assign(Object.assign({ enabled: !!options &&
  22. typeof options !== 'boolean' &&
  23. filesPatterns.length > 0 && // enable by default if files are provided
  24. options.enabled !== false, memoryLimit: 2048 }, (typeof options === 'object' ? options : {})), { files: filesPatterns, options: Object.assign({ cwd: compiler.options.context || process.cwd(), extensions: ['.ts', '.tsx', '.js', '.jsx'] }, (typeof options === 'object' ? options.options || {} : {})) });
  25. }
  26. exports.createEsLintReporterConfiguration = createEsLintReporterConfiguration;