Created
January 18, 2022 12:41
-
-
Save tynrare/207361919b43b2d50f0a36bb279523b5 to your computer and use it in GitHub Desktop.
Most generic javascript ES6 class file template
This file contains 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
/** | |
* This file provides basic structure for any JS class in my projects | |
* Don't forget to use doxygen comments https://jsdoc.app/ | |
* This file linted with strict eslint rules https://eslint.org/ | |
* Use prettier to format your files https://prettier.io/ | |
* | |
* @file ClassTemplate.js | |
* @author tynrare | |
* @version 1 | |
* @module Templates | |
*/ | |
/** | |
* % insert class description here % | |
*/ | |
export default class ClassTemplate { | |
/** | |
* % use constructor only for fields declaration % | |
* @example | |
* | |
* // Good | |
* this.someField = 'value' | |
* | |
* // Bad | |
* document.getElementById('#element').onclick('...') | |
*/ | |
constructor() { | |
// ... | |
} | |
/** | |
* % use init for any state-changing operation, other inits, etc. % | |
* % always return this % | |
* | |
* #chain | |
* | |
* @returns {ClassTemplate} this | |
*/ | |
init() { | |
return this; | |
} | |
/** | |
* % clean up anything you've changed in init() or other functions | |
*/ | |
dispose() { | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment