Skip to content

style: add no-invalid-await and prefer-promise-shorthand lint rules #15450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/angular_devkit/architect/src/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('architect', () => {

it('reports errors in the builder (async)', async () => {
testArchitectHost.addBuilder('package:error', createBuilder(() => {
return new Promise((_, reject) => reject(new Error('Error async')));
return Promise.reject(new Error('Error async'));
}));

let run: BuilderRun | undefined = undefined;
Expand Down
24 changes: 12 additions & 12 deletions packages/angular_devkit/core/src/experimental/jobs/strategy_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ describe('strategy.serialize()', () => {
name: 'add',
});

const job1 = await scheduler.schedule('add', [1, 2, 3, 4]);
const job2 = await scheduler.schedule('add', [1, 2, 3, 4, 5]);
const job1 = scheduler.schedule('add', [1, 2, 3, 4]);
const job2 = scheduler.schedule('add', [1, 2, 3, 4, 5]);
expect(started).toBe(0);
expect(finished).toBe(0);

Expand Down Expand Up @@ -102,8 +102,8 @@ describe('strategy.serialize()', () => {
name: 'add100',
});

const job1 = await scheduler.schedule('add', [1, 2, 3, 4]);
const job2 = await scheduler.schedule('add100', [1, 2, 3, 4, 5]);
const job1 = scheduler.schedule('add', [1, 2, 3, 4]);
const job2 = scheduler.schedule('add100', [1, 2, 3, 4, 5]);
expect(started).toBe(0);
expect(finished).toBe(0);

Expand Down Expand Up @@ -159,8 +159,8 @@ describe('strategy.reuse()', () => {
name: 'add',
});

const job1 = await scheduler.schedule('add', [1, 2, 3, 4]);
const job2 = await scheduler.schedule('add', []);
const job1 = scheduler.schedule('add', [1, 2, 3, 4]);
const job2 = scheduler.schedule('add', []);
expect(started).toBe(0);
expect(finished).toBe(0);

Expand All @@ -179,8 +179,8 @@ describe('strategy.reuse()', () => {
expect(job1.state).toBe(JobState.Ended);
expect(job2.state).toBe(JobState.Ended);

const job3 = await scheduler.schedule('add', [1, 2, 3, 4, 5]);
const job4 = await scheduler.schedule('add', []);
const job3 = scheduler.schedule('add', [1, 2, 3, 4, 5]);
const job4 = scheduler.schedule('add', []);
job3.output.subscribe();
expect(started).toBe(2);
expect(finished).toBe(1);
Expand Down Expand Up @@ -226,10 +226,10 @@ describe('strategy.memoize()', () => {
name: 'add',
});

const job1 = await scheduler.schedule('add', [1, 2, 3, 4]);
const job2 = await scheduler.schedule('add', [1, 2, 3, 4]);
const job3 = await scheduler.schedule('add', [1, 2, 3, 4, 5]);
const job4 = await scheduler.schedule('add', [1, 2, 3, 4, 5]);
const job1 = scheduler.schedule('add', [1, 2, 3, 4]);
const job2 = scheduler.schedule('add', [1, 2, 3, 4]);
const job3 = scheduler.schedule('add', [1, 2, 3, 4, 5]);
const job4 = scheduler.schedule('add', [1, 2, 3, 4, 5]);
expect(started).toBe(0);
expect(finished).toBe(0);

Expand Down
2 changes: 1 addition & 1 deletion scripts/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default async function (options: { verbose: boolean }, logger: logging.Lo

logger.info('');
logger.info('Running commit validation...');
error = await validateCommits({}, logger.createChild('validate-commits')) != 0
error = validateCommits({}, logger.createChild('validate-commits')) != 0
|| error;

logger.info('');
Expand Down
2 changes: 2 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"no-unthrown-error": true,
"no-use-of-empty-return-value": true,
"no-useless-increment": true,
"no-invalid-await": true,
"prefer-promise-shorthand": true,

//These rules are part of the code smell detection section of tslint-sonarts
"no-dead-store": true,
Expand Down