-
Notifications
You must be signed in to change notification settings - Fork 161
Document coding standards and conventions #523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
Guide to Contributing | ||
===================== | ||
|
||
Contents: | ||
|
||
* Packages | ||
* Files | ||
* Facades | ||
* Non-Facades | ||
* Partially-Supported DOM API | ||
* Binary Compatibility | ||
* Submitting a PR | ||
|
||
|
||
Packages | ||
======== | ||
|
||
TODO: Put `beacon` in `dom` | ||
TODO: Put DOMParser in `dom` with its extra types in its companion object | ||
TODO: Put `gamepad` in `dom` | ||
TODO: Put `push` in `dom`? Everything is `Push*`. Or will there be `Push*` from other APIs too? Do we care? | ||
TODO: Put `sharedworkers` in `dom` | ||
TODO: Put `storage` in `dom`? Does it really warrant its own package? | ||
TODO: Put `webgl/extensions` in `webgl` | ||
TODO: The `ext` package is named confusingly imo. Ideally we could rename it to something clearer. | ||
|
||
``` | ||
org.scalajs.dom — All top-level facades | ||
+-- beacon — Beacon API | ||
+-- crypto — Crypto API | ||
+-- deviceorientation — Device Orientation API | ||
+-- domparser — DOMParser API | ||
+-- ext — Scala helpers for nicer usage | ||
+-- gamepad — Gamepad API | ||
+-- intl — Internationalization API | ||
+-- mediastream — MediaStream API | ||
+-- permissions — Permissions API | ||
+-- push — Push API | ||
+-- raw — deprecated. Remains only for backwards-compatibility | ||
+-- serviceworkers — Service Workers API | ||
+-- sharedworkers — | ||
+-- storage — Storage API | ||
+-- webgl — WebGL API | ||
| +-- extensions — | ||
+-- webrtc — WebRTC API | ||
``` | ||
|
||
|
||
Files | ||
===== | ||
|
||
* Use `package.scala` for a package object and nothing else. | ||
Also don't include traits/classes/objects. | ||
|
||
* Match the filename to the trait/class/object in it; don't add multiple top-level types. | ||
This is effectively Java-style. | ||
armanbilge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
Facades | ||
======= | ||
|
||
If a feature has many types that don't share a common unambiguous prefix (like `crypto`), | ||
* create a feature package | ||
* put all of its types in its package | ||
japgolly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
If a feature has only a few types that don't share a common unambiguous prefix (like `DOMParser`), | ||
* create a facade for the main feature | ||
* create a companion object for the facade | ||
* put all of its types in the companion object | ||
|
||
If a feature has types that all share a common unambiguous prefix (like `Gamepad*`), | ||
* put it all in `dom` | ||
|
||
|
||
Non-Facades | ||
=========== | ||
|
||
* Implicit conversions should go in companion objects so that they are always in scope without the | ||
need for imports. There's no need to group by feature, the types already specify the feature. | ||
|
||
* Add Scala-only utilities that pertain to a specific facade, in the facades companion object | ||
Eg: helper constructors, legal facade values. | ||
|
||
* Add Scala-only utilities that don't pertain to a specific facade, or shouldn't be universally | ||
available (subjective judgement here) in the `ext` package. | ||
japgolly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
Partially-Supported DOM API | ||
=========================== | ||
|
||
TODO: Pending discussion in #514 | ||
|
||
armanbilge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Binary Compatibility | ||
==================== | ||
|
||
Binary compatibility for Scala.JS facades is different than standard Scala. | ||
japgolly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
The following are changes that are indeed incompatible in both formats: | ||
|
||
Don't: | ||
* Remove a trait / class / object | ||
* Change a class into a trait or vice versa | ||
|
||
Here is a non-exhaustive list of changes that would be binary incompatible for Scala classes, but | ||
are compatible for JS facade types: | ||
|
||
You can: | ||
* Remove a member | ||
* Change the type or signature of a member | ||
* Add a field in a trait | ||
* Add an abstract member in a trait | ||
|
||
|
||
Submitting a PR | ||
=============== | ||
|
||
Once you're done making your changes... | ||
|
||
1. Run `sbt prePR` | ||
2. Run `git diff api-reports` and ensure that you aren't breaking backwards-binary-compatibility | ||
(see above). We'll probably automate this step in the future (See #503) | ||
armanbilge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3. Check in and commit the changes to `api-reports` | ||
4. Submit your PR | ||
5. Know that your contribution is appreciated, thank you! |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.