-
-
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.
- Loading branch information
1 parent
f819203
commit f7f372e
Showing
2 changed files
with
49 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,49 @@ | ||
import { join } from 'path'; | ||
import { writeFileSync } from 'fs'; | ||
|
||
import { removeSync } from 'fs-extra'; | ||
|
||
import pack from './utils/pack'; | ||
|
||
const target = join(__dirname, 'fixtures', 'lint-dirty-modules-only-entry.js'); | ||
|
||
describe('lint dirty modules only', () => { | ||
let watch; | ||
afterEach(() => { | ||
if (watch) { | ||
watch.close(); | ||
} | ||
removeSync(target); | ||
}); | ||
|
||
it('skips linting on initial run', (done) => { | ||
const compiler = pack('error', { lintDirtyModulesOnly: true }); | ||
writeFileSync(target, 'const foo = false\n'); | ||
|
||
let next = firstPass; | ||
const compiler = pack('lint-dirty-modules-only', { | ||
lintDirtyModulesOnly: true, | ||
}); | ||
watch = compiler.watch({}, (err, stats) => next(err, stats)); | ||
|
||
compiler.run((err, stats) => { | ||
function firstPass(err, stats) { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(false); | ||
expect(stats.hasErrors()).toBe(false); | ||
|
||
next = secondPass; | ||
|
||
writeFileSync(target, 'const bar = false;\n'); | ||
} | ||
|
||
function secondPass(err, stats) { | ||
expect(err).toBeNull(); | ||
expect(stats.hasWarnings()).toBe(false); | ||
expect(stats.hasErrors()).toBe(true); | ||
const { errors } = stats.compilation; | ||
expect(errors.length).toBe(1); | ||
const [{ message }] = errors; | ||
expect(message).toEqual(expect.stringMatching('no-unused-vars')); | ||
done(); | ||
}); | ||
} | ||
}); | ||
}); |