Skip to content

Commit

Permalink
Enable no-floating-promises tslint rule (#626)
Browse files Browse the repository at this point in the history
This prevents the code from getting promises and not handling them
appropriately, a known source of subtle bugs and race conditions.
  • Loading branch information
RomainMuller committed Aug 26, 2018
1 parent 4bafcca commit 9f49274
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
16 changes: 8 additions & 8 deletions packages/aws-cdk/test/test.account-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import path = require('path');
import { AccountAccessKeyCache } from '../lib/api/util/account-cache';

export = {
'setUp'(cb: ICallbackFunction) {
async 'setUp'(cb: ICallbackFunction) {
const self = this as any;
fs.mkdtemp('/tmp/account-cache-test').then(dir => {
self.file = path.join(dir, 'cache.json');
self.cache = new AccountAccessKeyCache(self.file);
return cb();
});
const dir = await fs.mkdtemp('/tmp/account-cache-test');
self.file = path.join(dir, 'cache.json');
self.cache = new AccountAccessKeyCache(self.file);
return cb();
},

'tearDown'(cb: ICallbackFunction) {
async 'tearDown'(cb: ICallbackFunction) {
const self = this as any;
fs.remove(path.dirname(self.file)).then(cb);
await fs.remove(path.dirname(self.file));
cb();
},

async 'get(k) when cache is empty'(test: Test) {
Expand Down
2 changes: 1 addition & 1 deletion packages/simple-resource-bundler/bin/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function main() {
'export = resources;'
];

fs.writeFile(path.join(output, 'resources.d.ts'), declContents.join('\n'));
await fs.writeFile(path.join(output, 'resources.d.ts'), declContents.join('\n'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/cdk-build-tools/bin/cdk-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function main() {
await fs.move(tarball, path.join(target, path.basename(tarball)));
}

detector.markClean();
await detector.markClean();
}

main().then(() => {
Expand Down
3 changes: 3 additions & 0 deletions tslint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ rules:

# Without this rule, _blabla would be disallowed, which is necessary to silence unused variable errors.
variable-name: [true, "ban-keywords", "check-format", "allow-leading-underscore"]

# Unhandled promises are the source of all kinds of bugs and race conditions...
no-floating-promises: true

0 comments on commit 9f49274

Please sign in to comment.