Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Fixing bug where the worker thread would hang if there wasn't a tslint.json file #160

Merged
merged 5 commits into from
Apr 25, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ async function lint(content, filePath, options) {
return path.join(configurationDir, dir);
});

if (rulesDirectory) {
rulesDirectory.push(rulesDirectory);
if (config.rulesDirectory) {
rulesDirectory.push(config.rulesDirectory);
}
}

Expand All @@ -133,8 +133,13 @@ async function lint(content, filePath, options) {
rulesDirectory,
}, options));

linter.lint(filePath, content, configuration);
const lintResult = linter.getResult();
let lintResult;
try {
linter.lint(filePath, content, configuration);
lintResult = linter.getResult();
} catch (err) {
lintResult = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't something be done with this crash? (Logging to the console?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, will add =]

}

if (
// tslint@<5
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/no-config/noConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const foo = 42;
export default foo;
9 changes: 8 additions & 1 deletion spec/linter-tslint-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import * as path from 'path';

const validPath = path.join(__dirname, 'fixtures', 'valid', 'valid.ts');
const invalidPath = path.join(__dirname, 'fixtures', 'invalid', 'invalid.ts');
const noConfigPath = path.join(__dirname, 'fixtures', 'no-config', 'noConfig.ts');
const validPath = path.join(__dirname, 'fixtures', 'valid', 'valid.ts');

describe('The TSLint provider for Linter', () => {
const lint = require('../lib/main.js').provideLinter().lint;
Expand Down Expand Up @@ -47,4 +48,10 @@ describe('The TSLint provider for Linter', () => {
}),
);
});

it('validates even when there is no tslint.json', () => {
waitsForPromise(() =>
atom.workspace.open(noConfigPath).then(editor => lint(editor)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the results be checked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure. In this test I don't care that the file was accurately validated, nor the specific results, I just want to make sure that validation completed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's all that was needed for the test, that's good enough for me.

);
});
});