-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: add full-of-problems test from eslint example - https://eslint.org/docs/user-guide/formatters/#eslint-formatters - This provides a single file with a variety of errors and warnings * test: add test using full-of-problems and quiet flag - when linting a file that has both warnings and errors, if the quiet flag is set, then the errors should be emited, but the warnings should not * test: add emit-error and emit-warning tests - replace force-emit-error and force-emit-warning tests with more robust tests that match the functionality of eslint-loader - if emitError is undefined or true, it should emit errors, otherwise if emitError is false, it should suppress errors - if emitWarning is undefined or true, it should emit warnings, otherwise if emitWarning is false, it should suppress warnings * fix: suppress warnings when emitWarning is set to false - print errors only when emitError is undefined or true, otherwise suppress errors - print warnings only when emitWarning is undefined or true, otherwise suppress warnings - this allows the config to be set up to lint a file that has both warnings and errors and only show the relevant errors or warnings fix #19 BREAKING CHANGE: Updates to emitError and emitWarning Setting only emitError to true will no longer exclusively print files with errors and disregard the files with warnings. Similarly, setting only emitWarning to true will no longer exclusively print files with warnings disregard the files with errors. * fix: use quiet to override emitError and emitWarning - quiet is essentially syntactic sugar for setting emitError to true and emitWarning to false fix #19
- Loading branch information
1 parent
f7f372e
commit d38165b
Showing
9 changed files
with
181 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import pack from './utils/pack'; | ||
|
||
describe('emit error', () => { | ||
it('should not emit errors if emitError is false', (done) => { | ||
const compiler = pack('error', { emitError: false }); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasErrors()).toBe(false); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should emit errors if emitError is undefined', (done) => { | ||
const compiler = pack('error', {}); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasErrors()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should emit errors if emitError is true', (done) => { | ||
const compiler = pack('error', { emitError: true }); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasErrors()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should emit errors, but not warnings if emitError is true and emitWarning is false', (done) => { | ||
const compiler = pack('full-of-problems', { | ||
emitError: true, | ||
emitWarning: false, | ||
}); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(false); | ||
expect(stats.hasErrors()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should emit errors and warnings if emitError is true and emitWarning is undefined', (done) => { | ||
const compiler = pack('full-of-problems', { emitError: true }); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(true); | ||
expect(stats.hasErrors()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import pack from './utils/pack'; | ||
|
||
describe('emit warning', () => { | ||
it('should not emit warnings if emitWarning is false', (done) => { | ||
const compiler = pack('warn', { emitWarning: false }); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(false); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should emit warnings if emitWarning is undefined', (done) => { | ||
const compiler = pack('warn', {}); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should emit warnings if emitWarning is true', (done) => { | ||
const compiler = pack('warn', { emitWarning: true }); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should emit warnings, but not warnings if emitWarning is true and emitError is false', (done) => { | ||
const compiler = pack('full-of-problems', { | ||
emitWarning: true, | ||
emitError: false, | ||
}); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(true); | ||
expect(stats.hasErrors()).toBe(false); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should emit warnings and errors if emitWarning is true and emitError is undefined', (done) => { | ||
const compiler = pack('full-of-problems', { emitWarning: true }); | ||
|
||
compiler.run((err, stats) => { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(true); | ||
expect(stats.hasErrors()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('./full-of-problems'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* eslint consistent-return: "error" */ | ||
/* eslint indent: ["warn", 4] */ | ||
/* eslint no-else-return: "warn" */ | ||
/* eslint semi: ["warn", "always"] */ | ||
/* eslint space-unary-ops: "error" */ | ||
|
||
function addOne(i) { | ||
if (i != NaN) { | ||
return i ++ | ||
} else { | ||
return | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters