From e062d3547652bb6282a5d6cd2825f41664d67faa Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Fri, 9 Sep 2016 13:09:53 -0700 Subject: [PATCH 1/6] chore(package): update eslint to version 3.5.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de72017c..2b1fe0dd 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "atom-package-deps": "^4.0.1", "consistent-path": "^2.0.1", "escape-html": "^1.0.3", - "eslint": "^2.11.1", + "eslint": "^3.5.0", "eslint-rule-documentation": "^1.0.0", "process-communication": "^1.1.0", "resolve-env": "^1.0.0" From df56916e588b72111296bca28a6c7817e2e90811 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Tue, 13 Sep 2016 03:47:34 -0700 Subject: [PATCH 2/6] chore(package): update eslint-config-airbnb-base to version 7.1.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b1fe0dd..e2834b81 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "resolve-env": "^1.0.0" }, "devDependencies": { - "eslint-config-airbnb-base": "^3.0.1", + "eslint-config-airbnb-base": "^7.1.0", "eslint-plugin-import": "^1.7.0", "ucompiler": "^3.2.0", "ucompiler-plugin-babel": "^3.0.0", From e1e1a24aedace59eb6bab747ce04c2f756e6e6f6 Mon Sep 17 00:00:00 2001 From: Landon Abney Date: Fri, 16 Sep 2016 14:51:13 -0700 Subject: [PATCH 3/6] Update eslint-plugin-import to v1.15.0 Needs at least v1.14.0 to satisfy the peerDependency of eslint-config-airbnb-base. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e2834b81..50d77bdc 100644 --- a/package.json +++ b/package.json @@ -98,12 +98,12 @@ "resolve-env": "^1.0.0" }, "devDependencies": { + "babel-preset-steelbrain": "^4.0.2", "eslint-config-airbnb-base": "^7.1.0", - "eslint-plugin-import": "^1.7.0", + "eslint-plugin-import": "^1.15.0", "ucompiler": "^3.2.0", "ucompiler-plugin-babel": "^3.0.0", - "ucompiler-plugin-newline": "^3.0.0", - "babel-preset-steelbrain": "^4.0.2" + "ucompiler-plugin-newline": "^3.0.0" }, "package-deps": [ "linter" From cdf5206e077d9e3a0aa1e6b3d9e0c7133a924b9c Mon Sep 17 00:00:00 2001 From: Landon Abney Date: Fri, 16 Sep 2016 14:53:24 -0700 Subject: [PATCH 4/6] Bump minimum Atom version to v1.10.0 Atom v1.10.0 was the first version to include a version of APM that could install `eslint@3`. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 50d77bdc..a5886add 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "repository": "https://github.com/AtomLinter/linter-eslint.git", "license": "MIT", "engines": { - "atom": ">=1.8.0 <2.0.0" + "atom": ">=1.10.0 <2.0.0" }, "configSchema": { "lintHtmlFiles": { From df692997f56902bec07fd572dd06f7ea17452fd8 Mon Sep 17 00:00:00 2001 From: Landon Abney Date: Fri, 16 Sep 2016 15:02:06 -0700 Subject: [PATCH 5/6] Fix lint issues --- lib/helpers.js | 13 +++++++----- lib/main.js | 16 +++++++-------- lib/worker.js | 8 ++++---- spec/linter-eslint-spec.js | 41 +++++++++++++++---------------------- spec/worker-helpers-spec.js | 2 +- src/helpers.js | 12 +++++++---- src/main.js | 25 +++++++++++----------- src/worker.js | 5 +++-- 8 files changed, 61 insertions(+), 61 deletions(-) diff --git a/lib/helpers.js b/lib/helpers.js index 012b8f7a..83cadaed 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -11,12 +11,12 @@ var _child_process = require('child_process'); var _child_process2 = _interopRequireDefault(_child_process); -var _atom = require('atom'); - var _processCommunication = require('process-communication'); var _path = require('path'); +var _atom = require('atom'); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function spawnWorker() { @@ -36,11 +36,14 @@ function spawnWorker() { console.log('[Linter-ESLint] STDERR', chunk.toString()); }); - return { worker: worker, subscription: new _atom.Disposable(function () { + return { + worker: worker, + subscription: new _atom.Disposable(function () { worker.kill(); - }) }; + }) + }; } - +// eslint-disable-next-line import/no-extraneous-dependencies function showError(givenMessage) { var givenDetail = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; diff --git a/lib/main.js b/lib/main.js index 564d8573..3c738020 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,10 +1,6 @@ 'use strict'; 'use babel'; -var _atom = require('atom'); - -var _helpers = require('./helpers'); - var _escapeHtml = require('escape-html'); var _escapeHtml2 = _interopRequireDefault(_escapeHtml); @@ -13,8 +9,13 @@ var _eslintRuleDocumentation = require('eslint-rule-documentation'); var _eslintRuleDocumentation2 = _interopRequireDefault(_eslintRuleDocumentation); +var _atom = require('atom'); + +var _helpers = require('./helpers'); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +// eslint-disable-next-line import/no-extraneous-dependencies module.exports = { activate: function activate() { var _this = this; @@ -36,10 +37,8 @@ module.exports = { this.subscriptions.add(atom.config.observe('linter-eslint.lintHtmlFiles', function (lintHtmlFiles) { if (lintHtmlFiles) { _this.scopes.push(embeddedScope); - } else { - if (_this.scopes.indexOf(embeddedScope) !== -1) { - _this.scopes.splice(_this.scopes.indexOf(embeddedScope), 1); - } + } else if (_this.scopes.indexOf(embeddedScope) !== -1) { + _this.scopes.splice(_this.scopes.indexOf(embeddedScope), 1); } })); this.subscriptions.add(atom.workspace.observeTextEditors(function (editor) { @@ -103,6 +102,7 @@ module.exports = { var _this2 = this; var Helpers = require('atom-linter'); + return { name: 'ESLint', grammarScopes: this.scopes, diff --git a/lib/worker.js b/lib/worker.js index 42171a3b..8f842880 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -6,14 +6,14 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path); -var _workerHelpers = require('./worker-helpers'); - -var Helpers = _interopRequireWildcard(_workerHelpers); - var _processCommunication = require('process-communication'); var _atomLinter = require('atom-linter'); +var _workerHelpers = require('./worker-helpers'); + +var Helpers = _interopRequireWildcard(_workerHelpers); + function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } diff --git a/spec/linter-eslint-spec.js b/spec/linter-eslint-spec.js index bfbf4fc1..62cbb69d 100644 --- a/spec/linter-eslint-spec.js +++ b/spec/linter-eslint-spec.js @@ -1,7 +1,7 @@ 'use babel' -import linter from '../lib/main' import * as path from 'path' +import linter from '../lib/main' const goodPath = path.join(__dirname, 'fixtures', 'files', 'good.js') const badPath = path.join(__dirname, 'fixtures', 'files', 'bad.js') @@ -16,6 +16,7 @@ const ignoredPath = path.join(__dirname, 'fixtures', describe('The eslint provider for Linter', () => { const { spawnWorker } = require('../lib/helpers') + const worker = spawnWorker() const lint = linter.provideLinter.call(worker).lint @@ -33,7 +34,7 @@ describe('The eslint provider for Linter', () => { let editor = null beforeEach(() => { waitsForPromise(() => - atom.workspace.open(badPath).then(openEditor => { + atom.workspace.open(badPath).then((openEditor) => { editor = openEditor }) ) @@ -41,21 +42,19 @@ describe('The eslint provider for Linter', () => { it('finds at least one message', () => { waitsForPromise(() => - lint(editor).then(messages => { - expect(messages.length).toBeGreaterThan(0) - }) + lint(editor).then(messages => expect(messages.length).toBeGreaterThan(0)) ) }) it('verifies that message', () => { waitsForPromise(() => - lint(editor).then(messages => { + lint(editor).then((messages) => { expect(messages[0].type).toBe('Error') expect(messages[0].html).not.toBeDefined() expect(messages[0].text).toBe("'foo' is not defined.") expect(messages[0].filePath).toBe(badPath) expect(messages[0].range).toEqual([[0, 0], [0, 3]]) - expect(messages[0].hasOwnProperty('fix')).toBeFalsy() + expect(Object.hasOwnProperty.call(messages[0], 'fix')).toBeFalsy() }) ) }) @@ -64,9 +63,7 @@ describe('The eslint provider for Linter', () => { it('finds nothing wrong with an empty file', () => { waitsForPromise(() => atom.workspace.open(emptyPath).then(editor => - lint(editor).then(messages => { - expect(messages.length).toBe(0) - }) + lint(editor).then(messages => expect(messages.length).toBe(0)) ) ) }) @@ -74,9 +71,7 @@ describe('The eslint provider for Linter', () => { it('finds nothing wrong with a valid file', () => { waitsForPromise(() => atom.workspace.open(goodPath).then(editor => - lint(editor).then(messages => { - expect(messages.length).toBe(0) - }) + lint(editor).then(messages => expect(messages.length).toBe(0)) ) ) }) @@ -85,7 +80,7 @@ describe('The eslint provider for Linter', () => { waitsForPromise(() => atom.workspace.open(fixPath).then(editor => lint(editor) - ).then(messages => { + ).then((messages) => { expect(messages[0].fix.range).toEqual([[0, 11], [0, 12]]) expect(messages[0].fix.newText).toBe('') @@ -99,23 +94,21 @@ describe('The eslint provider for Linter', () => { it('correctly resolves imports from parent', () => { waitsForPromise(() => atom.workspace.open(importingpath).then(editor => - lint(editor).then(messages => { - expect(messages.length).toBe(0) - }) + lint(editor).then(messages => expect(messages.length).toBe(0)) ) ) }) it('shows a message for an invalid import', () => { waitsForPromise(() => atom.workspace.open(badImportPath).then(editor => - lint(editor).then(messages => { + lint(editor).then((messages) => { expect(messages.length).toBeGreaterThan(0) expect(messages[0].type).toBe('Error') expect(messages[0].html).not.toBeDefined() expect(messages[0].text).toBe("Unable to resolve path to module '../nonexistent'.") expect(messages[0].filePath).toBe(badImportPath) expect(messages[0].range).toEqual([[0, 24], [0, 39]]) - expect(messages[0].hasOwnProperty('fix')).toBeFalsy() + expect(Object.hasOwnProperty.call(messages[0], 'fix')).toBeFalsy() }) ) ) @@ -129,9 +122,7 @@ describe('The eslint provider for Linter', () => { it('will not give warnings for the file', () => { waitsForPromise(() => atom.workspace.open(ignoredPath).then(editor => - lint(editor).then(messages => { - expect(messages.length).toBe(0) - }) + lint(editor).then(messages => expect(messages.length).toBe(0)) ) ) }) @@ -143,11 +134,11 @@ describe('The eslint provider for Linter', () => { }) it('should fix lint errors when saved', () => { waitsForPromise(() => - atom.workspace.open(fixPath).then(editor => { - lint(editor).then(messages => { + atom.workspace.open(fixPath).then((editor) => { + lint(editor).then((messages) => { expect(messages.length).toBe(2) editor.save() - lint(editor).then(messagesAfterSave => { + lint(editor).then((messagesAfterSave) => { expect(messagesAfterSave.length).toBe(0) }) }) diff --git a/spec/worker-helpers-spec.js b/spec/worker-helpers-spec.js index e26efb6f..d02c38ea 100644 --- a/spec/worker-helpers-spec.js +++ b/spec/worker-helpers-spec.js @@ -1,8 +1,8 @@ 'use babel' +import * as Path from 'path' import * as Helpers from '../lib/worker-helpers' import { getFixturesPath } from './common' -import * as Path from 'path' describe('Worker Helpers', () => { describe('getESLintInstance && getESLintFromDirectory', () => { diff --git a/src/helpers.js b/src/helpers.js index 62d296b1..00467285 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -1,9 +1,10 @@ 'use babel' import ChildProcess from 'child_process' -import { Disposable } from 'atom' import { createFromProcess } from 'process-communication' import { join } from 'path' +// eslint-disable-next-line import/no-extraneous-dependencies +import { Disposable } from 'atom' export function spawnWorker() { const env = Object.create(process.env) @@ -22,9 +23,12 @@ export function spawnWorker() { console.log('[Linter-ESLint] STDERR', chunk.toString()) }) - return { worker, subscription: new Disposable(() => { - worker.kill() - }) } + return { + worker, + subscription: new Disposable(() => { + worker.kill() + }) + } } export function showError(givenMessage, givenDetail = null) { diff --git a/src/main.js b/src/main.js index 7a2bce75..c4dafafb 100644 --- a/src/main.js +++ b/src/main.js @@ -1,9 +1,11 @@ 'use babel' -import { CompositeDisposable, Range } from 'atom' -import { spawnWorker, showError } from './helpers' import escapeHTML from 'escape-html' import ruleURI from 'eslint-rule-documentation' +// eslint-disable-next-line import/no-extraneous-dependencies +import { CompositeDisposable, Range } from 'atom' + +import { spawnWorker, showError } from './helpers' module.exports = { activate() { @@ -14,20 +16,18 @@ module.exports = { this.worker = null this.scopes = [] - this.subscriptions.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 Array.prototype.push.apply(this.scopes, scopes) })) const embeddedScope = 'source.js.embedded.html' - this.subscriptions.add(atom.config.observe('linter-eslint.lintHtmlFiles', lintHtmlFiles => { + this.subscriptions.add(atom.config.observe('linter-eslint.lintHtmlFiles', (lintHtmlFiles) => { if (lintHtmlFiles) { this.scopes.push(embeddedScope) - } else { - if (this.scopes.indexOf(embeddedScope) !== -1) { - this.scopes.splice(this.scopes.indexOf(embeddedScope), 1) - } + } else if (this.scopes.indexOf(embeddedScope) !== -1) { + this.scopes.splice(this.scopes.indexOf(embeddedScope), 1) } })) this.subscriptions.add(atom.workspace.observeTextEditors((editor) => { @@ -38,7 +38,7 @@ module.exports = { type: 'fix', config: atom.config.get('linter-eslint'), filePath: editor.getPath() - }).catch((response) => + }).catch(response => atom.notifications.addWarning(response) ) } @@ -59,9 +59,9 @@ module.exports = { type: 'fix', config: atom.config.get('linter-eslint'), filePath - }).then((response) => + }).then(response => atom.notifications.addSuccess(response) - ).catch((response) => + ).catch(response => atom.notifications.addWarning(response) ) } @@ -87,12 +87,13 @@ module.exports = { }, provideLinter() { const Helpers = require('atom-linter') + return { name: 'ESLint', grammarScopes: this.scopes, scope: 'file', lintOnFly: true, - lint: textEditor => { + lint: (textEditor) => { const text = textEditor.getText() if (text.length === 0) { return Promise.resolve([]) diff --git a/src/worker.js b/src/worker.js index e2e4559c..b049c3c8 100644 --- a/src/worker.js +++ b/src/worker.js @@ -1,11 +1,12 @@ 'use babel' // Note: 'use babel' doesn't work in forked processes -process.title = 'linter-eslint helper' import Path from 'path' -import * as Helpers from './worker-helpers' import { create } from 'process-communication' import { FindCache } from 'atom-linter' +import * as Helpers from './worker-helpers' + +process.title = 'linter-eslint helper' const ignoredMessages = [ // V1 From 8417c304f0b4adce93c54cdb7ea79d0b6c552dab Mon Sep 17 00:00:00 2001 From: Landon Abney Date: Fri, 16 Sep 2016 15:47:34 -0700 Subject: [PATCH 6/6] Some minor cosmetic fixes --- lib/main.js | 3 +++ lib/worker.js | 1 + spec/.eslintrc | 6 ------ spec/.eslintrc.js | 6 ++++++ src/main.js | 3 +++ src/worker.js | 1 + 6 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 spec/.eslintrc create mode 100644 spec/.eslintrc.js diff --git a/lib/main.js b/lib/main.js index 3c738020..41f69d9a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,6 +33,7 @@ module.exports = { // 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) { @@ -41,6 +42,7 @@ module.exports = { _this.scopes.splice(_this.scopes.indexOf(embeddedScope), 1); } })); + this.subscriptions.add(atom.workspace.observeTextEditors(function (editor) { editor.onDidSave(function () { if (_this.scopes.indexOf(editor.getGrammar().scopeName) !== -1 && atom.config.get('linter-eslint.fixOnSave')) { @@ -54,6 +56,7 @@ module.exports = { } }); })); + this.subscriptions.add(atom.commands.add('atom-text-editor', { 'linter-eslint:fix-file': function linterEslintFixFile() { var textEditor = atom.workspace.getActiveTextEditor(); diff --git a/lib/worker.js b/lib/worker.js index 8f842880..26534dcc 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -39,6 +39,7 @@ function lintJob(argv, contents, eslint, configPath, config) { return !ignoredMessages.includes(e.message); }); } + function fixJob(argv, eslint) { try { eslint.execute(argv); diff --git a/spec/.eslintrc b/spec/.eslintrc deleted file mode 100644 index 52414395..00000000 --- a/spec/.eslintrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "env": { - "jasmine": true, - "atomtest": true - } -} diff --git a/spec/.eslintrc.js b/spec/.eslintrc.js new file mode 100644 index 00000000..6c640eeb --- /dev/null +++ b/spec/.eslintrc.js @@ -0,0 +1,6 @@ +module.exports = { + env: { + jasmine: true, + atomtest: true + } +} diff --git a/src/main.js b/src/main.js index c4dafafb..d825bc23 100644 --- a/src/main.js +++ b/src/main.js @@ -22,6 +22,7 @@ module.exports = { // 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) { @@ -30,6 +31,7 @@ module.exports = { this.scopes.splice(this.scopes.indexOf(embeddedScope), 1) } })) + this.subscriptions.add(atom.workspace.observeTextEditors((editor) => { editor.onDidSave(() => { if (this.scopes.indexOf(editor.getGrammar().scopeName) !== -1 && @@ -44,6 +46,7 @@ module.exports = { } }) })) + this.subscriptions.add(atom.commands.add('atom-text-editor', { 'linter-eslint:fix-file': () => { const textEditor = atom.workspace.getActiveTextEditor() diff --git a/src/worker.js b/src/worker.js index b049c3c8..d63811e1 100644 --- a/src/worker.js +++ b/src/worker.js @@ -30,6 +30,7 @@ function lintJob(argv, contents, eslint, configPath, config) { return global.__LINTER_ESLINT_RESPONSE .filter(e => !ignoredMessages.includes(e.message)) } + function fixJob(argv, eslint) { try { eslint.execute(argv)