Как подавить исключение линтинга

У меня есть эта задача gulp в моем gulpfile.js, которая выглядит так

      const runeslint = (cb) => Promise.all(
     gulp.src('./Scripts/**/*.ts')
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError())
).finally(cb);

При запуске из командной строки с помощью gulp runeslint я получаю красиво отформатированный набор сообщений об ошибках, но затем в конце он также печатает около 100 строк текста исключения. Текст выглядит как строковое представление исключения, которое было сгенерировано из-за ошибки, отмеченной eslint в моем машинописном тексте. Мне нужен красиво отформатированный вывод ошибок. Мне также нужно поведение обработки failAfterError, чтобы, если runeslint используется как один шаг в серии шагов, остальные шаги не будут выполнены, если произошла ошибка линтинга. Единственное, чего я не хочу, - это чтобы gulp распечатал версию исключения tostring. Это бесполезно и полностью загромождает выходные журналы.

Я вижу в https://github.com/adametry/gulp-eslint/blob/master/index.js, что failAfterError выдает, если обнаружены какие-либо ошибки. Но везде, где я пытаюсь подавить это исключение, это либо нарушает поведение failAfterError, либо не подавляет распечатку ошибки в моих журналах. Какие-либо предложения?

Я поместил полный вывод ошибки ниже, но я убрал некоторые специфические для компании вещи. Видите, это даже загромождает этот пост :)

      C:\company-secret-stuff\gulp runeslint
[09:44:46] Using gulpfile ~\source\repos\company-secret-stuff\gulpfile.js
[09:44:46] Starting 'runeslint'...
an error occurred
[09:44:46] Finished 'runeslint' after 64 ms
Warning: React version was set to "detect" in eslint-plugin-react settings, but the "react" package is not installed. Assuming latest React version for linting.
[09:44:49]
C:\company-secret-stuff\Scripts\HelloWorld.ts
  2:2   warning  Missing return type on function     @typescript-eslint/explicit-module-boundary-types
  2:28  error    Missing space before opening brace  space-before-blocks
  3:3   warning  Unexpected console statement        no-console

✖ 3 problems (1 error, 2 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.


events.js:292
      throw er; // Unhandled 'error' event
      ^
<ref *1> [PluginError [ESLintError]: Failed with 1 error] {
  plugin: 'gulp-eslint',
  showProperties: true,
  showStack: false,
  __safety: { toString: [Function: bound ] },
  domainEmitter: Transform {
    _readableState: ReadableState {
      objectMode: true,
      highWaterMark: 16,
      buffer: BufferList {
        head: {
          data: File {
            stat: [Stats],
            _contents: [Buffer [Uint8Array]],
            history: [Array],
            _cwd: 'C:\\company-secret-stuff',
            _base: 'C:\\company-secret-stuff\\Scripts',
            _isVinyl: true,
            _symlink: null,
            eslint: [Object]
          },
          next: { data: [File], next: null }
        },
        tail: {
          data: File {
            stat: [Stats],
            _contents: [Buffer [Uint8Array]],
            history: [Array],
            _cwd: C:\\company-secret-stuff',
            _base: 'C:\\company-secret-stuff\\Scripts',
            _isVinyl: true,
            _symlink: null,
            eslint: [Object]
          },
          next: null
        },
        length: 2
      },
      length: 2,
      pipes: [],
      flowing: null,
      ended: false,
      endEmitted: false,
      reading: true,
      sync: false,
      needReadable: true,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      errorEmitted: true,
      emitClose: true,
      autoDestroy: true,
      destroyed: true,
      errored: [Circular *1],
      closed: true,
      closeEmitted: false,
      defaultEncoding: 'utf8',
      awaitDrainWriters: null,
      multiAwaitDrain: false,
      readingMore: false,
      decoder: null,
      encoding: null,
      [Symbol(kPaused)]: null
    },
    _events: [Object: null prototype] { prefinish: [Function: prefinish] },
    _eventsCount: 1,
    _maxListeners: undefined,
    _writableState: WritableState {
      objectMode: true,
      highWaterMark: 16,
      finalCalled: false,
      needDrain: false,
      ending: true,
      ended: true,
      finished: false,
      destroyed: true,
      decodeStrings: true,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: false,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      afterWriteTickInfo: null,
      buffered: [],
      bufferedIndex: 0,
      allBuffers: true,
      allNoop: true,
      pendingcb: 1,
      prefinished: true,
      errorEmitted: true,
      emitClose: true,
      autoDestroy: true,
      errored: [Circular *1],
      closed: true
    },
    allowHalfOpen: true,
    _transform: [Function (anonymous)],
    _flush: [Function (anonymous)],
    [Symbol(kCapture)]: false,
    [Symbol(kTransformState)]: {
      afterTransform: [Function: bound afterTransform],
      needTransform: true,
      transforming: false,
      writecb: null,
      writechunk: null,
      writeencoding: 'utf8'
    }
  },
  domainThrown: false
}

0 ответов

Другие вопросы по тегам