diff --git a/lib/main.js b/lib/main.js index c7178d3..6e27891 100644 --- a/lib/main.js +++ b/lib/main.js @@ -75,12 +75,24 @@ const generateInvalidPointTrace = async (execPath, match, filePath, textEditor, export default { activate() { - require('atom-package-deps').install('linter-flake8'); + this.idleCallbacks = new Set(); - // FIXME: Remove after a few versions - if (typeof atom.config.get('linter-flake8.disableTimeout') !== 'undefined') { - atom.config.unset('linter-flake8.disableTimeout'); - } + let packageDepsID; + const linterFlake8Deps = () => { + this.idleCallbacks.delete(packageDepsID); + + // Request checking / installation of package dependencies + if (!atom.inSpecMode()) { + require('atom-package-deps').install('linter-flake8'); + } + + // FIXME: Remove after a few versions + if (typeof atom.config.get('linter-flake8.disableTimeout') !== 'undefined') { + atom.config.unset('linter-flake8.disableTimeout'); + } + }; + packageDepsID = window.requestIdleCallback(linterFlake8Deps); + this.idleCallbacks.add(packageDepsID); this.subscriptions = new CompositeDisposable(); this.subscriptions.add( @@ -118,6 +130,8 @@ export default { }, deactivate() { + this.idleCallbacks.forEach(callbackID => window.cancelIdleCallback(callbackID)); + this.idleCallbacks.clear(); this.subscriptions.dispose(); }, diff --git a/package.json b/package.json index b0282de..03e20a8 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,8 @@ "atom": true }, "env": { - "node": true + "node": true, + "browser": true } }, "providedServices": {