Skip to content
This repository was archived by the owner on Mar 16, 2020. It is now read-only.

Add an option to filter warnings about compling to JS #46

Merged
merged 1 commit into from
Jul 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/linter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ final Map<String, String> _severityMap = {

String _infosPrefPath = '${pluginId}.showInfos';
String _todosPrefPath = '${pluginId}.showTodos';
String _filterUnnamedWarningPath = '${pluginId}.showUnnamedLibraryWarning';
String _filterUnnamedLibraryWarningsPath = '${pluginId}.filterUnnamedLibraryWarnings';
String _filterCompiledToJSWarningsPath = '${pluginId}.filterCompiledToJSWarnings';

bool _shouldShowInfoMessages() => atom.config.get(_infosPrefPath);
bool _shouldShowTodosMessages() => atom.config.get(_todosPrefPath);
bool _filterUnnamedLibraryWarnings() => atom.config.get(_filterUnnamedWarningPath);
bool _shouldFilterUnnamedLibraryWarnings() => atom.config.get(_filterUnnamedLibraryWarningsPath);
bool _shouldFilterCompiledToJSWarnings() => atom.config.get(_filterCompiledToJSWarningsPath);
6 changes: 5 additions & 1 deletion lib/linter/dart_linter_consumer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ class DartLinterConsumer extends LinterConsumer with Disposables {
if (!_shouldShowTodosMessages()) {
sortedErrors = sortedErrors.where((issue) => issue.type != 'TODO');
}
if (_filterUnnamedLibraryWarnings()) {
if (_shouldFilterUnnamedLibraryWarnings()) {
sortedErrors = sortedErrors.where(
(issue) => !issue.message.contains('cannot both be unnamed'));
}
if (_shouldFilterCompiledToJSWarnings()) {
sortedErrors = sortedErrors.where(
(issue) => !issue.message.contains('When compiled to JS'));
}

var formattedErrors = sortedErrors
.where((e) => acceptableErrorTypes.contains(e.severity))
Expand Down
10 changes: 8 additions & 2 deletions lib/plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,15 @@ class AtomDartPackage extends AtomPackage {
'type': 'boolean',
'default': false
},
'showUnnamedLibraryWarning': {
'filterUnnamedLibraryWarnings': {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While slightly inaccurate, this setting was named showUnnamed... in order for it to display after the other settings in the preferences page. They're sorted (I believe) by pref id. filter will sort before everything else, and these aren't the primary prefs for the app.

We can play with some id prefixes in order to group settings; let's keep it as you have for now.

'title': 'Filter unnamed library warnings',
'description': 'Filter all unnamed library warnings.',
'description': 'Don\'t display warnings about unnamed libraries.',
'type': 'boolean',
'default': true
},
'filterCompiledToJSWarnings': {
'title': 'Filter warnings about compiling to JavaScript',
'description': 'Don\'t display warnings about compiling to JavaScript.',
'type': 'boolean',
'default': true
}
Expand Down