From d4fc25d5faa37d8b9dbfaf2cfa317d293cb36bbf Mon Sep 17 00:00:00 2001 From: Eric Bower Date: Thu, 30 Jun 2016 22:47:53 -0400 Subject: [PATCH 1/6] adding scopes to config --- package.json | 8 ++++++++ src/main.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f8b0475e..75eaba86 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,14 @@ "description": "Have eslint attempt to fix some errors automatically when saving the file.", "type": "boolean", "default": false + }, + "scopes": { + "title": "Language scopes to use linter", + "type": "array", + "default": ["source.js", "source.jsx", "source.js.jsx", "source.babel", "source.js-semantic"], + "items": { + "type": "string" + } } }, "scripts": { diff --git a/src/main.js b/src/main.js index c7915ad9..59f5becf 100644 --- a/src/main.js +++ b/src/main.js @@ -11,7 +11,7 @@ module.exports = { this.subscriptions = new CompositeDisposable() this.active = true this.worker = null - this.scopes = ['source.js', 'source.jsx', 'source.js.jsx', 'source.babel', 'source.js-semantic'] + this.scopes = atom.config.get('linter-eslint.scopes') const embeddedScope = 'source.js.embedded.html' this.subscriptions.add(atom.config.observe('linter-eslint.lintHtmlFiles', lintHtmlFiles => { From a10b282215b8c4d6f6dd6b275c6afd450a27259b Mon Sep 17 00:00:00 2001 From: Eric Bower Date: Fri, 1 Jul 2016 22:11:38 -0400 Subject: [PATCH 2/6] compile lib files --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index cc9167e8..e9fb241a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -20,7 +20,7 @@ module.exports = { this.subscriptions = new _atom.CompositeDisposable(); this.active = true; this.worker = null; - this.scopes = ['source.js', 'source.jsx', 'source.js.jsx', 'source.babel', 'source.js-semantic']; + this.scopes = atom.config.get('linter-eslint.scopes'); var embeddedScope = 'source.js.embedded.html'; this.subscriptions.add(atom.config.observe('linter-eslint.lintHtmlFiles', function (lintHtmlFiles) { From 6c2ef2cbd819207d619af262c5494f4704510f78 Mon Sep 17 00:00:00 2001 From: Eric Bower Date: Wed, 6 Jul 2016 19:07:51 -0400 Subject: [PATCH 3/6] newline for default language scope array --- package.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 75eaba86..286e5836 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,13 @@ "scopes": { "title": "Language scopes to use linter", "type": "array", - "default": ["source.js", "source.jsx", "source.js.jsx", "source.babel", "source.js-semantic"], + "default": [ + "source.js", + "source.jsx", + "source.js.jsx", + "source.babel", + "source.js-semantic" + ], "items": { "type": "string" } From 0fbc86ba0f80ad6be772458188910765bcd507d3 Mon Sep 17 00:00:00 2001 From: Eric Bower Date: Thu, 7 Jul 2016 11:43:05 -0400 Subject: [PATCH 4/6] updated scopes description --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 286e5836..7d2cfa51 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "default": false }, "scopes": { - "title": "Language scopes to use linter", + "title": "List of scopes to run ESLint on, run `Editor: Log Cursor Scope` to determine the scopes for a file.", "type": "array", "default": [ "source.js", From 3b3d432351dc605b258649a5e7cb71d54b1b539d Mon Sep 17 00:00:00 2001 From: Eric Bower Date: Thu, 7 Jul 2016 11:44:12 -0400 Subject: [PATCH 5/6] observe scopes config and update when it changes --- lib/main.js | 8 +++++++- src/main.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index e9fb241a..7ec51a02 100644 --- a/lib/main.js +++ b/lib/main.js @@ -20,8 +20,14 @@ module.exports = { this.subscriptions = new _atom.CompositeDisposable(); this.active = true; this.worker = null; - this.scopes = atom.config.get('linter-eslint.scopes'); + this.scopes = new _atom.CompositeDisposable(); + this.scopes.add(atom.config.observe('linter-eslint.scopes', function (scopes) { + // Remove any old scopes + _this.scopes.splice(0, _this.scopes.length); + // Add the current scopes + Array.prototype.push.apply(_this.scopes, scopes); + })); var embeddedScope = 'source.js.embedded.html'; this.subscriptions.add(atom.config.observe('linter-eslint.lintHtmlFiles', function (lintHtmlFiles) { if (lintHtmlFiles) { diff --git a/src/main.js b/src/main.js index 59f5becf..92c38ded 100644 --- a/src/main.js +++ b/src/main.js @@ -11,8 +11,14 @@ module.exports = { this.subscriptions = new CompositeDisposable() this.active = true this.worker = null - this.scopes = atom.config.get('linter-eslint.scopes') + this.scopes = new CompositeDisposable() + this.scopes.add(atom.config.observe('linter-eslint.scopes', scopes => { + // Remove any old scopes + this.scopes.splice(0, this.scopes.length) + // Add the current scopes + Array.prototype.push.apply(this.scopes, scopes) + })) const embeddedScope = 'source.js.embedded.html' this.subscriptions.add(atom.config.observe('linter-eslint.lintHtmlFiles', lintHtmlFiles => { if (lintHtmlFiles) { From ebbbf4fbbe8cfe6f2b0a36f6b09cb10f33d94469 Mon Sep 17 00:00:00 2001 From: Eric Bower Date: Thu, 7 Jul 2016 19:10:25 -0400 Subject: [PATCH 6/6] use subscriptions disposable and not create new one for scopes --- lib/main.js | 4 ++-- src/main.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 7ec51a02..55a5382f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -20,9 +20,9 @@ module.exports = { this.subscriptions = new _atom.CompositeDisposable(); this.active = true; this.worker = null; - this.scopes = new _atom.CompositeDisposable(); + this.scopes = []; - this.scopes.add(atom.config.observe('linter-eslint.scopes', function (scopes) { + this.subscriptions.add(atom.config.observe('linter-eslint.scopes', function (scopes) { // Remove any old scopes _this.scopes.splice(0, _this.scopes.length); // Add the current scopes diff --git a/src/main.js b/src/main.js index 92c38ded..171f4df4 100644 --- a/src/main.js +++ b/src/main.js @@ -11,9 +11,9 @@ module.exports = { this.subscriptions = new CompositeDisposable() this.active = true this.worker = null - this.scopes = new CompositeDisposable() + this.scopes = [] - this.scopes.add(atom.config.observe('linter-eslint.scopes', scopes => { + this.subscriptions.add(atom.config.observe('linter-eslint.scopes', scopes => { // Remove any old scopes this.scopes.splice(0, this.scopes.length) // Add the current scopes