OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library services.src.linter; | 5 library services.src.linter; |
6 | 6 |
7 import 'package:analyzer/plugin/options.dart'; | 7 import 'package:analyzer/plugin/options.dart'; |
8 import 'package:analyzer/analyzer.dart'; | 8 import 'package:analyzer/analyzer.dart'; |
9 import 'package:yaml/yaml.dart'; | 9 import 'package:yaml/yaml.dart'; |
10 import 'package:linter/src/rules.dart'; | 10 import 'package:linter/src/rules.dart'; |
11 import 'package:linter/src/linter.dart'; | 11 import 'package:linter/src/linter.dart'; |
12 | 12 |
13 /** | 13 /** |
14 * An error code indicating an undefined lint rule. | 14 * An error code indicating an undefined lint rule. |
15 * | 15 * |
16 * Parameters: | 16 * Parameters: |
17 * 0: the rule name | 17 * 0: the rule name |
18 */ | 18 */ |
19 const AnalysisOptionsWarningCode UNDEFINED_LINT_WARNING = | 19 const AnalysisOptionsWarningCode UNDEFINED_LINT_WARNING = |
20 const AnalysisOptionsWarningCode( | 20 const AnalysisOptionsWarningCode( |
21 'UNDEFINED_LINT_WARNING', "Undefined lint rule '{0}'"); | 21 'UNDEFINED_LINT_WARNING', "'{0}' is not a recognized lint rule"); |
22 | 22 |
23 /// Validates `linter` rule configurations. | 23 /// Validates `linter` rule configurations. |
24 class LinterRuleOptionsValidator extends OptionsValidator { | 24 class LinterRuleOptionsValidator extends OptionsValidator { |
25 static const linter = 'linter'; | 25 static const linter = 'linter'; |
26 static const rulesKey = 'rules'; | 26 static const rulesKey = 'rules'; |
27 @override | 27 @override |
28 List<AnalysisError> validate( | 28 List<AnalysisError> validate( |
29 ErrorReporter reporter, Map<String, YamlNode> options) { | 29 ErrorReporter reporter, Map<String, YamlNode> options) { |
30 List<AnalysisError> errors = <AnalysisError>[]; | 30 List<AnalysisError> errors = <AnalysisError>[]; |
31 var node = options[linter]; | 31 var node = options[linter]; |
(...skipping 10 matching lines...) Expand all Loading... |
42 Iterable<String> registeredLints = ruleRegistry.map((r) => r.name); | 42 Iterable<String> registeredLints = ruleRegistry.map((r) => r.name); |
43 rules.nodes.forEach((YamlNode ruleNode) { | 43 rules.nodes.forEach((YamlNode ruleNode) { |
44 if (!registeredLints.contains(ruleNode.value)) { | 44 if (!registeredLints.contains(ruleNode.value)) { |
45 reporter.reportErrorForSpan( | 45 reporter.reportErrorForSpan( |
46 UNDEFINED_LINT_WARNING, ruleNode.span, [ruleNode.value]); | 46 UNDEFINED_LINT_WARNING, ruleNode.span, [ruleNode.value]); |
47 } | 47 } |
48 }); | 48 }); |
49 } | 49 } |
50 } | 50 } |
51 } | 51 } |
OLD | NEW |