Skip to content

Commit

Permalink
fix linting and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren committed Apr 10, 2017
1 parent bf53d9c commit f1cffff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const merge = (options, config) => {
return Object.assign(opts, config);
};

const lint = exports.lint = (input, opts) => {
const lint = (input, opts) => {
if (typeof input !== 'string') {
return Promise.reject(new TypeError('No input provided.'));
}
Expand Down Expand Up @@ -86,6 +86,8 @@ const lint = exports.lint = (input, opts) => {
.then(() => validations);
};

exports.lint = lint;

exports.fix = (input, opts) => {
const fs = new FileSystem();
const fixer = new Fixer();
Expand Down
4 changes: 2 additions & 2 deletions test/max-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ test('max depth fail', async t => {
);
});

test('max depth is not a number', t => {
test('max depth is not a number', async t => {
const ruleTester = clintonRuleTester(Object.assign({}, opts, {rules: {'max-depth': ['error', '5']}}));

t.throws(ruleTester(t, '.'), 'Expected `max-depth` to be of type `number`, got `string`');
await t.throws(ruleTester(t, '.'), 'Expected `max-depth` to be of type `number`, got `string`');
});
4 changes: 2 additions & 2 deletions test/pkg-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ test('missing required version property', async t => {
);
});

test('fails on incorrect options object', t => {
test('fails on incorrect options object', async t => {
const ruleTester = clintonRuleTester(Object.assign({}, opts, {rules: {'pkg-schema': ['error', 'foo']}}));

t.throws(ruleTester(t, '.'), 'Expected options to be of type `object`, got `string`');
await t.throws(ruleTester(t, '.'), 'Expected options to be of type `object`, got `string`');
});
12 changes: 6 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import figures from 'figures';
import {lint as m} from '../';

test('project does not exist', async t => {
t.throws(m('foo/bar'), 'Path foo/bar does not exist.');
await t.throws(m('foo/bar'), 'Path foo/bar does not exist.');
});

test('no project provided', async t => {
t.throws(m(), 'No input provided.');
await t.throws(m(), 'No input provided.');
});

test('no errors', async t => {
Expand Down Expand Up @@ -39,10 +39,10 @@ test('`ignores` option', async t => {
t.is(result.length, 0);
});

test('unknown plugin', t => {
t.throws(m('.', {cwd: './', plugins: ['foo'], rules: {foo: 'error'}}), 'Could not find module for plugin \'foo\'.');
test('unknown plugin', async t => {
await t.throws(m('.', {cwd: './', plugins: ['foo'], rules: {foo: 'error'}}), 'Could not find module for plugin \'foo\'.');
});

test('cli', t => {
t.throws(execa('./cli.js', ['test/fixtures/valid-version/invalid-version', '--no-inherit']), new RegExp(`[ ]*?${figures.cross}[ ]*?The specified version in package.json is invalid.[ ]*valid-version`));
test('cli', async t => {
await t.throws(execa('./cli.js', ['test/fixtures/valid-version/invalid-version', '--no-inherit']), new RegExp(`[ ]*?${figures.cross}[ ]*?The specified version in package.json is invalid.[ ]*valid-version`));
});

0 comments on commit f1cffff

Please sign in to comment.