forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Coding Guidelines
Brett Cannon edited this page Jun 10, 2019
·
2 revisions
- Always aim for small, targeted interfaces
-
IDisposable & IAsynDisposable
- Classes that require disposing of resources must implement the
IDisposable
interface - Classes that require disposing of resources in an async manner must implement the
IAsynDisposable
interface
- Classes that require disposing of resources must implement the
-
IExtensionActivationService
- Classes that require code to be executed during the startup of the extension must implement
IExtensionActivationService
- Classes that require code to be executed during the startup of the extension must implement
- Timers/Timeouts
- All timers/timeouts (setTimeout/setInterval) must be cleared in the
dispose
method of the class - This ensure we do not have any dangling timeouts preventing the process from gracefully exiting.
- All timers/timeouts (setTimeout/setInterval) must be cleared in the
-
Async Methods
- Async must be
awaited
where possible. - If awaiting on async methods is not required or not possible always use
ignoreErrors
to ensure we do not leave any dangling promises (i.e. promises where we do not handle exceptions). - Note: Not doing so could (in a future version of
Node.js
) crash the entire process.
- Async must be
- Write code to be testable
-
Localization
- All messages displayed to the user must be localized.