conductor-install 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/conductor-install.cjs +13 -9
- package/dist/conductor-install.js +12 -8
- package/dist/index.cjs +6 -4
- package/dist/index.js +5 -3
- package/package.json +6 -6
- package/dist/conductor/conductor/CHANGELOG.md +0 -39
- package/dist/conductor/conductor/CONTRIBUTING.md +0 -33
- package/dist/conductor/conductor/GEMINI.md +0 -41
- package/dist/conductor/conductor/LICENSE +0 -202
- package/dist/conductor/conductor/README.md +0 -128
- package/dist/conductor/conductor/commands/conductor/implement.toml +0 -179
- package/dist/conductor/conductor/commands/conductor/newTrack.toml +0 -154
- package/dist/conductor/conductor/commands/conductor/revert.toml +0 -130
- package/dist/conductor/conductor/commands/conductor/review.toml +0 -158
- package/dist/conductor/conductor/commands/conductor/setup.toml +0 -456
- package/dist/conductor/conductor/commands/conductor/status.toml +0 -57
- package/dist/conductor/conductor/gemini-extension.json +0 -5
- package/dist/conductor/conductor/release-please-config.json +0 -11
- package/dist/conductor/conductor/templates/code_styleguides/cpp.md +0 -113
- package/dist/conductor/conductor/templates/code_styleguides/csharp.md +0 -115
- package/dist/conductor/conductor/templates/code_styleguides/dart.md +0 -238
- package/dist/conductor/conductor/templates/code_styleguides/general.md +0 -23
- package/dist/conductor/conductor/templates/code_styleguides/go.md +0 -48
- package/dist/conductor/conductor/templates/code_styleguides/html-css.md +0 -49
- package/dist/conductor/conductor/templates/code_styleguides/javascript.md +0 -51
- package/dist/conductor/conductor/templates/code_styleguides/python.md +0 -37
- package/dist/conductor/conductor/templates/code_styleguides/typescript.md +0 -43
- package/dist/conductor/conductor/templates/workflow.md +0 -333
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# Google C++ Style Guide Summary
|
|
2
|
-
|
|
3
|
-
## 1. Naming
|
|
4
|
-
- **General:** Optimize for readability. Be descriptive but concise. Use inclusive language.
|
|
5
|
-
- **Files:** `.h` (headers), `.cc` (source). Lowercase with underscores (`_`) or dashes (`-`). Be consistent.
|
|
6
|
-
- **Types:** PascalCase (`MyClass`, `MyEnum`). Use `int` by default; use `<cstdint>` (`int32_t`) if size matters.
|
|
7
|
-
- **Concepts:** PascalCase (`MyConcept`).
|
|
8
|
-
- **Variables:** snake_case (`my_var`). Class members end with underscore (`my_member_`), struct members do not.
|
|
9
|
-
- **Constants/Enumerators:** `k` + PascalCase (`kDays`, `kOk`).
|
|
10
|
-
- **Template Parameters:** PascalCase for types (`T`, `MyType`), snake_case/kPascalCase for non-types (`N`, `kLimit`).
|
|
11
|
-
- **Functions:** PascalCase (`GetValue()`).
|
|
12
|
-
- **Accessors/Mutators:** snake_case. `count()` (not `GetCount`), `set_count(v)`.
|
|
13
|
-
- **Namespaces:** lowercase (`web_search`).
|
|
14
|
-
- **Macros:** ALL_CAPS (`MY_MACRO`).
|
|
15
|
-
|
|
16
|
-
## 2. Header Files
|
|
17
|
-
- **General:** Every `.cc` usually has a `.h`. Headers must be self-contained.
|
|
18
|
-
- **Guards:** Use `#define <PROJECT>_<PATH>_<FILE>_H_`.
|
|
19
|
-
- **IWYU:** Direct includes only. Do not rely on transitive includes.
|
|
20
|
-
- **Forward Decls:** Avoid. Include headers instead. **Never** forward declare `std::` symbols.
|
|
21
|
-
- **Inline Definitions:** Only short functions (<10 lines) in headers. Must be ODR-safe (`inline` or templates).
|
|
22
|
-
- **Include Order:**
|
|
23
|
-
1. Related header (`foo.h`)
|
|
24
|
-
2. C system (`<unistd.h>`)
|
|
25
|
-
3. C++ standard (`<vector>`)
|
|
26
|
-
4. Other libraries (`<Python.h>`)
|
|
27
|
-
5. Project headers (`"base/logging.h"`)
|
|
28
|
-
*Separate groups with blank lines. Alphabetical within groups.*
|
|
29
|
-
|
|
30
|
-
## 3. Formatting
|
|
31
|
-
- **Indentation:** 2 spaces. **Line Length:** 80 chars.
|
|
32
|
-
- **Non-ASCII:** Rare, use UTF-8. Avoid `u8` prefix if possible.
|
|
33
|
-
- **Braces:** `if (cond) { ... }`. **Exception:** Function definition open brace goes on the **next line**.
|
|
34
|
-
- **Switch:** Always include `default`. Use `[[fallthrough]]` for explicit fallthrough.
|
|
35
|
-
- **Literals:** Floating-point must have radix point (`1.0f`).
|
|
36
|
-
- **Calls:** Wrap arguments at paren or 4-space indent.
|
|
37
|
-
- **Init Lists:** Colon on new line, indent 4 spaces.
|
|
38
|
-
- **Namespaces:** No indentation.
|
|
39
|
-
- **Vertical Whitespace:** Use sparingly. Separate related chunks, not code blocks.
|
|
40
|
-
- **Loops/Branching:** Use braces (optional if single line). No space after `(`, space before `{`.
|
|
41
|
-
- **Return:** No parens `return result;`.
|
|
42
|
-
- **Preprocessor:** `#` always at line start.
|
|
43
|
-
- **Pointers:** `char* c` (attached to type).
|
|
44
|
-
- **Templates:** No spaces inside `< >` (`vector<int>`).
|
|
45
|
-
- **Operators:** Space around assignment/binary, no space for unary.
|
|
46
|
-
- **Class Order:** `public`, `protected`, `private`.
|
|
47
|
-
- **Parameter Wrapping:** Wrap parameter lists that don't fit. Use 4-space indent for wrapped parameters.
|
|
48
|
-
|
|
49
|
-
## 4. Classes
|
|
50
|
-
- **Constructors:** `explicit` for single-arg and conversion operators. **Exception:** `std::initializer_list`. No virtual calls in ctors. Use factories for fallible init.
|
|
51
|
-
- **Structs:** Only for passive data. Prefer `struct` over `std::pair` or `std::tuple`.
|
|
52
|
-
- **Copy/Move:** Explicitly `= default` or `= delete`. **Rule of 5:** If defining one, declare all.
|
|
53
|
-
- **Inheritance:** `public` only. Composition > Inheritance. Use `override` (omit `virtual`). No multiple implementation inheritance.
|
|
54
|
-
- **Operator Overloading:** Judicious use only. Binary ops as non-members. Never overload `&&`, `||`, `,`, or unary `&`. No User-Defined Literals.
|
|
55
|
-
- **Access:** Data members `private` (except structs/constants).
|
|
56
|
-
- **Declaration Order:** `public` before `protected` before `private`. Within sections: Types, Constants, Factory, Constructors, Destructor, Methods, Data Members.
|
|
57
|
-
|
|
58
|
-
## 5. Functions
|
|
59
|
-
- **Params:** Inputs (`const T&`, `std::string_view`, `std::span` or value) first, then outputs. **Ordering:** Inputs before outputs.
|
|
60
|
-
- **Outputs:** Prefer return values/`std::optional`. For non-optional outputs, use references. For optional outputs, use pointers.
|
|
61
|
-
- **Optional Inputs:** Use `std::optional` for by-value, `const T*` for reference.
|
|
62
|
-
- **Nonmember vs Static:** Prefer nonmember functions in namespaces over static member functions.
|
|
63
|
-
- **Length:** Prefer small (<40 lines).
|
|
64
|
-
- **Overloading:** Use only when behavior is obvious. Document overload sets with a single umbrella comment.
|
|
65
|
-
- **Default Args:** Allowed on non-virtual functions only (value must be fixed/constant).
|
|
66
|
-
- **Trailing Return:** Only when necessary (lambdas).
|
|
67
|
-
|
|
68
|
-
## 6. Scoping
|
|
69
|
-
- **Namespaces:** No `using namespace`. Use `using std::string`. Never add to `namespace std`.
|
|
70
|
-
- **Internal:** Use anonymous namespaces or `static` in `.cc` files. Avoid in headers.
|
|
71
|
-
- **Locals:** Narrowest scope. Initialize at declaration. **Exception:** Declare complex objects outside loops.
|
|
72
|
-
- **Static/Global:** Must be **trivially destructible** (e.g., `constexpr`, raw pointers, arrays). No global `std::string`, `std::map`, smart pointers. Dynamic initialization allowed only for function-static variables.
|
|
73
|
-
- **Thread Local:** `thread_local` must be `constinit` if global. Prefer `thread_local` over other mechanisms.
|
|
74
|
-
|
|
75
|
-
## 7. Modern C++ Features
|
|
76
|
-
- **Version:** Target **C++20**. Do not use C++23. Consider portability for C++17/20 features. No non-standard extensions.
|
|
77
|
-
- **Modules:** Do not use C++20 Modules.
|
|
78
|
-
- **Coroutines:** Use approved libraries only. Do not roll your own promise or awaitable types.
|
|
79
|
-
- **Concepts:** Prefer C++20 Concepts (`requires`) over `std::enable_if`. Use `requires(Concept<T>)`, not `template<Concept T>`.
|
|
80
|
-
- **R-Value References:** Use only for move ctors/assignment, perfect forwarding, or consuming `*this`.
|
|
81
|
-
- **Smart Pointers:** `std::unique_ptr` (exclusive), `std::shared_ptr` (shared). No `std::auto_ptr`.
|
|
82
|
-
- **Auto:** Use when type is obvious (`make_unique`, iterators). Avoid for public APIs.
|
|
83
|
-
- **CTAD:** Use only if explicitly supported (deduction guides exist).
|
|
84
|
-
- **Structured Bindings:** Use for pairs/tuples. Comment aliased field names.
|
|
85
|
-
- **Nullptr:** Use `nullptr`, never `NULL` or `0`.
|
|
86
|
-
- **Constexpr:** Use `constexpr`/`consteval` for constants/functions whenever possible. Use `constinit` for static initialization.
|
|
87
|
-
- **Noexcept:** Specify when useful/correct. Prefer unconditional `noexcept` if exceptions are disabled.
|
|
88
|
-
- **Lambdas:** Prefer explicit captures (`[&x]`) if escaping scope. Avoid `std::bind`.
|
|
89
|
-
- **Initialization:** Prefer brace init. **Designated Initializers:** Allowed (C++20 ordered form only).
|
|
90
|
-
- **Casts:** Use C++ casts (`static_cast`). Use `std::bit_cast` for type punning.
|
|
91
|
-
- **Loops:** Prefer range-based `for`.
|
|
92
|
-
|
|
93
|
-
## 8. Best Practices
|
|
94
|
-
- **Const:** Mark methods/variables `const` whenever possible. `const` methods must be thread-safe.
|
|
95
|
-
- **Exceptions:** **Forbidden**.
|
|
96
|
-
- **RTTI:** Avoid `dynamic_cast`/`typeid`. Allowed in unit tests. Do not hand-implement workarounds.
|
|
97
|
-
- **Macros:** Avoid. Use `constexpr`/`inline`. If needed, define close to use and `#undef` immediately. Do not define in headers.
|
|
98
|
-
- **0 and nullptr:** Use `nullptr` for pointers, `\0` for chars, not `0`.
|
|
99
|
-
- **Streams:** Use streams primarily for logging. Prefer printf-style formatting or absl::StrCat.
|
|
100
|
-
- **Types:** Avoid `unsigned` for non-negativity. No `long double`.
|
|
101
|
-
- **Pre-increment:** Prefer `++i` over `i++`.
|
|
102
|
-
- **Sizeof:** Prefer `sizeof(varname)` over `sizeof(type)`.
|
|
103
|
-
- **Friends:** Allowed, usually defined in the same file.
|
|
104
|
-
- **Boost:** Use only approved libraries (e.g., Call Traits, Compressed Pair, BGL, Property Map, Iterator, etc.).
|
|
105
|
-
- **Aliases:** Use `using` instead of `typedef`. Public aliases must be documented.
|
|
106
|
-
- **Ownership:** Single fixed owner. Transfer via smart pointers.
|
|
107
|
-
- **Aliases:** Document intent. Don't use in public API for convenience. `using` > `typedef`.
|
|
108
|
-
- **Switch:** Always include `default`. Use `[[fallthrough]]` for explicit fallthrough.
|
|
109
|
-
- **Comments:** Document File, Class, Function (params/return). Use `//` or `/* */`. Implementation comments for tricky code. `TODO(user):` format.
|
|
110
|
-
|
|
111
|
-
**BE CONSISTENT.** Follow existing code style.
|
|
112
|
-
|
|
113
|
-
*Source: [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)*
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Google C# Style Guide Summary
|
|
2
|
-
|
|
3
|
-
This document summarizes key rules and best practices from the Google C# Style Guide.
|
|
4
|
-
|
|
5
|
-
## 1. Naming Conventions
|
|
6
|
-
- **PascalCase:** For class names, method names, constants, properties, namespaces, and public fields.
|
|
7
|
-
- Example: `MyClass`, `GetValue()`, `MaxValue`
|
|
8
|
-
- **_camelCase:** For private, internal, and protected fields (with leading underscore).
|
|
9
|
-
- Example: `_myField`, `_internalState`
|
|
10
|
-
- **camelCase:** For local variables and parameters.
|
|
11
|
-
- Example: `localVariable`, `methodParameter`
|
|
12
|
-
- **Interfaces:** Prefix with `I` (e.g., `IMyInterface`).
|
|
13
|
-
- **Type Parameters:** Use descriptive names prefixed with `T` (e.g., `TValue`, `TKey`), or just `T` for simple cases.
|
|
14
|
-
|
|
15
|
-
## 2. Formatting Rules
|
|
16
|
-
- **Indentation:** Use 2 spaces (never tabs).
|
|
17
|
-
- **Braces:** K&R style—no line break before the opening brace; keep `} else` on one line; braces required even when optional.
|
|
18
|
-
```csharp
|
|
19
|
-
if (condition) {
|
|
20
|
-
DoSomething();
|
|
21
|
-
} else {
|
|
22
|
-
DoSomethingElse();
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
- **Line Length:** Column limit 100.
|
|
26
|
-
- **One Statement Per Line:** Each statement on its own line.
|
|
27
|
-
|
|
28
|
-
## 3. Declaration Order
|
|
29
|
-
Class member ordering:
|
|
30
|
-
- Group members in this order:
|
|
31
|
-
1. Nested classes, enums, delegates, and events
|
|
32
|
-
2. Static, const, and readonly fields
|
|
33
|
-
3. Fields and properties
|
|
34
|
-
4. Constructors and finalizers
|
|
35
|
-
5. Methods
|
|
36
|
-
- Within each group, order by accessibility:
|
|
37
|
-
1. Public
|
|
38
|
-
2. Internal
|
|
39
|
-
3. Protected internal
|
|
40
|
-
4. Protected
|
|
41
|
-
5. Private
|
|
42
|
-
- Where possible, group interface implementations together.
|
|
43
|
-
|
|
44
|
-
## 4. Language Features
|
|
45
|
-
- **var:** Use of `var` is encouraged if it aids readability by avoiding type names that are noisy, obvious, or unimportant. Prefer explicit types when it improves clarity.
|
|
46
|
-
```csharp
|
|
47
|
-
var apple = new Apple(); // Good - type is obvious
|
|
48
|
-
bool success = true; // Preferred over var for basic types
|
|
49
|
-
```
|
|
50
|
-
- **Expression-bodied Members:** Use sparingly for simple properties and lambdas; don't use on method definitions.
|
|
51
|
-
```csharp
|
|
52
|
-
public int Age => _age;
|
|
53
|
-
// Methods: prefer block bodies.
|
|
54
|
-
```
|
|
55
|
-
- **String Interpolation:** In general, use whatever is easiest to read, particularly for logging and assert messages.
|
|
56
|
-
- Be aware that chained `operator+` concatenations can be slower and cause memory churn.
|
|
57
|
-
- If performance is a concern, `StringBuilder` can be faster for multiple concatenations.
|
|
58
|
-
```csharp
|
|
59
|
-
var message = $"Hello, {name}!";
|
|
60
|
-
```
|
|
61
|
-
- **Collection Initializers:** Use collection and object initializers when appropriate.
|
|
62
|
-
```csharp
|
|
63
|
-
var list = new List<int> { 1, 2, 3 };
|
|
64
|
-
```
|
|
65
|
-
- **Null-conditional Operators:** Use `?.` and `??` to simplify null checks.
|
|
66
|
-
```csharp
|
|
67
|
-
var length = text?.Length ?? 0;
|
|
68
|
-
```
|
|
69
|
-
- **Pattern Matching:** Use pattern matching for type checks and casts.
|
|
70
|
-
```csharp
|
|
71
|
-
if (obj is string str) { /* use str */ }
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## 5. Best Practices
|
|
75
|
-
- **Structs vs Classes**:
|
|
76
|
-
- Almost always use a class.
|
|
77
|
-
- Consider structs only for small, value-like types that are short-lived or frequently embedded.
|
|
78
|
-
- Performance considerations may justify deviations from this guidance.
|
|
79
|
-
- **Access Modifiers:** Always explicitly declare access modifiers (don't rely on defaults).
|
|
80
|
-
- **Ordering Modifiers:** Use standard order: `public protected internal private new abstract virtual override sealed static readonly extern unsafe volatile async`.
|
|
81
|
-
- **Namespace Imports:** Place `using` directives at the top of the file (outside namespaces); `System` first, then alphabetical.
|
|
82
|
-
- **Constants:** Always make variables `const` when possible; if not, use `readonly`. Prefer named constants over magic numbers.
|
|
83
|
-
- **IEnumerable vs IList vs IReadOnlyList:** When method inputs are intended to be immutable, prefer the most restrictive collection type possible (e.g., IEnumerable, IReadOnlyList); for return values, prefer IList when transferring ownership of a mutable collection, and otherwise prefer the most restrictive option.
|
|
84
|
-
- **Array vs List:** Prefer `List<>` for public variables, properties, and return types. Use arrays when size is fixed and known at construction time, or for multidimensional arrays.
|
|
85
|
-
- **Extension Methods:** Only use when the source is unavailable or changing it is infeasible. Only for core, general features. Be aware they obfuscate code.
|
|
86
|
-
- **LINQ:** Use LINQ for readability, but be mindful of performance in hot paths.
|
|
87
|
-
|
|
88
|
-
## 6. File Organization
|
|
89
|
-
- **One Class Per File:** Typically one class, interface, enum, or struct per file.
|
|
90
|
-
- **File Name:** Prefer the file name to match the name of the primary type it contains.
|
|
91
|
-
- **Folders and File Locations:**
|
|
92
|
-
- Be consistent within the project.
|
|
93
|
-
- Prefer a flat folder structure where possible.
|
|
94
|
-
- Don’t force file/folder layout to match namespaces.
|
|
95
|
-
- **Namespaces:**
|
|
96
|
-
- In general, namespaces should be no more than 2 levels deep.
|
|
97
|
-
- For shared library/module code, use namespaces.
|
|
98
|
-
- For leaf application code, namespaces are not necessary.
|
|
99
|
-
- New top-level namespace names must be globally unique and recognizable.
|
|
100
|
-
|
|
101
|
-
## 7. Parameters and Returns
|
|
102
|
-
- **out Parameters:** Permitted for output-only values; place `out` parameters after all other parameters. Prefer tuples or return types when they improve clarity.
|
|
103
|
-
- **Argument Clarity:** When argument meaning is nonobvious, use named constants, replace `bool` with `enum`, use named arguments, or create a configuration class/struct.
|
|
104
|
-
```csharp
|
|
105
|
-
// Bad
|
|
106
|
-
DecimalNumber product = CalculateProduct(values, 7, false, null);
|
|
107
|
-
|
|
108
|
-
// Good
|
|
109
|
-
var options = new ProductOptions { PrecisionDecimals = 7, UseCache = CacheUsage.DontUseCache };
|
|
110
|
-
DecimalNumber product = CalculateProduct(values, options, completionDelegate: null);
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
**BE CONSISTENT.** When editing code, follow the existing style in the codebase.
|
|
114
|
-
|
|
115
|
-
*Source: [Google C# Style Guide](https://google.github.io/styleguide/csharp-style.html)*
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
# Dart Code Style Guide
|
|
2
|
-
|
|
3
|
-
This guide summarizes key recommendations from the official Effective Dart documentation, covering style, documentation, language usage, and API design principles. Adhering to these guidelines promotes consistent, readable, and maintainable Dart code.
|
|
4
|
-
|
|
5
|
-
## 1. Style
|
|
6
|
-
|
|
7
|
-
### 1.1. Identifiers
|
|
8
|
-
|
|
9
|
-
- **DO** name types, extensions, and enum types using `UpperCamelCase`.
|
|
10
|
-
- **DO** name packages, directories, and source files using `lowercase_with_underscores`.
|
|
11
|
-
- **DO** name import prefixes using `lowercase_with_underscores`.
|
|
12
|
-
- **DO** name other identifiers (class members, top-level definitions, variables, parameters) using `lowerCamelCase`.
|
|
13
|
-
- **PREFER** using `lowerCamelCase` for constant names.
|
|
14
|
-
- **DO** capitalize acronyms and abbreviations longer than two letters like words (e.g., `Http`, `Nasa`, `Uri`). Two-letter acronyms (e.g., `ID`, `TV`, `UI`) should remain capitalized.
|
|
15
|
-
- **PREFER** using wildcards (`_`) for unused callback parameters in anonymous and local functions.
|
|
16
|
-
- **DON'T** use a leading underscore for identifiers that aren't private.
|
|
17
|
-
- **DON'T** use prefix letters (e.g., `kDefaultTimeout`).
|
|
18
|
-
- **DON'T** explicitly name libraries using the `library` directive.
|
|
19
|
-
|
|
20
|
-
### 1.2. Ordering
|
|
21
|
-
|
|
22
|
-
- **DO** place `dart:` imports before other imports.
|
|
23
|
-
- **DO** place `package:` imports before relative imports.
|
|
24
|
-
- **DO** specify exports in a separate section after all imports.
|
|
25
|
-
- **DO** sort sections alphabetically.
|
|
26
|
-
|
|
27
|
-
### 1.3. Formatting
|
|
28
|
-
|
|
29
|
-
- **DO** format your code using `dart format`.
|
|
30
|
-
- **CONSIDER** changing your code to make it more formatter-friendly (e.g., shortening long identifiers, simplifying nested expressions).
|
|
31
|
-
- **PREFER** lines 80 characters or fewer.
|
|
32
|
-
- **DO** use curly braces for all flow control statements (`if`, `for`, `while`, `do`, `try`, `catch`, `finally`).
|
|
33
|
-
|
|
34
|
-
## 2. Documentation
|
|
35
|
-
|
|
36
|
-
### 2.1. Comments
|
|
37
|
-
|
|
38
|
-
- **DO** format comments like sentences (capitalize the first word, end with a period).
|
|
39
|
-
- **DON'T** use block comments (`/* ... */`) for documentation; use `//` for regular comments.
|
|
40
|
-
|
|
41
|
-
### 2.2. Doc Comments
|
|
42
|
-
|
|
43
|
-
- **DO** use `///` doc comments to document members and types.
|
|
44
|
-
- **PREFER** writing doc comments for public APIs.
|
|
45
|
-
- **CONSIDER** writing a library-level doc comment.
|
|
46
|
-
- **CONSIDER** writing doc comments for private APIs.
|
|
47
|
-
- **DO** start doc comments with a single-sentence summary.
|
|
48
|
-
- **DO** separate the first sentence of a doc comment into its own paragraph.
|
|
49
|
-
- **AVOID** redundancy with the surrounding context (e.g., don't repeat the class name in its doc comment).
|
|
50
|
-
- **PREFER** starting comments of a function or method with third-person verbs if its main purpose is a side effect (e.g., "Connects to...").
|
|
51
|
-
- **PREFER** starting a non-boolean variable or property comment with a noun phrase (e.g., "The current day...").
|
|
52
|
-
- **PREFER** starting a boolean variable or property comment with "Whether" followed by a noun or gerund phrase (e.g., "Whether the modal is...").
|
|
53
|
-
- **PREFER** a noun phrase or non-imperative verb phrase for a function or method if returning a value is its primary purpose.
|
|
54
|
-
- **DON'T** write documentation for both the getter and setter of a property.
|
|
55
|
-
- **PREFER** starting library or type comments with noun phrases.
|
|
56
|
-
- **CONSIDER** including code samples in doc comments using triple backticks.
|
|
57
|
-
- **DO** use square brackets (`[]`) in doc comments to refer to in-scope identifiers (e.g., `[StateError]`, `[anotherMethod()]`, `[Duration.inDays]`, `[Point.new]`).
|
|
58
|
-
- **DO** use prose to explain parameters, return values, and exceptions.
|
|
59
|
-
- **DO** put doc comments before metadata annotations.
|
|
60
|
-
|
|
61
|
-
### 2.3. Markdown
|
|
62
|
-
|
|
63
|
-
- **AVOID** using markdown excessively.
|
|
64
|
-
- **AVOID** using HTML for formatting.
|
|
65
|
-
- **PREFER** backtick fences (```) for code blocks.
|
|
66
|
-
|
|
67
|
-
### 2.4. Writing
|
|
68
|
-
|
|
69
|
-
- **PREFER** brevity.
|
|
70
|
-
- **AVOID** abbreviations and acronyms unless they are obvious.
|
|
71
|
-
- **PREFER** using "this" instead of "the" to refer to a member's instance.
|
|
72
|
-
|
|
73
|
-
## 3. Usage
|
|
74
|
-
|
|
75
|
-
### 3.1. Libraries
|
|
76
|
-
|
|
77
|
-
- **DO** use strings in `part of` directives.
|
|
78
|
-
- **DON'T** import libraries that are inside the `src` directory of another package.
|
|
79
|
-
- **DON'T** allow an import path to reach into or out of `lib`.
|
|
80
|
-
- **PREFER** relative import paths when not crossing the `lib` boundary.
|
|
81
|
-
|
|
82
|
-
### 3.2. Null Safety
|
|
83
|
-
|
|
84
|
-
- **DON'T** explicitly initialize variables to `null`.
|
|
85
|
-
- **DON'T** use an explicit default value of `null`.
|
|
86
|
-
- **DON'T** use `true` or `false` in equality operations (e.g., `if (nonNullableBool == true)`).
|
|
87
|
-
- **AVOID** `late` variables if you need to check whether they are initialized; prefer nullable types.
|
|
88
|
-
- **CONSIDER** type promotion or null-check patterns for using nullable types.
|
|
89
|
-
|
|
90
|
-
### 3.3. Strings
|
|
91
|
-
|
|
92
|
-
- **DO** use adjacent strings to concatenate string literals.
|
|
93
|
-
- **PREFER** using interpolation (`$variable`, `${expression}`) to compose strings and values.
|
|
94
|
-
- **AVOID** using curly braces in interpolation when not needed (e.g., `'$name'` instead of `'${name}'`).
|
|
95
|
-
|
|
96
|
-
### 3.4. Collections
|
|
97
|
-
|
|
98
|
-
- **DO** use collection literals (`[]`, `{}`, `<type>{}`) when possible.
|
|
99
|
-
- **DON'T** use `.length` to check if a collection is empty; use `.isEmpty` or `.isNotEmpty`.
|
|
100
|
-
- **AVOID** using `Iterable.forEach()` with a function literal; prefer `for-in` loops.
|
|
101
|
-
- **DON'T** use `List.from()` unless you intend to change the type of the result; prefer `.toList()`.
|
|
102
|
-
- **DO** use `whereType()` to filter a collection by type.
|
|
103
|
-
- **AVOID** using `cast()` when a nearby operation (like `List<T>.from()` or `map<T>()`) will do.
|
|
104
|
-
|
|
105
|
-
### 3.5. Functions
|
|
106
|
-
|
|
107
|
-
- **DO** use a function declaration to bind a function to a name.
|
|
108
|
-
- **DON'T** create a lambda when a tear-off will do (e.g., `list.forEach(print)` instead of `list.forEach((e) => print(e))`).
|
|
109
|
-
|
|
110
|
-
### 3.6. Variables
|
|
111
|
-
|
|
112
|
-
- **DO** follow a consistent rule for `var` and `final` on local variables (either `final` for non-reassigned and `var` for reassigned, or `var` for all locals).
|
|
113
|
-
- **AVOID** storing what you can calculate (e.g., don't store `area` if you have `radius`).
|
|
114
|
-
|
|
115
|
-
### 3.7. Members
|
|
116
|
-
|
|
117
|
-
- **DON'T** wrap a field in a getter and setter unnecessarily.
|
|
118
|
-
- **PREFER** using a `final` field to make a read-only property.
|
|
119
|
-
- **CONSIDER** using `=>` for simple members (getters, setters, single-expression methods).
|
|
120
|
-
- **DON'T** use `this.` except to redirect to a named constructor or to avoid shadowing.
|
|
121
|
-
- **DO** initialize fields at their declaration when possible.
|
|
122
|
-
|
|
123
|
-
### 3.8. Constructors
|
|
124
|
-
|
|
125
|
-
- **DO** use initializing formals (`this.field`) when possible.
|
|
126
|
-
- **DON'T** use `late` when a constructor initializer list will do.
|
|
127
|
-
- **DO** use `;` instead of `{}` for empty constructor bodies.
|
|
128
|
-
- **DON'T** use `new`.
|
|
129
|
-
- **DON'T** use `const` redundantly in constant contexts.
|
|
130
|
-
|
|
131
|
-
### 3.9. Error Handling
|
|
132
|
-
|
|
133
|
-
- **AVOID** `catch` clauses without `on` clauses.
|
|
134
|
-
- **DON'T** discard errors from `catch` clauses without `on` clauses.
|
|
135
|
-
- **DO** throw objects that implement `Error` only for programmatic errors.
|
|
136
|
-
- **DON'T** explicitly catch `Error` or types that implement it.
|
|
137
|
-
- **DO** use `rethrow` to rethrow a caught exception to preserve the original stack trace.
|
|
138
|
-
|
|
139
|
-
### 3.10. Asynchrony
|
|
140
|
-
|
|
141
|
-
- **PREFER** `async`/`await` over using raw `Future`s.
|
|
142
|
-
- **DON'T** use `async` when it has no useful effect.
|
|
143
|
-
- **CONSIDER** using higher-order methods to transform a stream.
|
|
144
|
-
- **AVOID** using `Completer` directly.
|
|
145
|
-
|
|
146
|
-
## 4. API Design
|
|
147
|
-
|
|
148
|
-
### 4.1. Names
|
|
149
|
-
|
|
150
|
-
- **DO** use terms consistently.
|
|
151
|
-
- **AVOID** abbreviations unless more common than the unabbreviated term.
|
|
152
|
-
- **PREFER** putting the most descriptive noun last (e.g., `pageCount`).
|
|
153
|
-
- **CONSIDER** making the code read like a sentence when using the API.
|
|
154
|
-
- **PREFER** a noun phrase for a non-boolean property or variable.
|
|
155
|
-
- **PREFER** a non-imperative verb phrase for a boolean property or variable (e.g., `isEnabled`, `canClose`).
|
|
156
|
-
- **CONSIDER** omitting the verb for a named boolean parameter (e.g., `growable: true`).
|
|
157
|
-
- **PREFER** the "positive" name for a boolean property or variable (e.g., `isConnected` over `isDisconnected`).
|
|
158
|
-
- **PREFER** an imperative verb phrase for a function or method whose main purpose is a side effect (e.g., `list.add()`, `window.refresh()`).
|
|
159
|
-
- **PREFER** a noun phrase or non-imperative verb phrase for a function or method if returning a value is its primary purpose (e.g., `list.elementAt(3)`).
|
|
160
|
-
- **CONSIDER** an imperative verb phrase for a function or method if you want to draw attention to the work it performs (e.g., `database.downloadData()`).
|
|
161
|
-
- **AVOID** starting a method name with `get`.
|
|
162
|
-
- **PREFER** naming a method `to___()` if it copies the object's state to a new object (e.g., `toList()`).
|
|
163
|
-
- **PREFER** naming a method `as___()` if it returns a different representation backed by the original object (e.g., `asMap()`).
|
|
164
|
-
- **AVOID** describing the parameters in the function's or method's name.
|
|
165
|
-
- **DO** follow existing mnemonic conventions when naming type parameters (e.g., `E` for elements, `K`, `V` for map keys/values, `T`, `S`, `U` for general types).
|
|
166
|
-
|
|
167
|
-
### 4.2. Libraries
|
|
168
|
-
|
|
169
|
-
- **PREFER** making declarations private (`_`).
|
|
170
|
-
- **CONSIDER** declaring multiple classes in the same library if they logically belong together.
|
|
171
|
-
|
|
172
|
-
### 4.3. Classes and Mixins
|
|
173
|
-
|
|
174
|
-
- **AVOID** defining a one-member abstract class when a simple function (`typedef`) will do.
|
|
175
|
-
- **AVOID** defining a class that contains only static members; prefer top-level functions/variables or a library.
|
|
176
|
-
- **AVOID** extending a class that isn't intended to be subclassed.
|
|
177
|
-
- **DO** use class modifiers (e.g., `final`, `interface`, `sealed`) to control if your class can be extended.
|
|
178
|
-
- **AVOID** implementing a class that isn't intended to be an interface.
|
|
179
|
-
- **DO** use class modifiers to control if your class can be an interface.
|
|
180
|
-
- **PREFER** defining a pure mixin or pure class to a `mixin class`.
|
|
181
|
-
|
|
182
|
-
### 4.4. Constructors
|
|
183
|
-
|
|
184
|
-
- **CONSIDER** making your constructor `const` if the class supports it (all fields are `final` and initialized in the constructor).
|
|
185
|
-
|
|
186
|
-
### 4.5. Members
|
|
187
|
-
|
|
188
|
-
- **PREFER** making fields and top-level variables `final`.
|
|
189
|
-
- **DO** use getters for operations that conceptually access properties (no arguments, returns a result, no user-visible side effects, idempotent).
|
|
190
|
-
- **DO** use setters for operations that conceptually change properties (single argument, no result, changes state, idempotent).
|
|
191
|
-
- **DON'T** define a setter without a corresponding getter.
|
|
192
|
-
- **AVOID** using runtime type tests to fake overloading.
|
|
193
|
-
- **AVOID** public `late final` fields without initializers.
|
|
194
|
-
- **AVOID** returning nullable `Future`, `Stream`, and collection types; prefer empty containers or non-nullable futures of nullable types.
|
|
195
|
-
- **AVOID** returning `this` from methods just to enable a fluent interface; prefer method cascades.
|
|
196
|
-
|
|
197
|
-
### 4.6. Types
|
|
198
|
-
|
|
199
|
-
- **DO** type annotate variables without initializers.
|
|
200
|
-
- **DO** type annotate fields and top-level variables if the type isn't obvious.
|
|
201
|
-
- **DON'T** redundantly type annotate initialized local variables.
|
|
202
|
-
- **DO** annotate return types on function declarations.
|
|
203
|
-
- **DO** annotate parameter types on function declarations.
|
|
204
|
-
- **DON'T** annotate inferred parameter types on function expressions.
|
|
205
|
-
- **DON'T** type annotate initializing formals.
|
|
206
|
-
- **DO** write type arguments on generic invocations that aren't inferred.
|
|
207
|
-
- **DON'T** write type arguments on generic invocations that are inferred.
|
|
208
|
-
- **AVOID** writing incomplete generic types.
|
|
209
|
-
- **DO** annotate with `dynamic` instead of letting inference fail silently.
|
|
210
|
-
- **PREFER** signatures in function type annotations.
|
|
211
|
-
- **DON'T** specify a return type for a setter.
|
|
212
|
-
- **DON'T** use the legacy `typedef` syntax.
|
|
213
|
-
- **PREFER** inline function types over `typedef`s.
|
|
214
|
-
- **PREFER** using function type syntax for parameters.
|
|
215
|
-
- **AVOID** using `dynamic` unless you want to disable static checking.
|
|
216
|
-
- **DO** use `Future<void>` as the return type of asynchronous members that do not produce values.
|
|
217
|
-
- **AVOID** using `FutureOr<T>` as a return type.
|
|
218
|
-
|
|
219
|
-
### 4.7. Parameters
|
|
220
|
-
|
|
221
|
-
- **AVOID** positional boolean parameters.
|
|
222
|
-
- **AVOID** optional positional parameters if the user may want to omit earlier parameters.
|
|
223
|
-
- **AVOID** mandatory parameters that accept a special "no argument" value.
|
|
224
|
-
- **DO** use inclusive start and exclusive end parameters to accept a range.
|
|
225
|
-
|
|
226
|
-
### 4.8. Equality
|
|
227
|
-
|
|
228
|
-
- **DO** override `hashCode` if you override `==`.
|
|
229
|
-
- **DO** make your `==` operator obey the mathematical rules of equality (reflexive, symmetric, transitive, consistent).
|
|
230
|
-
- **AVOID** defining custom equality for mutable classes.
|
|
231
|
-
- **DON'T** make the parameter to `==` nullable.
|
|
232
|
-
|
|
233
|
-
_Sources:_
|
|
234
|
-
|
|
235
|
-
- [Effective Dart: Style](https://dart.dev/effective-dart/style)
|
|
236
|
-
- [Effective Dart: Documentation](https://dart.dev/effective-dart/documentation)
|
|
237
|
-
- [Effective Dart: Usage](https://dart.dev/effective-dart/usage)
|
|
238
|
-
- [Effective Dart: Design](https://dart.dev/effective-dart/design)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# General Code Style Principles
|
|
2
|
-
|
|
3
|
-
This document outlines general coding principles that apply across all languages and frameworks used in this project.
|
|
4
|
-
|
|
5
|
-
## Readability
|
|
6
|
-
- Code should be easy to read and understand by humans.
|
|
7
|
-
- Avoid overly clever or obscure constructs.
|
|
8
|
-
|
|
9
|
-
## Consistency
|
|
10
|
-
- Follow existing patterns in the codebase.
|
|
11
|
-
- Maintain consistent formatting, naming, and structure.
|
|
12
|
-
|
|
13
|
-
## Simplicity
|
|
14
|
-
- Prefer simple solutions over complex ones.
|
|
15
|
-
- Break down complex problems into smaller, manageable parts.
|
|
16
|
-
|
|
17
|
-
## Maintainability
|
|
18
|
-
- Write code that is easy to modify and extend.
|
|
19
|
-
- Minimize dependencies and coupling.
|
|
20
|
-
|
|
21
|
-
## Documentation
|
|
22
|
-
- Document *why* something is done, not just *what*.
|
|
23
|
-
- Keep documentation up-to-date with code changes.
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# Effective Go Style Guide Summary
|
|
2
|
-
|
|
3
|
-
This document summarizes key rules and best practices from the official "Effective Go" guide for writing idiomatic Go code.
|
|
4
|
-
|
|
5
|
-
## 1. Formatting
|
|
6
|
-
- **`gofmt`:** All Go code **must** be formatted with `gofmt` (or `go fmt`). This is a non-negotiable, automated standard.
|
|
7
|
-
- **Indentation:** Use tabs for indentation (`gofmt` handles this).
|
|
8
|
-
- **Line Length:** Go has no strict line length limit. Let `gofmt` handle line wrapping.
|
|
9
|
-
|
|
10
|
-
## 2. Naming
|
|
11
|
-
- **`MixedCaps`:** Use `MixedCaps` or `mixedCaps` for multi-word names. Do not use underscores.
|
|
12
|
-
- **Exported vs. Unexported:** Names starting with an uppercase letter are exported (public). Names starting with a lowercase letter are not exported (private).
|
|
13
|
-
- **Package Names:** Short, concise, single-word, lowercase names.
|
|
14
|
-
- **Getters:** Do not name getters with a `Get` prefix. A getter for a field named `owner` should be named `Owner()`.
|
|
15
|
-
- **Interface Names:** One-method interfaces are named by the method name plus an `-er` suffix (e.g., `Reader`, `Writer`).
|
|
16
|
-
|
|
17
|
-
## 3. Control Structures
|
|
18
|
-
- **`if`:** No parentheses around the condition. Braces are mandatory. Can include an initialization statement (e.g., `if err := file.Chmod(0664); err != nil`).
|
|
19
|
-
- **`for`:** Go's only looping construct. Unifies `for` and `while`. Use `for...range` to iterate over slices, maps, strings, and channels.
|
|
20
|
-
- **`switch`:** More general than in C. Cases do not fall through by default (use `fallthrough` explicitly). Can be used without an expression to function as a cleaner `if-else-if` chain.
|
|
21
|
-
|
|
22
|
-
## 4. Functions
|
|
23
|
-
- **Multiple Returns:** Functions can return multiple values. This is the standard way to return a result and an error (e.g., `value, err`).
|
|
24
|
-
- **Named Result Parameters:** Return parameters can be named. This can make code clearer and more concise.
|
|
25
|
-
- **`defer`:** Schedules a function call to be run immediately before the function executing `defer` returns. Use it for cleanup tasks like closing files.
|
|
26
|
-
|
|
27
|
-
## 5. Data
|
|
28
|
-
- **`new` vs. `make`:**
|
|
29
|
-
- `new(T)`: Allocates memory for a new item of type `T`, zeroes it, and returns a pointer (`*T`).
|
|
30
|
-
- `make(T, ...)`: Creates and initializes slices, maps, and channels only. Returns an initialized value of type `T` (not a pointer).
|
|
31
|
-
- **Slices:** The preferred way to work with sequences. They are more flexible than arrays.
|
|
32
|
-
- **Maps:** Use the "comma ok" idiom to check for the existence of a key: `value, ok := myMap[key]`.
|
|
33
|
-
|
|
34
|
-
## 6. Interfaces
|
|
35
|
-
- **Implicit Implementation:** A type implements an interface by implementing its methods. No `implements` keyword is needed.
|
|
36
|
-
- **Small Interfaces:** Prefer many small interfaces over one large one. The standard library is full of single-method interfaces (e.g., `io.Reader`).
|
|
37
|
-
|
|
38
|
-
## 7. Concurrency
|
|
39
|
-
- **Share Memory By Communicating:** This is the core philosophy. Do not communicate by sharing memory; instead, share memory by communicating.
|
|
40
|
-
- **Goroutines:** Lightweight, concurrently executing functions. Start one with the `go` keyword.
|
|
41
|
-
- **Channels:** Typed conduits for communication between goroutines. Use `make` to create them.
|
|
42
|
-
|
|
43
|
-
## 8. Errors
|
|
44
|
-
- **`error` type:** The built-in `error` interface is the standard way to handle errors.
|
|
45
|
-
- **Explicit Error Handling:** Do not discard errors with the blank identifier (`_`). Check for errors explicitly.
|
|
46
|
-
- **`panic`:** Reserved for truly exceptional, unrecoverable situations. Generally, libraries should not panic.
|
|
47
|
-
|
|
48
|
-
*Source: [Effective Go](https://go.dev/doc/effective_go)*
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# Google HTML/CSS Style Guide Summary
|
|
2
|
-
|
|
3
|
-
This document summarizes key rules and best practices from the Google HTML/CSS Style Guide.
|
|
4
|
-
|
|
5
|
-
## 1. General Rules
|
|
6
|
-
- **Protocol:** Use HTTPS for all embedded resources.
|
|
7
|
-
- **Indentation:** Indent by 2 spaces. Do not use tabs.
|
|
8
|
-
- **Capitalization:** Use only lowercase for all code (element names, attributes, selectors, properties).
|
|
9
|
-
- **Trailing Whitespace:** Remove all trailing whitespace.
|
|
10
|
-
- **Encoding:** Use UTF-8 (without a BOM). Specify `<meta charset="utf-8">` in HTML.
|
|
11
|
-
|
|
12
|
-
## 2. HTML Style Rules
|
|
13
|
-
- **Document Type:** Use `<!doctype html>`.
|
|
14
|
-
- **HTML Validity:** Use valid HTML.
|
|
15
|
-
- **Semantics:** Use HTML elements according to their intended purpose (e.g., use `<p>` for paragraphs, not for spacing).
|
|
16
|
-
- **Multimedia Fallback:** Provide `alt` text for images and transcripts/captions for audio/video.
|
|
17
|
-
- **Separation of Concerns:** Strictly separate structure (HTML), presentation (CSS), and behavior (JavaScript). Link to CSS and JS from external files.
|
|
18
|
-
- **`type` Attributes:** Omit `type` attributes for stylesheets (`<link>`) and scripts (`<script>`).
|
|
19
|
-
|
|
20
|
-
## 3. HTML Formatting Rules
|
|
21
|
-
- **General:** Use a new line for every block, list, or table element, and indent its children.
|
|
22
|
-
- **Quotation Marks:** Use double quotation marks (`""`) for attribute values.
|
|
23
|
-
|
|
24
|
-
## 4. CSS Style Rules
|
|
25
|
-
- **CSS Validity:** Use valid CSS.
|
|
26
|
-
- **Class Naming:** Use meaningful, generic names. Separate words with a hyphen (`-`).
|
|
27
|
-
- **Good:** `.video-player`, `.site-navigation`
|
|
28
|
-
- **Bad:** `.vid`, `.red-text`
|
|
29
|
-
- **ID Selectors:** Avoid using ID selectors for styling. Prefer class selectors.
|
|
30
|
-
- **Shorthand Properties:** Use shorthand properties where possible (e.g., `padding`, `font`).
|
|
31
|
-
- **`0` and Units:** Omit units for `0` values (e.g., `margin: 0;`).
|
|
32
|
-
- **Leading `0`s:** Always include leading `0`s for decimal values (e.g., `font-size: 0.8em;`).
|
|
33
|
-
- **Hexadecimal Notation:** Use 3-character hex notation where possible (e.g., `#fff`).
|
|
34
|
-
- **`!important`:** Avoid using `!important`.
|
|
35
|
-
|
|
36
|
-
## 5. CSS Formatting Rules
|
|
37
|
-
- **Declaration Order:** Alphabetize declarations within a rule.
|
|
38
|
-
- **Indentation:** Indent all block content.
|
|
39
|
-
- **Semicolons:** Use a semicolon after every declaration.
|
|
40
|
-
- **Spacing:**
|
|
41
|
-
- Use a space after a property name's colon (`font-weight: bold;`).
|
|
42
|
-
- Use a space between the last selector and the opening brace (`.foo {`).
|
|
43
|
-
- Start a new line for each selector and declaration.
|
|
44
|
-
- **Rule Separation:** Separate rules with a new line.
|
|
45
|
-
- **Quotation Marks:** Use single quotes (`''`) for attribute selectors and property values (e.g., `[type='text']`).
|
|
46
|
-
|
|
47
|
-
**BE CONSISTENT.** When editing code, match the existing style.
|
|
48
|
-
|
|
49
|
-
*Source: [Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html)*
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Google JavaScript Style Guide Summary
|
|
2
|
-
|
|
3
|
-
This document summarizes key rules and best practices from the Google JavaScript Style Guide.
|
|
4
|
-
|
|
5
|
-
## 1. Source File Basics
|
|
6
|
-
- **File Naming:** All lowercase, with underscores (`_`) or dashes (`-`). Extension must be `.js`.
|
|
7
|
-
- **File Encoding:** UTF-8.
|
|
8
|
-
- **Whitespace:** Use only ASCII horizontal spaces (0x20). Tabs are forbidden for indentation.
|
|
9
|
-
|
|
10
|
-
## 2. Source File Structure
|
|
11
|
-
- New files should be ES modules (`import`/`export`).
|
|
12
|
-
- **Exports:** Use named exports (`export {MyClass};`). **Do not use default exports.**
|
|
13
|
-
- **Imports:** Do not use line-wrapped imports. The `.js` extension in import paths is mandatory.
|
|
14
|
-
|
|
15
|
-
## 3. Formatting
|
|
16
|
-
- **Braces:** Required for all control structures (`if`, `for`, `while`, etc.), even single-line blocks. Use K&R style ("Egyptian brackets").
|
|
17
|
-
- **Indentation:** +2 spaces for each new block.
|
|
18
|
-
- **Semicolons:** Every statement must be terminated with a semicolon.
|
|
19
|
-
- **Column Limit:** 80 characters.
|
|
20
|
-
- **Line-wrapping:** Indent continuation lines at least +4 spaces.
|
|
21
|
-
- **Whitespace:** Use single blank lines between methods. No trailing whitespace.
|
|
22
|
-
|
|
23
|
-
## 4. Language Features
|
|
24
|
-
- **Variable Declarations:** Use `const` by default, `let` if reassignment is needed. **`var` is forbidden.**
|
|
25
|
-
- **Array Literals:** Use trailing commas. Do not use the `Array` constructor.
|
|
26
|
-
- **Object Literals:** Use trailing commas and shorthand properties. Do not use the `Object` constructor.
|
|
27
|
-
- **Classes:** Do not use JavaScript getter/setter properties (`get name()`). Provide ordinary methods instead.
|
|
28
|
-
- **Functions:** Prefer arrow functions for nested functions to preserve `this` context.
|
|
29
|
-
- **String Literals:** Use single quotes (`'`). Use template literals (`` ` ``) for multi-line strings or complex interpolation.
|
|
30
|
-
- **Control Structures:** Prefer `for-of` loops. `for-in` loops should only be used on dict-style objects.
|
|
31
|
-
- **`this`:** Only use `this` in class constructors, methods, or in arrow functions defined within them.
|
|
32
|
-
- **Equality Checks:** Always use identity operators (`===` / `!==`).
|
|
33
|
-
|
|
34
|
-
## 5. Disallowed Features
|
|
35
|
-
- `with` keyword.
|
|
36
|
-
- `eval()` or `Function(...string)`.
|
|
37
|
-
- Automatic Semicolon Insertion.
|
|
38
|
-
- Modifying builtin objects (`Array.prototype.foo = ...`).
|
|
39
|
-
|
|
40
|
-
## 6. Naming
|
|
41
|
-
- **Classes:** `UpperCamelCase`.
|
|
42
|
-
- **Methods & Functions:** `lowerCamelCase`.
|
|
43
|
-
- **Constants:** `CONSTANT_CASE` (all uppercase with underscores).
|
|
44
|
-
- **Non-constant Fields & Variables:** `lowerCamelCase`.
|
|
45
|
-
|
|
46
|
-
## 7. JSDoc
|
|
47
|
-
- JSDoc is used on all classes, fields, and methods.
|
|
48
|
-
- Use `@param`, `@return`, `@override`, `@deprecated`.
|
|
49
|
-
- Type annotations are enclosed in braces (e.g., `/** @param {string} userName */`).
|
|
50
|
-
|
|
51
|
-
*Source: [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html)*
|