You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the rule you'd like to see implemented
The lint should flag comments where there is no space between the slashes (// or ///) and the content of the comment.
This is the style used by Flutter and Dart.
Examples
Bad:
//Bad comment///Bad doc-comment
Good:
// Good comment/// Good doc comment
Some edge cases:
// An empty comment with no spaces after is okay:////// What about this:///////////heey// //Is this alright?// An empty comment at the end of the file is probably also okay:///
The text was updated successfully, but these errors were encountered:
Just in case it helps anybody else - I'm using danger.systems and GitHub Actions to make this check automatically. The relevant part of my Dangerfile is:
files=git.added_files + git.modified_filesfiles.eachdo |f|
diff=git.diff_for_file(f)# Check comment formattingiff =~ /.*\.dart/anddiff.patch =~ /((\/\/)[^ \n\/])|((\/\/\/)[^ \n])|(\/\*)/mFile.readlines(f).each_with_indexdo |line,index|
ifline =~ /\/\*/warn("Don't use block comments",file: f,line: index+1)elsifline =~ /(\/\/\/)[^ \n]/ifline =~ /\/{4}/warn("That's probably too many slashes",file: f,line: index+1)elsewarn("Add a space between \"///\" and the actual comment",file: f,line: index+1)endelsifline =~ /(\/\/)[^ \n\/]/warn("Add a space between \"//\" and the actual comment",file: f,line: index+1)endendendend
Thanks @Jonas-Sander for providing the edge cases, they helped me write and test this code :)
Describe the rule you'd like to see implemented
The lint should flag comments where there is no space between the slashes (
//
or///
) and the content of the comment.This is the style used by Flutter and Dart.
Examples
Bad:
Good:
Some edge cases:
The text was updated successfully, but these errors were encountered: