Skip to content

Commit

Permalink
Ignore directories when accepting empty extensions (fixes xojs#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmengels committed Oct 30, 2016
1 parent e216cc2 commit cf773b7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports.lintFiles = (patterns, opts) => {
patterns = '**/*';
}

return globby(patterns, {ignore: opts.ignores}).then(paths => {
return globby(patterns, {'ignore': opts.ignores, 'no-dir': true}).then(paths => {
// filter out unwanted file extensions
// for silly users that don't specify an extension in the glob pattern
paths = paths.filter(x => {
Expand Down
5 changes: 5 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ test('ignore files in .gitignore', async t => {
}
});

test('ignore directories when accepting files without extensions', async () => {
const cwd = path.join(__dirname, 'fixtures/no-extension');
await execa('../../../cli.js', ['--no-local'], {cwd});
});

test('supports being extended with a shareable config', async () => {
const cwd = path.join(__dirname, 'fixtures/project');
await execa('../../../cli.js', ['--no-local'], {cwd});
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/no-extension/child/binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict'

module.exports = function (foo) {
return foo + 'bar'
}
8 changes: 8 additions & 0 deletions test/fixtures/no-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"xo": {
"extensions": ["", ".js"],
"ignores": [
"child/**"
]
}
}

0 comments on commit cf773b7

Please sign in to comment.