-
Notifications
You must be signed in to change notification settings - Fork 23
Refactored to perform linting/fixing on async worker task #158
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what I see so far, I like your solution to the "has the worker been started" problem!
this.worker = new Task(require.resolve('./worker.js')); | ||
idleCallbacks.delete(createWorkerCallback); | ||
}); | ||
idleCallbacks.add(createWorkerCallback); | ||
}, | ||
|
||
deactivate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to terminate your worker here in deactivate()
.
lib/main.js
Outdated
if (filePath === null || filePath === undefined) { | ||
return null; | ||
} | ||
const text = textEditor.getText(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this below the worker initialization check so the "conflict window" is as small as possible.
lib/worker.js
Outdated
} | ||
} else { | ||
const { emitKey, jobType, content, filePath } = message.message; | ||
const options = jobType === 'fix' ? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just put this all on one line, there's only the one option.
lib/worker.js
Outdated
|
||
function loadDefaultTSLint() { | ||
if (!tslintDef) { | ||
tslintDef = require('loophole').allowUnsafeNewFunction(() => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need the loophole here? I'm not sure that Atom's CSP actually applies to Task processes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea (since this part was simply moving the methods). I shall try, then get back to you =]
Loosely based on @Arcanemagus's work on eslint/task-api
Caveats