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

Commit

Permalink
ESLint: enable more checks (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Nov 5, 2020
1 parent 99aed6f commit 16fb0fb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ rules:
no-loss-of-precision: error
no-misleading-character-class: error
no-obj-calls: error
no-promise-executor-return: off # TODO
no-promise-executor-return: error
no-prototype-builtins: error
no-regex-spaces: error
no-setter-return: error
Expand Down Expand Up @@ -256,7 +256,7 @@ rules:
no-void: error
no-warning-comments: off
no-with: error
prefer-named-capture-group: off # ES2018
prefer-named-capture-group: error
prefer-promise-reject-errors: error
prefer-regex-literals: error
radix: error
Expand Down Expand Up @@ -322,7 +322,7 @@ rules:
no-restricted-syntax: off
no-tabs: error
no-ternary: off
no-underscore-dangle: off # TODO
no-underscore-dangle: error
no-unneeded-ternary: error
one-var: [error, never]
operator-assignment: error
Expand Down Expand Up @@ -503,9 +503,9 @@ overrides:
'@typescript-eslint/no-var-requires': error
'@typescript-eslint/prefer-as-const': off # TODO consider
'@typescript-eslint/prefer-enum-initializers': off # TODO consider
'@typescript-eslint/prefer-for-of': off # TODO switch to error after TS migration
'@typescript-eslint/prefer-for-of': error
'@typescript-eslint/prefer-function-type': error
'@typescript-eslint/prefer-includes': off # TODO switch to error after IE11 drop
'@typescript-eslint/prefer-includes': error
'@typescript-eslint/prefer-literal-enum-member': error
'@typescript-eslint/prefer-namespace-keyword': error
'@typescript-eslint/prefer-nullish-coalescing': error
Expand All @@ -515,13 +515,13 @@ overrides:
'@typescript-eslint/prefer-reduce-type-parameter': error
'@typescript-eslint/prefer-regexp-exec': error
'@typescript-eslint/prefer-ts-expect-error': error
'@typescript-eslint/prefer-string-starts-ends-with': off # TODO switch to error after IE11 drop
'@typescript-eslint/prefer-string-starts-ends-with': error
'@typescript-eslint/promise-function-async': off
'@typescript-eslint/require-array-sort-compare': error
'@typescript-eslint/restrict-plus-operands':
[error, { checkCompoundAssignments: true }]
'@typescript-eslint/restrict-template-expressions': error
'@typescript-eslint/strict-boolean-expressions': off # TODO consider
'@typescript-eslint/strict-boolean-expressions': error
'@typescript-eslint/switch-exhaustiveness-check': error
'@typescript-eslint/triple-slash-reference': error
'@typescript-eslint/typedef': off
Expand Down
4 changes: 2 additions & 2 deletions resources/build-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ function buildPackageJSON() {
delete packageJSON.devDependencies;

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

const [, preReleaseTag] = versionMatch;
const { preReleaseTag } = versionMatch.groups;

if (preReleaseTag != null) {
const [tag] = preReleaseTag.split('.');
Expand Down
8 changes: 4 additions & 4 deletions resources/gen-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ if (!packageJSON.repository || typeof packageJSON.repository.url !== 'string') {
process.exit(1);
}

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

getChangeLog()
.then((changelog) => process.stdout.write(changelog))
Expand Down Expand Up @@ -275,9 +275,9 @@ function commitsInfoToPRs(commits) {
(pr) => pr.repository.nameWithOwner === `${githubOrg}/${githubRepo}`,
);
if (associatedPRs.length === 0) {
const match = / \(#([0-9]+)\)$/m.exec(commit.message);
const match = / \(#(?<prNumber>[0-9]+)\)$/m.exec(commit.message);
if (match) {
prs[parseInt(match[1], 10)] = true;
prs[parseInt(match.groups.prNumber, 10)] = true;
continue;
}
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ type Middleware = (request: Request, response: Response) => Promise<void>;
* configure behavior, and returns an express middleware.
*/
export function graphqlHTTP(options: Options): Middleware {
if (!options) {
if (options == null) {
throw new Error('GraphQL middleware requires options.');
}

Expand Down
2 changes: 1 addition & 1 deletion src/parseBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async function readBody(
const charset = typeInfo.parameters.charset?.toLowerCase() ?? 'utf-8';

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

Expand Down

0 comments on commit 16fb0fb

Please sign in to comment.