<commit_before>import * as assert from 'assert';
import { join } from 'path';
import { each } from 'northbrook';
import { defaultStdio } from 'northbrook/helpers';
import { plugin } from './plugin';
import { runLint } from './runLint';

describe('tslint plugin', function () {
  it('is has a handler', () => {
    assert.strictEqual(plugin.type, 'command');
    assert.strictEqual(typeof plugin.handler, 'function');
  });

  it('lints typescript files', function (done) {
    const packageDir = join(__dirname);

    const config = {
      packages: [ join(packageDir, '__test__') ],

      tslint: {
        patterns: [
          /.ts/,
        ],
      },
    };

    const args: Array<string> = [];
    const options: any = {};

    if (!plugin.handler) return done(new Error('No handler was found'));

    each(plugin, (input, io) => runLint(input, io).catch((x: any) => {
      assert.ok(x.stderr.indexOf('packages/tslint/src/__test__/failing.skip.ts[2, 3]') > - 1);
      done();
    }));

    plugin.handler({ config, args, options, directory: packageDir }, defaultStdio);
  });
});<commit_msg>test(tslint): fix test<commit_after>import * as assert from 'assert';
import { join } from 'path';
import { each } from 'northbrook';
import { defaultStdio } from 'northbrook/helpers';
import { plugin } from './plugin';
import { runLint } from './runLint';

describe('tslint plugin', function () {
  it('is has a handler', () => {
    assert.strictEqual(plugin.type, 'command');
    assert.strictEqual(typeof plugin.handler, 'function');
  });

  it('lints typescript files', function (done) {
    const packageDir = join(__dirname);

    const config = {
      packages: [ join(packageDir, '__test__') ],

      tslint: {
        patterns: [
          /.ts/,
        ],
      },
    };

    const args: Array<string> = [];
    const options: any = {};

    if (!plugin.handler) return done(new Error('No handler was found'));

    each(plugin, (input, io) => runLint(input, io).catch((x: any) => {
      assert.ok(x.stderr.indexOf('packages/tslint/src/__test__/failing.skip.ts[2, 3]') > - 1);
      done();
    }));

    plugin.handler({
      config,
      args,
      options,
      directory: packageDir,
      depGraph: {} as any,
    }, defaultStdio);
  });
});
{'fraction_non_alphanumeric': 0.1745262230057294, 'fraction_numerical': 0.002644336712208021, 'mean_word_length': 2.9754816112084064, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4872645', 'n_tokens_mistral': 731, 'n_tokens_neox': 704, 'n_words': 173}