-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from kulshekhar/allow-use-strict
Handle 'use strict'
- Loading branch information
Showing
9 changed files
with
129 additions
and
33 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,27 @@ | ||
import { } from 'jest'; | ||
import { } from 'node'; | ||
import runJest from '../__helpers__/runJest'; | ||
|
||
describe('use strict', () => { | ||
|
||
it('should show the error locations for "use strict" violations', () => { | ||
|
||
const result = runJest('../use-strict', ['--no-cache', '-t', 'Invalid Strict']); | ||
|
||
const stderr = result.stderr.toString(); | ||
|
||
expect(result.status).toBe(1); | ||
expect(stderr).toContain('Strict.ts:4:4'); | ||
expect(stderr).toContain('Strict.test.ts:9:5'); | ||
|
||
}); | ||
|
||
it('should work with "use strict"', () => { | ||
|
||
const result = runJest('../use-strict', ['--no-cache', '-t', 'Valid Strict']); | ||
|
||
expect(result.status).toBe(0); | ||
|
||
}); | ||
|
||
}); |
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,5 @@ | ||
'use strict'; | ||
|
||
export function checkStrictValid() { | ||
var v = 33; | ||
} |
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,5 @@ | ||
'use strict'; | ||
|
||
export function checkStrict() { | ||
v = 33; | ||
}; |
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 @@ | ||
declare var jest, describe, it, expect; | ||
|
||
import { checkStrictValid } from '../Strict-valid'; | ||
|
||
describe('Valid Strict', () => { | ||
|
||
it('should not throw an error', () => { | ||
|
||
checkStrictValid(); | ||
|
||
}); | ||
|
||
}); |
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 @@ | ||
declare var jest, describe, it, expect; | ||
|
||
import { checkStrict } from '../Strict'; | ||
|
||
describe('Invalid Strict', () => { | ||
|
||
it('should throw an error on line 9', () => { | ||
|
||
checkStrict(); | ||
|
||
}); | ||
|
||
}); |
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,14 @@ | ||
{ | ||
"jest": { | ||
"transform": { | ||
".(ts|tsx)": "../../preprocessor.js" | ||
}, | ||
"testResultsProcessor": "../../coverageprocessor.js", | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js" | ||
] | ||
} | ||
} |
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,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES5", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noEmitOnError": false, | ||
"jsx": "react", | ||
"allowJs": true | ||
} | ||
} |