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

Checking for null/undefined filePath from editor. #156

Merged
merged 3 commits into from
Apr 14, 2017
Merged

Checking for null/undefined filePath from editor. #156

merged 3 commits into from
Apr 14, 2017

Conversation

Xapphire13
Copy link
Contributor

Fixes #155


if (filePath === null || filePath === undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this only ever returns a path or undefined, no reason not to check both though 😉.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Usually I prefer doing a value == undefined since this type-juggles null also. But the linting rules in this project disallow == even in the undefined case =[


it('handles null filepath', () => {
waitsForPromise(() =>
atom.workspace.open(null).then(editor => lint(editor)).then((result) => {
Copy link
Member

Choose a reason for hiding this comment

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

atom.workspace.open() is sufficient here, and the second case is doing nothing since the problematic textEditor.getPath() doesn't rely on this direct input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feared that might be the case. Ideally the editor input would be mocked out so we can simulate the exact state. I will remove the dupe test =]

@Xapphire13 Xapphire13 merged commit dd9a2d8 into AtomLinter:master Apr 14, 2017
@Xapphire13 Xapphire13 deleted the pathNullCheck branch April 14, 2017 18:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants