Skip to content

Commit cd0611d

Browse files
crisbetojelbourn
authored andcommitted
build: add more linting around async/await (#16976)
Given that we'll be using async/await a lot more because of the test harnesses, these changes enable the `await-promise` rule which ensures that the value that is being `await`-ed is a promise.
1 parent 050a027 commit cd0611d

File tree

8 files changed

+17
-16
lines changed

8 files changed

+17
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
"ts-api-guardian": "^0.4.6",
153153
"ts-node": "^3.0.4",
154154
"tsconfig-paths": "^2.3.0",
155-
"tslint": "^5.18.0",
155+
"tslint": "^5.19.0",
156156
"tsutils": "^3.0.0",
157157
"typescript": "3.5.3",
158158
"uglify-js": "^2.8.14"

src/cdk-experimental/testing/tests/protractor.e2e.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ describe('ProtractorHarnessEnvironment', () => {
1212
describe('HarnessLoader', () => {
1313
let loader: HarnessLoader;
1414

15-
beforeEach(async () => {
15+
beforeEach(() => {
1616
loader = ProtractorHarnessEnvironment.loader();
1717
});
1818

19-
it('should create HarnessLoader', async () => {
19+
it('should create HarnessLoader', () => {
2020
expect(loader).not.toBeNull();
2121
});
2222

src/cdk-experimental/testing/tests/testbed.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ describe('TestbedHarnessEnvironment', () => {
2121
describe('HarnessLoader', () => {
2222
let loader: HarnessLoader;
2323

24-
beforeEach(async () => {
24+
beforeEach(() => {
2525
loader = TestbedHarnessEnvironment.loader(fixture);
2626
});
2727

28-
it('should create HarnessLoader from fixture', async () => {
28+
it('should create HarnessLoader from fixture', () => {
2929
expect(loader).not.toBeNull();
3030
});
3131

src/material-experimental/mdc-chips/harness/chip-grid-harness.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('MatChipGridHarness', () => {
3434
it('should get the chip input harness', async () => {
3535
const harnesses = await loader.getAllHarnesses(MatChipGridHarness);
3636
const input = await harnesses[0].getTextInput();
37-
expect(await input).not.toBe(null);
37+
expect(input).not.toBe(null);
3838
});
3939
});
4040

src/material-experimental/mdc-chips/harness/chip-listbox-harness.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ describe('MatChipListboxHarness', () => {
3030
expect ((await harnesses[0].getOptions()).length).toBe(4);
3131
});
3232

33-
describe('should get selection', async () => {
33+
describe('should get selection', () => {
3434
it('with no selected options', async () => {
3535
const harnesses = await loader.getAllHarnesses(MatChipListboxHarness);
3636
const selectedOption = await harnesses[0].getSelected();
37-
expect(await selectedOption.length).toBe(0);
37+
expect(selectedOption.length).toBe(0);
3838
});
3939

4040
it('with a single selected option', async () => {
@@ -43,7 +43,7 @@ describe('MatChipListboxHarness', () => {
4343

4444
const harnesses = await loader.getAllHarnesses(MatChipListboxHarness);
4545
const selectedOption = await harnesses[0].getSelected();
46-
expect(await selectedOption.length).toBe(1);
46+
expect(selectedOption.length).toBe(1);
4747
expect(await selectedOption[0].getText()).toContain('Blue');
4848
});
4949

@@ -55,7 +55,7 @@ describe('MatChipListboxHarness', () => {
5555

5656
const harnesses = (await loader.getAllHarnesses(MatChipListboxHarness));
5757
const selectedOption = await harnesses[0].getSelected();
58-
expect(await selectedOption.length).toBe(2);
58+
expect(selectedOption.length).toBe(2);
5959
expect(await selectedOption[0].getText()).toContain('Blue');
6060
expect(await selectedOption[1].getText()).toContain('Green');
6161
});

src/material/icon/icon.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ describe('MatIcon without HttpClientModule', () => {
961961
sanitizer = ds;
962962
}));
963963

964-
it('should throw an error when trying to load a remote icon', async() => {
964+
it('should throw an error when trying to load a remote icon', () => {
965965
const expectedError = wrappedErrorMessage(getMatIconNoHttpProviderError());
966966

967967
expect(() => {

tslint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@
8181
],
8282
// Avoids inconsistent linebreak styles in source files. Forces developers to use LF linebreaks.
8383
"linebreak-style": [true, "LF"],
84-
// Namespaces are no allowed, because of Closure compiler.
84+
// Namespaces are not allowed, because of Closure compiler.
8585
"no-namespace": true,
8686
"jsdoc-format": [true, "check-multiline-start"],
8787
"no-duplicate-imports": true,
88+
"await-promise": true,
8889

8990
// Codelyzer
9091
"template-banana-in-box": true,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11854,10 +11854,10 @@ tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
1185411854
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
1185511855
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
1185611856

11857-
tslint@^5.18.0:
11858-
version "5.18.0"
11859-
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.18.0.tgz#f61a6ddcf372344ac5e41708095bbf043a147ac6"
11860-
integrity sha512-Q3kXkuDEijQ37nXZZLKErssQVnwCV/+23gFEMROi8IlbaBG6tXqLPQJ5Wjcyt/yHPKBC+hD5SzuGaMora+ZS6w==
11857+
tslint@^5.19.0:
11858+
version "5.19.0"
11859+
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.19.0.tgz#a2cbd4a7699386da823f6b499b8394d6c47bb968"
11860+
integrity sha512-1LwwtBxfRJZnUvoS9c0uj8XQtAnyhWr9KlNvDIdB+oXyT+VpsOAaEhEgKi1HrZ8rq0ki/AAnbGSv4KM6/AfVZw==
1186111861
dependencies:
1186211862
"@babel/code-frame" "^7.0.0"
1186311863
builtin-modules "^1.1.1"

0 commit comments

Comments
 (0)