Skip to content

Commit

Permalink
style: add no-invalid-await and prefer-promise-shorthand lint rul…
Browse files Browse the repository at this point in the history
…es (angular#15450)

Add these two lint rules for a better code quality and readability
  • Loading branch information
alan-agius4 authored and mgechev committed Aug 27, 2019
1 parent 5606a4c commit a6fbee6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
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

0 comments on commit a6fbee6

Please sign in to comment.