Skip to content

Commit

Permalink
Add --silently-ignore
Browse files Browse the repository at this point in the history
Closes GH-24.

Reviewed-by: Titus Wormer <tituswormer@gmail.com>
  • Loading branch information
cl8n committed Jun 9, 2020
1 parent 0f12dcf commit 4700e09
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function options(flags, configuration) {
ignorePath: config.ignorePath,
ignorePathResolveFrom: config.ignorePathResolveFrom,
ignorePatterns: commaSeparated(config.ignorePattern),
silentlyIgnore: config.silentlyIgnore,
detectIgnore: config.ignore,
pluginPrefix: configuration.pluginPrefix,
plugins: plugins(config.use),
Expand Down
5 changes: 5 additions & 0 deletions lib/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@
"description": "output formatted syntax tree",
"type": "boolean"
},
{
"long": "silently-ignore",
"description": "suppress warnings about given ignored files",
"type": "boolean"
},
{
"long": "stdout",
"description": "specify writing to stdout",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/example/HELP
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Options:
--tree-in specify input as syntax tree
--tree-out output syntax tree
--inspect output formatted syntax tree
--silently-ignore suppress warnings about given ignored files
--[no-]stdout specify writing to stdout (on by default)
--[no-]color specify color in report (on by default)
--[no-]config search for configuration files (on by default)
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/example/LONG_FLAG
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Error: Unknown option `--no`, expected:
--tree-in specify input as syntax tree
--tree-out output syntax tree
--inspect output formatted syntax tree
--silently-ignore suppress warnings about given ignored files
--[no-]stdout specify writing to stdout (on by default)
--[no-]color specify color in report (on by default)
--[no-]config search for configuration files (on by default)
Expand Down
46 changes: 46 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,52 @@ test('unified-args', function (t) {
}
})

t.test('should fail when given an ignored path', function (t) {
var expected = [
'one.txt',
' 1:1 error Cannot process specified file: it’s ignored',
'',
'two.txt: no issues found',
'',
figures.cross + ' 1 error'
].join('\n')

t.plan(1)

execa(bin, ['one.txt', 'two.txt', '--ignore-pattern', 'one.txt']).then(
t.fail,
onfail
)

function onfail(result) {
t.deepEqual(
[result.exitCode, strip(result.stderr)],
[1, expected],
'should fail'
)
}
})

t.test('should support `--silently-ignore`', function (t) {
t.plan(1)

execa(bin, [
'one.txt',
'two.txt',
'--ignore-pattern',
'one.txt',
'--silently-ignore'
]).then(onsuccess, t.fail)

function onsuccess(result) {
t.deepEqual(
[result.stdout, strip(result.stderr)],
['', 'two.txt: no issues found'],
'should work'
)
}
})

t.test('should honour `--watch`', function (t) {
var expected = [
'Watching... (press CTRL+C to exit)',
Expand Down

0 comments on commit 4700e09

Please sign in to comment.