Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(797)

Unified Diff: src/site/articles/style-guide/index.markdown

Issue 959553002: Update the Style Guide (Closed) Base URL: https://github.com/dart-lang/www.dartlang.org.git@master
Patch Set: incorporate reviewer comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/site/articles/style-guide/index.markdown
diff --git a/src/site/articles/style-guide/index.markdown b/src/site/articles/style-guide/index.markdown
index 43dc5a0c2fffb9f2220bc060b69cfc40b83f1d48..c7cef1b5d23e260a5e1dff31892fe2386c526694 100644
--- a/src/site/articles/style-guide/index.markdown
+++ b/src/site/articles/style-guide/index.markdown
@@ -606,8 +606,8 @@ bool convertToBool(arg) {
#### DO name types using `UpperCamelCase`.
{:.no_toc}
-Classes and typedefs should capitalize the first letter of each word (including
-the first word), and use no separators.
+Classes, enums, and typedefs should capitalize the first letter of each word
+(including the first word), and use no separators.
<div class="good" markdown="1">
{% prettify dart %}
@@ -628,7 +628,8 @@ typedef num Adder(num x, num y);
{:.no_toc}
<!-- https://github.com/dart-lang/www.dartlang.org/issues/831 -->
-In new code, use `lowerCamelCase` for constant variables.
+In new code, use `lowerCamelCase` for constant variables, including enum
+values.
In existing code that uses `ALL_CAPS_WITH_UNDERSCORES` for constants, you
may continue to use all caps to stay consistent.
@@ -1009,7 +1010,7 @@ compact. Do you really need to call that class
`AbstractWidgetFactoryManagerBuilder`?
-#### DO place the operator on the preceding line in a multi-line expression.
+#### DO place binary operators on the preceding line in a multi-line expression.
{:.no_toc}
There are valid arguments for both styles but most of our code seems to go this
@@ -1042,6 +1043,31 @@ bobLikes()
</div>
+#### DO place ternary operators on the next line in a multi-line expression.
+{:.no_toc}
+
+Also, if you break the line before one of the operators, prefer breaking
+around both.
+
+<div class="good">
+{% prettify dart %}
+return someCondition
+ ? whenTrue
+ : whenFalse;
+{% endprettify %}
+</div>
+
+<div class="bad">
+{% prettify dart %}
+return someCondition ?
+ whenTrue :
+ whenFalse;
+return someCondition
+ ? whenTrue : whenFalse;
+{% endprettify %}
+</div>
+
+
#### DO place the `.` on the next line in a multi-line expression.
{:.no_toc}
@@ -1527,3 +1553,65 @@ followed by more alphanumeric text, the `{}` can and should be omitted.
"Wear your wildest ${decade}'s outfit."
{% endprettify %}
</div>
+
+
+## Ordering
+
+#### DO specify dart: imports, then package: imports, and then relative imports
+{:.no_toc}
+
+Separate import sections from each other with a single blank line.
+
+Within each section, prefer sorting alphabetically. If you use a
+`package:` import to import from your own package, consider putting
+that import in the relative import section.
+
+<div class="good">
+{% prettify dart %}
+import 'dart:async';
+import 'dart:convert' show JSON;
+import 'dart:html';
+
+import 'package:bar/bar.dart'
+import 'package:bar/foo.dart'
+import 'package:foo/bar.dart'
+
+import 'a.dart';
+{% endprettify %}
+</div>
+
+<div class="bad">
+{% prettify dart %}
+import 'dart:html';
+import 'dart:async';
+import 'dart:convert' show JSON;
+
+import 'a.dart';
+import 'package:bar/bar.dart'
+import 'package:foo/bar.dart'
+import 'package:bar/foo.dart'
+{% endprettify %}
+</div>
+
+#### PREFER specifying exports in a separate section after all imports
+{:.no_toc}
+
+Put a single blank line above the exports section.
+
+<div class="good">
+{% prettify dart %}
+import 'src/error.dart';
+import 'src/string_source.dart';
+
+export 'src/error.dart';
+{% endprettify %}
+</div>
+
+<div class="bad">
+{% prettify dart %}
+import 'src/error.dart';
+export 'src/error.dart';
+
+import 'src/string_source.dart';
+{% endprettify %}
+</div>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698