Skip to content

Commit

Permalink
Don't remove trailing spaces in WritingLints.MD
Browse files Browse the repository at this point in the history
  • Loading branch information
scheglov committed May 1, 2018
1 parent cd25e5c commit 2a04c13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions doc/WritingLints.MD
Expand Up @@ -105,6 +105,10 @@ You'll notice when authoring a new rule that failures cause the AST of the test

would dump the AST of `rules.dart`.

### Performance

For performance reasons rules should prefer implementing `NodeLintRule` and registering interest in specific AST node types using `registry.addXYZ(this, visitor)`. Avoid overriding `visitCompilationUnit()` and performing your own full `CompilationUnit` visits.

# Feedback is Welcome!

Details are under active development. Feedback is most [welcome](https://github.com/dart-lang/linter/issues)!
15 changes: 11 additions & 4 deletions tool/rule.dart
Expand Up @@ -122,22 +122,29 @@ const _details = r'''
''';
class $className extends LintRule {
class $className extends LintRule implements NodeLintRule {
$className() : super(
name: '$ruleName',
description: _desc,
details: _details,
group: Group.style);
@override
AstVisitor getVisitor() => new Visitor(this);
void registerNodeProcessors(NodeLintRegistry registry) {
final visitor = new _Visitor(this);
registry.addSimpleIdentifier(this, visitor);
}
}
class Visitor extends SimpleAstVisitor {
class _Visitor extends SimpleAstVisitor {
final LintRule rule;
Visitor(this.rule);
_Visitor(this.rule);
@override
void visitSimpleIdentifier(SimpleIdentifier node) {
// TODO: implement
}
}
""";

Expand Down

0 comments on commit 2a04c13

Please sign in to comment.