Skip to content

Commit

Permalink
feat(rules): remove fixer for async/await
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Woolum committed Jul 25, 2018
1 parent be4f917 commit 4df69cf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 54 deletions.
2 changes: 1 addition & 1 deletion src/ionOverlayMethodCreateShouldUseAwaitRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CreateMethodShouldUseAwaitWalker extends Lint.RuleWalker {

if (isValidForRule(node, 'create', ...matchingControllers) && tsutils.isObjectLiteralExpression(firstArgument)) {
if (node.parent.kind !== ts.SyntaxKind.AwaitExpression) {
this.addFailureAtNode(node, ruleMessage, Lint.Replacement.replaceFromTo(node.getStart(), node.getStart(), 'await '));
this.addFailureAtNode(node, ruleMessage);
}
}
}
Expand Down
53 changes: 0 additions & 53 deletions test/ionOverlayMethodCreateShouldUseAwaitRule.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { expect } from 'chai';
import { Replacement, RuleFailure, Utils } from '../node_modules/tslint';
import { ruleMessage, ruleName } from '../src/ionOverlayMethodCreateShouldUseAwaitRule';
import { assertAnnotated, assertSuccess } from './testHelper';

Expand Down Expand Up @@ -78,57 +76,6 @@ describe(ruleName, () => {
});
});
});

describe('replacements', () => {
it('should replace multiple', () => {
let source = `
class DoSomething{
constructor(private actionSheetController: ${controller}){}
doWork(){
this.actionSheetController.create({
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
component: PopoverComponent,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ev: event,
~~~~~~~~~~
translucent: true
~~~~~~~~~~~~~~~~~
})
~~
}
}
`;

let failures = assertAnnotated({
ruleName,
message: ruleMessage,
source
});

const fixes = (failures as RuleFailure[]).map(f => f.getFix());
const res = Replacement.applyAll(source, Utils.flatMap(fixes, Utils.arrayify));

expect(res).to.eq(`
class DoSomething{
constructor(private actionSheetController: ${controller}){}
doWork(){
await this.actionSheetController.create({
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
component: PopoverComponent,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ev: event,
~~~~~~~~~~
translucent: true
~~~~~~~~~~~~~~~~~
})
~~
}
}
`);
});
});
});
}
});

0 comments on commit 4df69cf

Please sign in to comment.