Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 97df145

Browse files
author
Jacob Peddicord
committed
tslint: catch dangling promises
1 parent 5017581 commit 97df145

File tree

12 files changed

+54
-38
lines changed

12 files changed

+54
-38
lines changed

browser/components/projects/acl/ProjectAclEditor.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import * as ProjectActions from '../../../modules/projects';
2222
interface Props {
2323
dispatch: (action: any) => any;
2424
project: WebProject;
25-
groups: string[];
2625
}
2726

2827
interface State {
@@ -88,7 +87,6 @@ class ProjectAclEditor extends React.Component<Props, State> {
8887
}
8988

9089
render() {
91-
const { groups } = this.props;
9290
const { sortedAcl } = this.state;
9391

9492
return <form onSubmit={this.save}>

browser/components/projects/render/AttributionDocBuilder.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class AttributionDocBuilder extends Component<Props, State> {
3737
};
3838
componentWillMount() {
3939
const { dispatch, project: { projectId } } = this.props;
40-
const activeProjectId = this.props.project.projectId;
4140
dispatch(ProjectActions.buildAttributionDoc(projectId));
4241
}
4342

@@ -82,7 +81,7 @@ class AttributionDocBuilder extends Component<Props, State> {
8281
}
8382

8483
render() {
85-
const { attributionDoc: { lines, warnings }, project: { title, version, projectId } } = this.props;
84+
const { attributionDoc: { lines, warnings }, project: { title, version } } = this.props;
8685
const { highlights } = this.state;
8786

8887
return (

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"selenium-webdriver": "^3.0.1",
6666
"ts-loader": "^2.3.2",
6767
"tslint": "^5.5.0",
68+
"tslint-language-service": "^0.9.7",
6869
"typescript": "^2.6.2",
6970
"url-loader": "^0.5.9",
7071
"webpack": "^3.6.0",

selenium/landing.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* permissions and limitations under the License.
1313
*/
1414

15+
/* tslint:disable:no-floating-promises */
16+
1517
import { By, until } from 'selenium-webdriver';
1618
import build, { CustomDriver } from './driver';
1719

selenium/projects-auth.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* permissions and limitations under the License.
1313
*/
1414

15+
/* tslint:disable:no-floating-promises */
16+
1517
import {By, until} from 'selenium-webdriver';
1618
import build, { CustomDriver } from './driver';
1719

selenium/projects.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* permissions and limitations under the License.
1313
*/
1414

15+
/* tslint:disable:no-floating-promises */
16+
1517
import {By, Key, until} from 'selenium-webdriver';
1618
import build, { CustomDriver } from './driver';
1719

server/api/packages/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export async function storePackage(req: any, packageId: number, info: Pick<WebPa
136136
export async function verifyPackage(req: any, packageId: number, verified: boolean,
137137
comments: string): Promise<Partial<WebPackage>> {
138138
const user = auth.extractRequestUser(req);
139-
assertCanValidate(req);
139+
await assertCanValidate(req);
140140
await Promise.all([
141141
db.addVerification(packageId, user, comments),
142142
db.verifyPackage(packageId, verified),
@@ -146,7 +146,7 @@ export async function verifyPackage(req: any, packageId: number, verified: boole
146146
}
147147

148148
export async function getVerificationQueue(req: any): Promise<{queue: Array<Partial<WebPackage>>}> {
149-
assertCanValidate(req);
149+
await assertCanValidate(req);
150150
const results = await db.getUnverifiedPackages(25);
151151
const queue = results.map((item) => ({
152152
packageId: item.package_id,

server/api/projects/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export async function generateAttributionDocument(req: Request, projectId: strin
233233

234234
// save a copy if requested
235235
if (store) {
236-
documentdb.storeAttributionDocument(projectId, project.version, text, user);
236+
await documentdb.storeAttributionDocument(projectId, project.version, text, user);
237237
winston.info(`Document for project ${projectId} was stored by ${user}`);
238238
return {text};
239239
}

server/api/routes.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,113 +48,113 @@ function pack(promise: Promise<any>, res: any | undefined, next: any | undefined
4848
}
4949

5050
/*** User/session/general info ***/
51-
router.get('/info', (req, res, next) => {
52-
pack(userInfo(req), res, next);
51+
router.get('/info', async (req, res, next) => {
52+
await pack(userInfo(req), res, next);
5353
});
5454

5555
/*** Projects ***/
5656

5757
/**
5858
* List all projects filtered by access.
5959
*/
60-
router.get('/projects', (req, res, next) => {
61-
pack(projectAPI.searchProjects(req), res, next);
60+
router.get('/projects', async (req, res, next) => {
61+
await pack(projectAPI.searchProjects(req), res, next);
6262
});
6363

6464
/**
6565
* Create a new project.
6666
*/
67-
router.post('/projects/new', projectValidators.createProject, (req, res, next) => {
68-
pack(projectAPI.createProject(req, req.body), res, next);
67+
router.post('/projects/new', projectValidators.createProject, async (req, res, next) => {
68+
await pack(projectAPI.createProject(req, req.body), res, next);
6969
});
7070

7171
/**
7272
* Get a particular project.
7373
*/
74-
router.get('/projects/:projectId', (req, res, next) => {
75-
pack(projectAPI.getProject(req, req.params.projectId), res, next);
74+
router.get('/projects/:projectId', async (req, res, next) => {
75+
await pack(projectAPI.getProject(req, req.params.projectId), res, next);
7676
});
7777

7878
/**
7979
* Edit a project's basic details.
8080
*/
81-
router.patch('/projects/:projectId', projectValidators.patchProject, (req, res, next) => {
82-
pack(projectAPI.patchProject(req, req.params.projectId, req.body), res, next);
81+
router.patch('/projects/:projectId', projectValidators.patchProject, async (req, res, next) => {
82+
await pack(projectAPI.patchProject(req, req.params.projectId, req.body), res, next);
8383
});
8484

8585
/**
8686
* Attach a package to a project, optionally creating or updating the package.
8787
*/
88-
router.post('/projects/:projectId/attach', projectValidators.attachPackage, (req, res, next) => {
89-
pack(projectAPI.attachPackage(req, req.params.projectId, req.body), res, next);
88+
router.post('/projects/:projectId/attach', projectValidators.attachPackage, async (req, res, next) => {
89+
await pack(projectAPI.attachPackage(req, req.params.projectId, req.body), res, next);
9090
});
9191

9292
/**
9393
* Detach a package from a project.
9494
*/
95-
router.post('/projects/:projectId/detach', (req, res, next) => {
96-
pack(projectAPI.detachPackage(req, req.params.projectId, req.body.packageId), res, next);
95+
router.post('/projects/:projectId/detach', async (req, res, next) => {
96+
await pack(projectAPI.detachPackage(req, req.params.projectId, req.body.packageId), res, next);
9797
});
9898

9999
/**
100100
* Replace a package instance with another, without changing the usage.
101101
*/
102-
router.post('/projects/:projectId/replace', projectValidators.replacePackage, (req, res, next) => {
103-
pack(projectAPI.replacePackage(req, req.params.projectId, req.body.oldId, req.body.newId), res, next);
102+
router.post('/projects/:projectId/replace', projectValidators.replacePackage, async (req, res, next) => {
103+
await pack(projectAPI.replacePackage(req, req.params.projectId, req.body.oldId, req.body.newId), res, next);
104104
});
105105

106106
/**
107107
* Build an attribution document. Return the document along
108108
* with any warnings.
109109
*/
110-
router.get('/projects/:projectId/build', (req, res, next) => {
111-
pack(projectAPI.generateAttributionDocument(req, req.params.projectId), res, next);
110+
router.get('/projects/:projectId/build', async (req, res, next) => {
111+
await pack(projectAPI.generateAttributionDocument(req, req.params.projectId), res, next);
112112
});
113113

114114
/**
115115
* Building a document using POST will trigger a store & download.
116116
*/
117-
router.post('/projects/:projectId/build', (req, res, next) => {
118-
pack(projectAPI.generateAttributionDocument(req, req.params.projectId, true), res, next);
117+
router.post('/projects/:projectId/build', async (req, res, next) => {
118+
await pack(projectAPI.generateAttributionDocument(req, req.params.projectId, true), res, next);
119119
});
120120

121121
/*** Packages ***/
122122

123123
/**
124124
* Search all packages by name/version.
125125
*/
126-
router.post('/packages/', (req, res, next) => {
127-
pack(packageAPI.searchPackages(req, req.body.query), res, next);
126+
router.post('/packages/', async (req, res, next) => {
127+
await pack(packageAPI.searchPackages(req, req.body.query), res, next);
128128
});
129129

130130
/**
131131
* Admin action: fetch the package verification queue.
132132
*/
133-
router.get('/packages/verification', (req, res, next) => {
134-
pack(packageAPI.getVerificationQueue(req), res, next);
133+
router.get('/packages/verification', async (req, res, next) => {
134+
await pack(packageAPI.getVerificationQueue(req), res, next);
135135
});
136136

137137
/**
138138
* Get a single package.
139139
*/
140-
router.get('/packages/:packageId', (req, res, next) => {
141-
pack(packageAPI.getPackage(req, req.params.packageId, req.query.extended != null), res, next);
140+
router.get('/packages/:packageId', async (req, res, next) => {
141+
await pack(packageAPI.getPackage(req, req.params.packageId, req.query.extended != null), res, next);
142142
});
143143

144144
/**
145145
* Verify (accept/reject with comments) a single package.
146146
*/
147-
router.post('/packages/:packageId/verify', (req, res, next) => {
148-
pack(packageAPI.verifyPackage(req, req.params.packageId, req.body.verified, req.body.comments), res, next);
147+
router.post('/packages/:packageId/verify', async (req, res, next) => {
148+
await pack(packageAPI.verifyPackage(req, req.params.packageId, req.body.verified, req.body.comments), res, next);
149149
});
150150

151151
/*** Licenses ***/
152152

153153
/**
154154
* Retrieve all license and tag data.
155155
*/
156-
router.get('/licenses/', (req, res, next) => {
157-
pack(licenseAPI.listLicenses(), res, next);
156+
router.get('/licenses/', async (req, res, next) => {
157+
await pack(licenseAPI.listLicenses(), res, next);
158158
});
159159

160160
// error handling for all of the above

0 commit comments

Comments
 (0)