Permalink
Browse files

Move to babel-cli

Replace the current `ucompiler` setup with a standard `babel-cli` setup,
along with a configuration that transpiles _only_ what is necessary,
instead of the current method of transpiling everything that _might_ be
needed. This currently transpiles to support for Node.js v5 as that is
what Atom v1.10.0 ships with, which is our current minimum version.
  • Loading branch information...
1 parent 1164657 commit 5b4f68291518a04c181bba1c7c8bdd0090e1f2fa @Arcanemagus Arcanemagus committed Dec 6, 2016
Showing with 173 additions and 192 deletions.
  1. +5 −0 .babelrc
  2. +0 −15 .ucompiler
  3. +81 −81 lib/helpers.js
  4. +50 −57 lib/main.js
  5. +1 −1 lib/reporter.js
  6. +18 −17 lib/worker-helpers.js
  7. +11 −13 lib/worker.js
  8. +7 −8 package.json
View
@@ -0,0 +1,5 @@
+{
+ "presets": [
+ "node5"
+ ]
+}
View
@@ -1,15 +0,0 @@
-{
- "defaultRule": "compile-src",
- "rules": [{
- "name": "compile-src",
- "plugins": ["babel", "newline"],
- "babel": {
- "presets": ["steelbrain"]
- },
- "include": [{
- "directory": "src",
- "extensions": ["js"]
- }],
- "outputPath": "lib/{relativePath:4}"
- }]
-}
View
@@ -6,55 +6,55 @@ Object.defineProperty(exports, "__esModule", {
});
exports.processESLintMessages = exports.generateDebugString = exports.getDebugInfo = undefined;
-var getDebugInfo = exports.getDebugInfo = function () {
+let getDebugInfo = exports.getDebugInfo = (() => {
var _ref = _asyncToGenerator(function* (worker) {
- var textEditor = atom.workspace.getActiveTextEditor();
- var filePath = textEditor.getPath();
- var packagePath = atom.packages.resolvePackagePath('linter-eslint');
+ const textEditor = atom.workspace.getActiveTextEditor();
+ const filePath = textEditor.getPath();
+ const packagePath = atom.packages.resolvePackagePath('linter-eslint');
// eslint-disable-next-line import/no-dynamic-require
- var linterEslintMeta = require((0, _path.join)(packagePath, 'package.json'));
- var config = atom.config.get('linter-eslint');
- var hoursSinceRestart = Math.round(process.uptime() / 3600 * 10) / 10;
- var returnVal = void 0;
+ const linterEslintMeta = require((0, _path.join)(packagePath, 'package.json'));
+ const config = atom.config.get('linter-eslint');
+ const hoursSinceRestart = Math.round(process.uptime() / 3600 * 10) / 10;
+ let returnVal;
try {
- var response = yield worker.request('job', {
+ const response = yield worker.request('job', {
type: 'debug',
- config: config,
- filePath: filePath
+ config,
+ filePath
});
returnVal = {
atomVersion: atom.getVersion(),
linterEslintVersion: linterEslintMeta.version,
linterEslintConfig: config,
// eslint-disable-next-line import/no-dynamic-require
eslintVersion: require((0, _path.join)(response.path, 'package.json')).version,
- hoursSinceRestart: hoursSinceRestart,
+ hoursSinceRestart,
platform: process.platform,
eslintType: response.type,
eslintPath: response.path
};
} catch (error) {
- atom.notifications.addError('' + error);
+ atom.notifications.addError(`${ error }`);
}
return returnVal;
});
return function getDebugInfo(_x3) {
return _ref.apply(this, arguments);
};
-}();
+})();
-var generateDebugString = exports.generateDebugString = function () {
+let generateDebugString = exports.generateDebugString = (() => {
var _ref2 = _asyncToGenerator(function* (worker) {
- var debug = yield getDebugInfo(worker);
- var details = ['Atom version: ' + debug.atomVersion, 'linter-eslint version: ' + debug.linterEslintVersion, 'ESLint version: ' + debug.eslintVersion, 'Hours since last Atom restart: ' + debug.hoursSinceRestart, 'Platform: ' + debug.platform, 'Using ' + debug.eslintType + ' ESLint from ' + debug.eslintPath, 'linter-eslint configuration: ' + JSON.stringify(debug.linterEslintConfig, null, 2)];
+ const debug = yield getDebugInfo(worker);
+ const details = [`Atom version: ${ debug.atomVersion }`, `linter-eslint version: ${ debug.linterEslintVersion }`, `ESLint version: ${ debug.eslintVersion }`, `Hours since last Atom restart: ${ debug.hoursSinceRestart }`, `Platform: ${ debug.platform }`, `Using ${ debug.eslintType } ESLint from ${ debug.eslintPath }`, `linter-eslint configuration: ${ JSON.stringify(debug.linterEslintConfig, null, 2) }`];
return details.join('\n');
});
return function generateDebugString(_x4) {
return _ref2.apply(this, arguments);
};
-}();
+})();
/**
* Given a raw response from ESLint, this processes the messages into a format
@@ -65,40 +65,40 @@ var generateDebugString = exports.generateDebugString = function () {
* @param {Object} worker The current Worker process to send Debug jobs to
* @return {Promise} The messages transformed into Linter messages
*/
-var processESLintMessages = exports.processESLintMessages = function () {
+let processESLintMessages = exports.processESLintMessages = (() => {
var _ref4 = _asyncToGenerator(function* (response, textEditor, showRule, worker) {
- return Promise.all(response.map(function () {
- var _ref5 = _asyncToGenerator(function* (_ref6) {
- var message = _ref6.message,
- line = _ref6.line,
- severity = _ref6.severity,
- ruleId = _ref6.ruleId,
- column = _ref6.column,
- fix = _ref6.fix,
- endLine = _ref6.endLine,
- endColumn = _ref6.endColumn;
-
- var filePath = textEditor.getPath();
- var textBuffer = textEditor.getBuffer();
- var linterFix = null;
+ return Promise.all(response.map((() => {
+ var _ref6 = _asyncToGenerator(function* (_ref5) {
+ let message = _ref5.message,
+ line = _ref5.line,
+ severity = _ref5.severity,
+ ruleId = _ref5.ruleId,
+ column = _ref5.column,
+ fix = _ref5.fix,
+ endLine = _ref5.endLine,
+ endColumn = _ref5.endColumn;
+
+ const filePath = textEditor.getPath();
+ const textBuffer = textEditor.getBuffer();
+ let linterFix = null;
if (fix) {
- var fixRange = new _atom.Range(textBuffer.positionForCharacterIndex(fix.range[0]), textBuffer.positionForCharacterIndex(fix.range[1]));
+ const fixRange = new _atom.Range(textBuffer.positionForCharacterIndex(fix.range[0]), textBuffer.positionForCharacterIndex(fix.range[1]));
linterFix = {
range: fixRange,
newText: fix.text
};
}
- var msgCol = void 0;
- var msgEndLine = void 0;
- var msgEndCol = void 0;
- var eslintFullRange = false;
+ let msgCol;
+ let msgEndLine;
+ let msgEndCol;
+ let eslintFullRange = false;
/*
Note: ESLint positions are 1-indexed, while Atom expects 0-indexed,
positions. We are subtracting 1 from these values here so we don't have to
keep doing so in later uses.
*/
- var msgLine = line - 1;
+ const msgLine = line - 1;
if (typeof endColumn !== 'undefined' && typeof endLine !== 'undefined') {
eslintFullRange = true;
// Here we always want the column to be a number
@@ -111,8 +111,8 @@ var processESLintMessages = exports.processESLintMessages = function () {
msgCol = typeof column !== 'undefined' ? column - 1 : column;
}
- var ret = void 0;
- var range = void 0;
+ let ret;
+ let range;
try {
if (eslintFullRange) {
validatePoint(textEditor, msgLine, msgCol);
@@ -122,15 +122,15 @@ var processESLintMessages = exports.processESLintMessages = function () {
range = (0, _atomLinter.rangeFromLineNumber)(textEditor, msgLine, msgCol);
}
ret = {
- filePath: filePath,
+ filePath,
type: severity === 1 ? 'Warning' : 'Error',
- range: range
+ range
};
if (showRule) {
- var elName = ruleId ? 'a' : 'span';
- var href = ruleId ? ' href=' + (0, _eslintRuleDocumentation2.default)(ruleId).url : '';
- ret.html = '<' + elName + href + ' class="badge badge-flexible eslint">' + ((ruleId || 'Fatal') + '</' + elName + '> ' + (0, _escapeHtml2.default)(message));
+ const elName = ruleId ? 'a' : 'span';
+ const href = ruleId ? ` href=${ (0, _eslintRuleDocumentation2.default)(ruleId).url }` : '';
+ ret.html = `<${ elName }${ href } class="badge badge-flexible eslint">` + `${ ruleId || 'Fatal' }</${ elName }> ${ (0, _escapeHtml2.default)(message) }`;
} else {
ret.text = message;
}
@@ -149,15 +149,15 @@ var processESLintMessages = exports.processESLintMessages = function () {
});
return function (_x19) {
- return _ref5.apply(this, arguments);
+ return _ref6.apply(this, arguments);
};
- }()));
+ })()));
});
return function processESLintMessages(_x15, _x16, _x17, _x18) {
return _ref4.apply(this, arguments);
};
-}();
+})();
exports.spawnWorker = spawnWorker;
exports.showError = showError;
@@ -190,95 +190,95 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a
// eslint-disable-next-line import/no-extraneous-dependencies, import/extensions
-var RULE_OFF_SEVERITY = 0;
+const RULE_OFF_SEVERITY = 0;
function spawnWorker() {
- var env = Object.create(process.env);
+ const env = Object.create(process.env);
delete env.NODE_PATH;
delete env.NODE_ENV;
delete env.OS;
- var child = _child_process2.default.fork((0, _path.join)(__dirname, 'worker.js'), [], { env: env, silent: true });
- var worker = (0, _processCommunication.createFromProcess)(child);
+ const child = _child_process2.default.fork((0, _path.join)(__dirname, 'worker.js'), [], { env, silent: true });
+ const worker = (0, _processCommunication.createFromProcess)(child);
- child.stdout.on('data', function (chunk) {
+ child.stdout.on('data', chunk => {
console.log('[Linter-ESLint] STDOUT', chunk.toString());
});
- child.stderr.on('data', function (chunk) {
+ child.stderr.on('data', chunk => {
console.log('[Linter-ESLint] STDERR', chunk.toString());
});
return {
- worker: worker,
- subscription: new _atom.Disposable(function () {
+ worker,
+ subscription: new _atom.Disposable(() => {
worker.kill();
})
};
}
function showError(givenMessage) {
- var givenDetail = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
+ let givenDetail = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
- var detail = void 0;
- var message = void 0;
+ let detail;
+ let message;
if (message instanceof Error) {
detail = message.stack;
message = message.message;
} else {
detail = givenDetail;
message = givenMessage;
}
- atom.notifications.addError('[Linter-ESLint] ' + message, {
- detail: detail,
+ atom.notifications.addError(`[Linter-ESLint] ${ message }`, {
+ detail,
dismissable: true
});
}
function idsToIgnoredRules() {
- var ruleIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ let ruleIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- return ruleIds.reduce(function (ids, id) {
+ return ruleIds.reduce((ids, id) => {
ids[id] = RULE_OFF_SEVERITY;
return ids;
}, {});
}
function validatePoint(textEditor, line, col) {
- var buffer = textEditor.getBuffer();
+ const buffer = textEditor.getBuffer();
// Clip the given point to a valid one, and check if it equals the original
if (!buffer.clipPosition([line, col]).isEqual([line, col])) {
- throw new Error(line + ':' + col + ' isn\'t a valid point!');
+ throw new Error(`${ line }:${ col } isn't a valid point!`);
}
}
-var generateInvalidTrace = function () {
+const generateInvalidTrace = (() => {
var _ref3 = _asyncToGenerator(function* (msgLine, msgCol, msgEndLine, msgEndCol, eslintFullRange, filePath, textEditor, ruleId, message, worker) {
- var errMsgRange = msgLine + 1 + ':' + msgCol;
+ let errMsgRange = `${ msgLine + 1 }:${ msgCol }`;
if (eslintFullRange) {
- errMsgRange += ' - ' + (msgEndLine + 1) + ':' + (msgEndCol + 1);
+ errMsgRange += ` - ${ msgEndLine + 1 }:${ msgEndCol + 1 }`;
}
- var rangeText = 'Requested ' + (eslintFullRange ? 'start point' : 'range') + ': ' + errMsgRange;
- var issueURL = 'https://github.com/AtomLinter/linter-eslint/issues/new';
- var titleText = 'Invalid position given by \'' + ruleId + '\'';
- var title = encodeURIComponent(titleText);
- var body = encodeURIComponent(['ESLint returned a point that did not exist in the document being edited.', 'Rule: `' + ruleId + '`', rangeText, '', '', '<!-- If at all possible, please include code to reproduce this issue! -->', '', '', 'Debug information:', '```json', JSON.stringify((yield getDebugInfo(worker)), null, 2), '```'].join('\n'));
- var newIssueURL = issueURL + '?title=' + title + '&body=' + body;
+ const rangeText = `Requested ${ eslintFullRange ? 'start point' : 'range' }: ${ errMsgRange }`;
+ const issueURL = 'https://github.com/AtomLinter/linter-eslint/issues/new';
+ const titleText = `Invalid position given by '${ ruleId }'`;
+ const title = encodeURIComponent(titleText);
+ const body = encodeURIComponent(['ESLint returned a point that did not exist in the document being edited.', `Rule: \`${ ruleId }\``, rangeText, '', '', '<!-- If at all possible, please include code to reproduce this issue! -->', '', '', 'Debug information:', '```json', JSON.stringify((yield getDebugInfo(worker)), null, 2), '```'].join('\n'));
+ const newIssueURL = `${ issueURL }?title=${ title }&body=${ body }`;
return {
type: 'Error',
severity: 'error',
- html: (0, _escapeHtml2.default)(titleText) + '. See the trace for details. ' + ('<a href="' + newIssueURL + '">Report this!</a>'),
- filePath: filePath,
+ html: `${ (0, _escapeHtml2.default)(titleText) }. See the trace for details. ` + `<a href="${ newIssueURL }">Report this!</a>`,
+ filePath,
range: (0, _atomLinter.rangeFromLineNumber)(textEditor, 0),
trace: [{
type: 'Trace',
- text: 'Original message: ' + ruleId + ' - ' + message,
- filePath: filePath,
+ text: `Original message: ${ ruleId } - ${ message }`,
+ filePath,
severity: 'info'
}, {
type: 'Trace',
text: rangeText,
- filePath: filePath,
+ filePath,
severity: 'info'
}]
};
@@ -287,4 +287,4 @@ var generateInvalidTrace = function () {
return function generateInvalidTrace(_x5, _x6, _x7, _x8, _x9, _x10, _x11, _x12, _x13, _x14) {
return _ref3.apply(this, arguments);
};
-}();
+})();
Oops, something went wrong.

0 comments on commit 5b4f682

Please sign in to comment.