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

Commit a48d10c

Browse files
committed
Defer package dependency checking
Move the checking of package dependencies to an idle callback. Also opportunisticly loads the dependencies in the callback so they are ready for the first lint call. Fixes #59.
1 parent dcf01f4 commit a48d10c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,17 @@ const loadDeps = () => {
5252

5353
export default {
5454
activate() {
55-
require('atom-package-deps').install('linter-htmlhint');
55+
this.idleCallbacks = new Set();
56+
let depsCallbackID;
57+
const installLinterHtmlhintDeps = () => {
58+
this.idleCallbacks.delete(depsCallbackID);
59+
if (!atom.inSpecMode()) {
60+
require('atom-package-deps').install('linter-htmlhint');
61+
}
62+
loadDeps();
63+
};
64+
depsCallbackID = window.requestIdleCallback(installLinterHtmlhintDeps);
65+
this.idleCallbacks.add(depsCallbackID);
5666

5767
this.grammarScopes = [];
5868

@@ -66,6 +76,8 @@ export default {
6676
},
6777

6878
deactivate() {
79+
this.idleCallbacks.forEach(callbackID => window.cancelIdleCallback(callbackID));
80+
this.idleCallbacks.clear();
6981
this.subscriptions.dispose();
7082
},
7183

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"homepage": "https://github.com/AtomLinter/linter-htmlhint#readme",
4444
"dependencies": {
4545
"atom-linter": "^10.0.0",
46-
"atom-package-deps": "^4.0.1",
46+
"atom-package-deps": "^4.6.0",
4747
"htmlhint": "0.9.13",
4848
"strip-json-comments": "^2.0.1",
4949
"tiny-promisify": "^1.0.0"
@@ -75,6 +75,7 @@
7575
"atom": true
7676
},
7777
"env": {
78+
"browser": true,
7879
"node": true
7980
}
8081
},

0 commit comments

Comments
 (0)