Disable prettier for a single file

If you want a certain file in a repo to never be formatted by prettier, you can add it to a .prettierignore file: Disable Prettier for one file From the docs: To exclude files from formatting, create a .prettierignore file in the root of your project. .prettierignore uses gitignore syntax. Example: # Ignore artifacts: build … Read more

TypeScript custom declaration files for untyped npm modules

The declaration declare module ‘shiitake’; should be in a global scope. i.e. a top-level declaration in a non-module (where a module is a file with at least one top-level import or export). A declaration of the form declare module ‘…’ { } in a module is an augmentation. For more details see Typescript Module Augmentation. … Read more

async await in image loading

Your problem here extends from the definition for await… The await operator is used to wait for a Promise The Image.prototype.onload property is not a promise, nor are you assigning it one. If you’re wanting to return the height property after loading, I would instead create a Promise… addImageProcess(src){ return new Promise((resolve, reject) => { … Read more

How to check if a Promise is pending [duplicate]

You can attach a then handler that sets a done flag on the promise (or the RunTest instance if you prefer), and test that: if (!this.promise) { this.promise = this.someTest(); this.promise.catch(() => {}).then(() => { this.promise.done = true; }); retVal = true; } if ( this.promise.done ) { this.promise = this.someTest(); this.promise.catch(() => {}).then(() => … Read more

javascript import from ‘/folder’ with index.js

Is this actually part of the specification? No. How module identifiers (‘./reducers’ in your case) are resolved to the actual modules is left to the implementation of the module loader/bundler, it’s not specificed by ES6. And it doesn’t seem to be specified in CommonJs either. This is just how node does it – when requiring … Read more

let keyword in the for loop

squint’s answer is no longer up-to-date. In ECMA 6 specification, the specified behaviour is that in for(let i;;){} i gets a new binding for every iteration of the loop. This means that every closure captures a different i instance. So the result of 012 is the correct result as of now. When you run this … Read more