From 4c1fb5cea83f129964b835fc4320405b4388acf0 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Fri, 18 Nov 2016 16:22:42 +0100 Subject: [PATCH 1/2] Improve Atom startup time Before this change, activation was done on Atom startup, whether or not you actually had any Javascript files open. With this change in place, we postpone activation until the Atom Javascript grammar's first use. This improves startup time of my Atom by about 180ms, thus fixing one of the top startup time offenders according to TimeCop. For some frame of reference, I have 87 packages installed, and Timecop lists all packages with startup times above 5ms. --- package.json | 1 + spec/linter-eslint-spec.js | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index ec942ae0..269a6257 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "engines": { "atom": ">=1.10.0 <2.0.0" }, + "activationHooks": ["language-javascript:grammar-used"], "configSchema": { "lintHtmlFiles": { "title": "Lint HTML Files", diff --git a/spec/linter-eslint-spec.js b/spec/linter-eslint-spec.js index 877f3c48..0613116c 100644 --- a/spec/linter-eslint-spec.js +++ b/spec/linter-eslint-spec.js @@ -40,14 +40,22 @@ describe('The eslint provider for Linter', () => { atom.config.set('linter-eslint.disableFSCache', false) atom.config.set('linter-eslint.disableEslintIgnore', true) + // This whole beforeEach function is inspired by: + // https://github.com/AtomLinter/linter-jscs/pull/295/files + // + // See also: + // https://discuss.atom.io/t/activationhooks-break-unit-tests/36028/8 + const activationPromise = + atom.packages.activatePackage('linter-eslint') + waitsForPromise(() => - Promise.all([ - atom.packages.activatePackage('language-javascript'), - atom.packages.activatePackage('linter-eslint'), - ]).then(() => - atom.workspace.open(goodPath) - ) - ) + atom.packages.activatePackage('language-javascript')) + + waitsForPromise(() => + atom.workspace.open(goodPath)) + + atom.packages.triggerDeferredActivationHooks() + waitsForPromise(() => activationPromise) }) describe('checks bad.js and', () => { From 70e3ea9a54418ced6f1243bacee9dd686ffb4f5d Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Fri, 18 Nov 2016 22:57:09 +0100 Subject: [PATCH 2/2] Remedy review feedback --- spec/linter-eslint-spec.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/spec/linter-eslint-spec.js b/spec/linter-eslint-spec.js index 0613116c..bbfb0471 100644 --- a/spec/linter-eslint-spec.js +++ b/spec/linter-eslint-spec.js @@ -40,19 +40,15 @@ describe('The eslint provider for Linter', () => { atom.config.set('linter-eslint.disableFSCache', false) atom.config.set('linter-eslint.disableEslintIgnore', true) - // This whole beforeEach function is inspired by: - // https://github.com/AtomLinter/linter-jscs/pull/295/files - // - // See also: - // https://discuss.atom.io/t/activationhooks-break-unit-tests/36028/8 + // Info about this beforeEach() implementation: + // https://github.com/AtomLinter/Meta/issues/15 const activationPromise = atom.packages.activatePackage('linter-eslint') waitsForPromise(() => - atom.packages.activatePackage('language-javascript')) - - waitsForPromise(() => - atom.workspace.open(goodPath)) + atom.packages.activatePackage('language-javascript').then(() => + atom.workspace.open(goodPath)) + ) atom.packages.triggerDeferredActivationHooks() waitsForPromise(() => activationPromise)