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

Commit 6849285

Browse files
Add url properties to messages…
…and handle “disable when no .eslintconfig” option.
1 parent d0ddc6d commit 6849285

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

lib/main.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,19 @@ export default {
377377
return;
378378
}
379379

380+
if (err.type && err.type === 'config-not-found') {
381+
if (Config.get('disabling.disableWhenNoEslintConfig')) {
382+
return;
383+
}
384+
atom.notifications.addError(
385+
`linter-eslint-node: No .eslintrc found`,
386+
{
387+
description: err.error,
388+
dismissable: false
389+
}
390+
);
391+
}
392+
380393
if (err.type && err.type === 'no-project') {
381394
// No project means nowhere to look for an `.eslintrc`.
382395
return;
@@ -519,7 +532,7 @@ export default {
519532
return filteredResults;
520533
} catch (err) {
521534
this.handleError(err);
522-
return null;
535+
return [];
523536
}
524537
}
525538
};

lib/worker.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class VersionOverlapError extends Error {
3434
}
3535
}
3636

37+
function isConfigNotFoundError (error) {
38+
return error.messageTemplate === 'no-config-found';
39+
}
40+
3741
function emit (obj) {
3842
if (typeof obj !== 'string') {
3943
obj = JSON.stringify(obj);
@@ -185,6 +189,9 @@ function formatResults (files, rules, config, { isModified, key }) {
185189
if (showRuleIdInMessage && message.ruleId) {
186190
idTag = ` (${message.ruleId})`;
187191
}
192+
193+
let rule = rules[message.ruleId];
194+
188195
let position;
189196
if (message.fatal) {
190197
// Parsing errors don't define a range — only a single position. By
@@ -212,7 +219,8 @@ function formatResults (files, rules, config, { isModified, key }) {
212219
position,
213220
},
214221
fix: message.fix,
215-
excerpt: `${message.message}${idTag}`
222+
excerpt: `${message.message}${idTag}`,
223+
url: rule ? rule.docs.url : undefined
216224
});
217225
}
218226
}
@@ -274,7 +282,7 @@ async function processMessage (bundle) {
274282
emit({
275283
key,
276284
error: err.message,
277-
verson: err.version,
285+
version: err.version,
278286
type: 'version-overlap'
279287
});
280288
} else {
@@ -319,6 +327,13 @@ async function processMessage (bundle) {
319327
);
320328

321329
} catch (error) {
330+
if (isConfigNotFoundError(error)) {
331+
emit({
332+
key,
333+
error: error.message,
334+
type: 'config-not-found'
335+
});
336+
}
322337
error.key = key;
323338
error.error = 'Unknown error';
324339
emitError(

0 commit comments

Comments
 (0)