Skip to content

Instantly share code, notes, and snippets.

@tynrare
Created January 18, 2022 12:41
Show Gist options
  • Save tynrare/207361919b43b2d50f0a36bb279523b5 to your computer and use it in GitHub Desktop.
Save tynrare/207361919b43b2d50f0a36bb279523b5 to your computer and use it in GitHub Desktop.
Most generic javascript ES6 class file template
/**
* 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