Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 16fb0fb

Browse files
ESLint: enable more checks (#713)
1 parent 99aed6f commit 16fb0fb

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

.eslintrc.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ rules:
171171
no-loss-of-precision: error
172172
no-misleading-character-class: error
173173
no-obj-calls: error
174-
no-promise-executor-return: off # TODO
174+
no-promise-executor-return: error
175175
no-prototype-builtins: error
176176
no-regex-spaces: error
177177
no-setter-return: error
@@ -256,7 +256,7 @@ rules:
256256
no-void: error
257257
no-warning-comments: off
258258
no-with: error
259-
prefer-named-capture-group: off # ES2018
259+
prefer-named-capture-group: error
260260
prefer-promise-reject-errors: error
261261
prefer-regex-literals: error
262262
radix: error
@@ -322,7 +322,7 @@ rules:
322322
no-restricted-syntax: off
323323
no-tabs: error
324324
no-ternary: off
325-
no-underscore-dangle: off # TODO
325+
no-underscore-dangle: error
326326
no-unneeded-ternary: error
327327
one-var: [error, never]
328328
operator-assignment: error
@@ -503,9 +503,9 @@ overrides:
503503
'@typescript-eslint/no-var-requires': error
504504
'@typescript-eslint/prefer-as-const': off # TODO consider
505505
'@typescript-eslint/prefer-enum-initializers': off # TODO consider
506-
'@typescript-eslint/prefer-for-of': off # TODO switch to error after TS migration
506+
'@typescript-eslint/prefer-for-of': error
507507
'@typescript-eslint/prefer-function-type': error
508-
'@typescript-eslint/prefer-includes': off # TODO switch to error after IE11 drop
508+
'@typescript-eslint/prefer-includes': error
509509
'@typescript-eslint/prefer-literal-enum-member': error
510510
'@typescript-eslint/prefer-namespace-keyword': error
511511
'@typescript-eslint/prefer-nullish-coalescing': error
@@ -515,13 +515,13 @@ overrides:
515515
'@typescript-eslint/prefer-reduce-type-parameter': error
516516
'@typescript-eslint/prefer-regexp-exec': error
517517
'@typescript-eslint/prefer-ts-expect-error': error
518-
'@typescript-eslint/prefer-string-starts-ends-with': off # TODO switch to error after IE11 drop
518+
'@typescript-eslint/prefer-string-starts-ends-with': error
519519
'@typescript-eslint/promise-function-async': off
520520
'@typescript-eslint/require-array-sort-compare': error
521521
'@typescript-eslint/restrict-plus-operands':
522522
[error, { checkCompoundAssignments: true }]
523523
'@typescript-eslint/restrict-template-expressions': error
524-
'@typescript-eslint/strict-boolean-expressions': off # TODO consider
524+
'@typescript-eslint/strict-boolean-expressions': error
525525
'@typescript-eslint/switch-exhaustiveness-check': error
526526
'@typescript-eslint/triple-slash-reference': error
527527
'@typescript-eslint/typedef': off

resources/build-npm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ function buildPackageJSON() {
5252
delete packageJSON.devDependencies;
5353

5454
const { version } = packageJSON;
55-
const versionMatch = /^\d+\.\d+\.\d+-?(.*)?$/.exec(version);
55+
const versionMatch = /^\d+\.\d+\.\d+-?(?<preReleaseTag>.*)?$/.exec(version);
5656
if (!versionMatch) {
5757
throw new Error('Version does not match semver spec: ' + version);
5858
}
5959

60-
const [, preReleaseTag] = versionMatch;
60+
const { preReleaseTag } = versionMatch.groups;
6161

6262
if (preReleaseTag != null) {
6363
const [tag] = preReleaseTag.split('.');

resources/gen-changelog.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ if (!packageJSON.repository || typeof packageJSON.repository.url !== 'string') {
4747
process.exit(1);
4848
}
4949

50-
const repoURLMatch = /https:\/\/github.com\/([^/]+)\/([^/]+).git/.exec(
50+
const repoURLMatch = /https:\/\/github.com\/(?<githubOrg>[^/]+)\/(?<githubRepo>[^/]+).git/.exec(
5151
packageJSON.repository.url,
5252
);
5353
if (repoURLMatch == null) {
5454
console.error('Cannot extract organization and repo name from repo URL!');
5555
process.exit(1);
5656
}
57-
const [, githubOrg, githubRepo] = repoURLMatch;
57+
const { githubOrg, githubRepo } = repoURLMatch.groups;
5858

5959
getChangeLog()
6060
.then((changelog) => process.stdout.write(changelog))
@@ -275,9 +275,9 @@ function commitsInfoToPRs(commits) {
275275
(pr) => pr.repository.nameWithOwner === `${githubOrg}/${githubRepo}`,
276276
);
277277
if (associatedPRs.length === 0) {
278-
const match = / \(#([0-9]+)\)$/m.exec(commit.message);
278+
const match = / \(#(?<prNumber>[0-9]+)\)$/m.exec(commit.message);
279279
if (match) {
280-
prs[parseInt(match[1], 10)] = true;
280+
prs[parseInt(match.groups.prNumber, 10)] = true;
281281
continue;
282282
}
283283
throw new Error(

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ type Middleware = (request: Request, response: Response) => Promise<void>;
186186
* configure behavior, and returns an express middleware.
187187
*/
188188
export function graphqlHTTP(options: Options): Middleware {
189-
if (!options) {
189+
if (options == null) {
190190
throw new Error('GraphQL middleware requires options.');
191191
}
192192

src/parseBody.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async function readBody(
8383
const charset = typeInfo.parameters.charset?.toLowerCase() ?? 'utf-8';
8484

8585
// Assert charset encoding per JSON RFC 7159 sec 8.1
86-
if (charset.slice(0, 4) !== 'utf-') {
86+
if (!charset.startsWith('utf-')) {
8787
throw httpError(415, `Unsupported charset "${charset.toUpperCase()}".`);
8888
}
8989

0 commit comments

Comments
 (0)