This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing bug where the worker thread would hang if there wasn't a tslin…
…t.json file (#160)
- Loading branch information
1 parent
65ff796
commit 01a482b
Showing
4 changed files
with
84 additions
and
88 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,2 @@ | ||
const foo = 42; | ||
export default foo; |
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,95 +1,82 @@ | ||
'use babel'; | ||
|
||
import * as path from 'path'; | ||
// NOTE: If using 'fit' you must add it to the list below! | ||
import { beforeEach, it } from 'jasmine-fix'; // eslint-disable-line import/no-extraneous-dependencies | ||
import linterTslint from '../lib/main'; | ||
|
||
const validPath = path.join(__dirname, 'fixtures', 'valid', 'valid.ts'); | ||
// Fixture paths | ||
const invalidPath = path.join(__dirname, 'fixtures', 'invalid', 'invalid.ts'); | ||
|
||
describe('The TSLint provider for Linter', () => { | ||
const lint = require('../lib/main.js').provideLinter().lint; | ||
|
||
beforeEach(() => { | ||
atom.workspace.destroyActivePaneItem(); | ||
|
||
waitsForPromise(() => | ||
Promise.all([ | ||
atom.packages.activatePackage('linter-tslint'), | ||
]), | ||
); | ||
}); | ||
|
||
it('finds nothing wrong with a valid file', () => { | ||
waitsForPromise(() => | ||
atom.workspace.open(validPath).then(editor => lint(editor)).then((messages) => { | ||
expect(messages.length).toBe(0); | ||
}), | ||
); | ||
}); | ||
|
||
it('handles messages from TSLint', () => { | ||
const expectedMsg = 'semicolon - Missing semicolon'; | ||
waitsForPromise(() => | ||
atom.workspace.open(invalidPath).then(editor => lint(editor)).then((messages) => { | ||
expect(messages.length).toBe(1); | ||
expect(messages[0].type).toBe('warning'); | ||
expect(messages[0].html).not.toBeDefined(); | ||
expect(messages[0].text).toBe(expectedMsg); | ||
expect(messages[0].filePath).toBe(invalidPath); | ||
expect(messages[0].range).toEqual([[0, 14], [0, 14]]); | ||
}), | ||
); | ||
}); | ||
|
||
it('handles undefined filepath', () => { | ||
waitsForPromise(() => | ||
atom.workspace.open().then(editor => lint(editor)).then((result) => { | ||
expect(result).toBeNull(); | ||
}), | ||
); | ||
}); | ||
}); | ||
|
||
const noConfigPath = path.join(__dirname, 'fixtures', 'no-config', 'noConfig.ts'); | ||
const validPath = path.join(__dirname, 'fixtures', 'valid', 'valid.ts'); | ||
const validTypecheckedPath = path.join(__dirname, 'fixtures', 'valid-typechecked', 'valid-typechecked.ts'); | ||
const invalidTypecheckedPath = path.join(__dirname, 'fixtures', 'invalid-typechecked', 'invalid-typechecked.ts'); | ||
|
||
describe('The TSLint provider for Linter (with semantic rules)', () => { | ||
const lint = require('../lib/main.js').provideLinter().lint; | ||
|
||
beforeEach(() => { | ||
atom.workspace.destroyActivePaneItem(); | ||
|
||
waitsForPromise(() => | ||
Promise.all([ | ||
atom.packages.activatePackage('linter-tslint'), | ||
]), | ||
); | ||
|
||
atom.config.set('linter-tslint.enableSemanticRules', true); | ||
}); | ||
|
||
afterEach(() => { | ||
atom.config.set('linter-tslint.enableSemanticRules', false); | ||
}); | ||
describe('The TSLint provider for Linter', () => { | ||
const lint = linterTslint.provideLinter().lint; | ||
|
||
it('finds nothing wrong with a valid file', () => { | ||
waitsForPromise(() => | ||
atom.workspace.open(validTypecheckedPath).then(editor => lint(editor)).then((messages) => { | ||
expect(messages.length).toBe(0); | ||
}), | ||
); | ||
beforeEach(async () => { | ||
await atom.packages.activatePackage('linter-tslint'); | ||
}); | ||
|
||
it('handles messages from TSLint', () => { | ||
const expectedMsg = 'no-boolean-literal-compare - This expression is unnecessarily compared to a boolean. Just use it directly.'; | ||
waitsForPromise(() => | ||
atom.workspace.open(invalidTypecheckedPath).then(editor => lint(editor)).then((messages) => { | ||
expect(messages.length).toBe(1); | ||
expect(messages[0].type).toBe('error'); | ||
expect(messages[0].html).not.toBeDefined(); | ||
expect(messages[0].text).toBe(expectedMsg); | ||
expect(messages[0].filePath).toBe(invalidTypecheckedPath); | ||
expect(messages[0].range).toEqual([[1, 0], [1, 1]]); | ||
}), | ||
); | ||
describe('When the package is activated', () => { | ||
describe('When dealing with typechecking off (no semantic rules)', () => { | ||
it('finds nothing wrong with a valid file', async () => { | ||
const editor = await atom.workspace.open(validPath); | ||
const result = await lint(editor); | ||
expect(result.length).toBe(0); | ||
}); | ||
|
||
it('handles messages from TSLint', async () => { | ||
const expectedMsg = 'semicolon - Missing semicolon'; | ||
const editor = await atom.workspace.open(invalidPath); | ||
const result = await lint(editor); | ||
expect(result.length).toBe(1); | ||
expect(result[0].type).toBe('warning'); | ||
expect(result[0].html).not.toBeDefined(); | ||
expect(result[0].text).toBe(expectedMsg); | ||
expect(result[0].filePath).toBe(invalidPath); | ||
expect(result[0].range).toEqual([[0, 14], [0, 14]]); | ||
}); | ||
|
||
it('handles undefined filepath', async () => { | ||
const editor = await atom.workspace.open(); | ||
const result = await lint(editor); | ||
expect(result).toBeNull(); | ||
}); | ||
|
||
it('finishes validatation even when there is no tslint.json', async () => { | ||
const editor = await atom.workspace.open(noConfigPath); | ||
await lint(editor); | ||
}); | ||
}); | ||
|
||
describe('When dealing with typechecking on (with semantic rules)', () => { | ||
beforeEach(() => { | ||
atom.config.set('linter-tslint.enableSemanticRules', true); | ||
}); | ||
|
||
afterEach(() => { | ||
atom.config.set('linter-tslint.enableSemanticRules', false); | ||
}); | ||
|
||
it('finds nothing wrong with a valid file', async () => { | ||
const editor = await atom.workspace.open(validTypecheckedPath); | ||
const result = await lint(editor); | ||
expect(result.length).toBe(0); | ||
}); | ||
|
||
it('handles messages from TSLint', async () => { | ||
const expectedMsg = 'no-boolean-literal-compare - This expression is unnecessarily compared to a boolean. Just use it directly.'; | ||
const editor = await atom.workspace.open(invalidTypecheckedPath); | ||
const result = await lint(editor); | ||
expect(result.length).toBe(1); | ||
expect(result[0].type).toBe('error'); | ||
expect(result[0].html).not.toBeDefined(); | ||
expect(result[0].text).toBe(expectedMsg); | ||
expect(result[0].filePath).toBe(invalidTypecheckedPath); | ||
expect(result[0].range).toEqual([[1, 0], [1, 1]]); | ||
}); | ||
}); | ||
}); | ||
}); |