Skip to content

Commit

Permalink
Update server-gitrest to ESLint 7 (#3794)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerbutler committed Oct 2, 2020
1 parent f156440 commit b12c903
Show file tree
Hide file tree
Showing 10 changed files with 1,073 additions and 275 deletions.
7 changes: 4 additions & 3 deletions server/gitrest/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

module.exports = {
"extends": [
"@fluidframework/eslint-config-fluid"
"@fluidframework/eslint-config-fluid/eslint7"
],
"rules": {
"prefer-arrow/prefer-arrow-functions": "off"
"@typescript-eslint/strict-boolean-expressions": "off", // requires strictNullChecks=true in tsconfig
"prefer-arrow/prefer-arrow-functions": "off",
}
}
}
1,299 changes: 1,053 additions & 246 deletions server/gitrest/package-lock.json

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions server/gitrest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build": "concurrently npm:build:compile npm:lint",
"build:compile": "npm run tsc",
"clean": "rimraf dist *.tsbuildinfo *.build.log",
"eslint": "eslint --ext=ts,tsx --format stylish src",
"eslint": "eslint --format stylish src",
"eslint:fix": "eslint --ext=ts,tsx --format stylish src --fix",
"lint": "npm run eslint",
"lint:fix": "npm run eslint:fix",
Expand All @@ -34,7 +34,7 @@
"winston": "^2.4.4"
},
"devDependencies": {
"@fluidframework/eslint-config-fluid": "^0.19.1",
"@fluidframework/eslint-config-fluid": "^0.20.0-0",
"@types/async": "^2.0.50",
"@types/cors": "^2.8.4",
"@types/debug": "^4.1.5",
Expand All @@ -47,18 +47,17 @@
"@types/rimraf": "^2.0.2",
"@types/supertest": "^2.0.7",
"@types/winston": "^2.4.4",
"@typescript-eslint/eslint-plugin": "~2.17.0",
"@typescript-eslint/parser": "~2.17.0",
"@typescript-eslint/eslint-plugin": "~4.2.0",
"@typescript-eslint/parser": "~4.2.0",
"async": "^2.5.0",
"concurrently": "^3.5.1",
"eslint": "~6.8.0",
"eslint-plugin-eslint-comments": "~3.1.2",
"eslint-plugin-import": "2.20.0",
"eslint": "~7.9.0",
"eslint-plugin-eslint-comments": "~3.2.0",
"eslint-plugin-import": "~2.22.0",
"eslint-plugin-no-null": "~1.0.2",
"eslint-plugin-optimize-regex": "~1.1.7",
"eslint-plugin-prefer-arrow": "~1.1.7",
"eslint-plugin-react": "~7.18.0",
"eslint-plugin-unicorn": "~15.0.1",
"eslint-plugin-prefer-arrow": "~1.2.2",
"eslint-plugin-react": "~7.21.2",
"eslint-plugin-unicorn": "~22.0.0",
"lorem-ipsum": "^1.0.6",
"mocha": "^8.1.1",
"moniker": "^0.1.2",
Expand Down
5 changes: 1 addition & 4 deletions server/gitrest/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import * as bodyParser from "body-parser";
import * as cors from "cors";
// eslint-disable-next-line import/no-duplicates
import * as express from "express";
// eslint-disable-next-line no-duplicate-imports, import/no-duplicates
// eslint-disable-next-line no-duplicate-imports
import { Express } from "express";
import * as morgan from "morgan";
import * as nconf from "nconf";
Expand Down Expand Up @@ -59,7 +58,6 @@ export function create(store: nconf.Provider) {
// will print stacktrace
if (app.get("env") === "development") {
app.use((err, req, res, next) => {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
res.status(err.status || 500);
res.json({
error: err,
Expand All @@ -71,7 +69,6 @@ export function create(store: nconf.Provider) {
// production error handler
// no stacktraces leaked to user
app.use((err, req, res, next) => {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
res.status(err.status || 500);
res.json({
error: {},
Expand Down
5 changes: 2 additions & 3 deletions server/gitrest/src/routes/git/blobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ export async function createBlob(
owner: string,
repo: string,
blob: ICreateBlobParams): Promise<ICreateBlobResponse> {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (!blob || !validateBlob(blob.content) || !validateEncoding(blob.encoding)) {
return Promise.reject("Invalid blob");
if (!blob || !validateBlob(blob.content) || !validateEncoding(blob.encoding)) {
return Promise.reject("Invalid blob");
}

const repository = await repoManager.open(owner, repo);
Expand Down
3 changes: 1 addition & 2 deletions server/gitrest/src/routes/git/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function createCommit(

const repository = await repoManager.open(owner, repo);
const signature = git.Signature.create(blob.author.name, blob.author.email, Math.floor(date), 0);
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions, no-null/no-null
// eslint-disable-next-line no-null/no-null
const parents = blob.parents && blob.parents.length > 0 ? blob.parents : null;
// eslint-disable-next-line no-null/no-null
const commit = await repository.createCommit(null, signature, signature, blob.message, blob.tree, parents);
Expand All @@ -30,7 +30,6 @@ export async function createCommit(
author: blob.author,
committer: blob.author,
message: blob.message,
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
parents: parents ? blob.parents.map((parent) => ({ sha: parent, url: "" })) : [],
sha: commit.tostrS(),
tree: {
Expand Down
1 change: 0 additions & 1 deletion server/gitrest/src/routes/git/repos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export function create(store: nconf.Provider, repoManager: utils.RepositoryManag
*/
router.post("/:owner/repos", (request, response, next) => {
const createParams = request.body as ICreateRepoParams;
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (!createParams || !createParams.name) {
return response.status(400).json("Invalid repo name");
}
Expand Down
2 changes: 0 additions & 2 deletions server/gitrest/src/test/routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ describe("GitRest", () => {
const tree = await createTreeInternal(manager, testOwnerName, testRepoName, createTreeParams);

const parents: string[] = [];
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (lastCommit) {
const commits = await getCommits(manager, testOwnerName, testRepoName, lastCommit, 1);
const parentCommit = commits[0];
Expand Down Expand Up @@ -454,7 +453,6 @@ describe("GitRest", () => {
resolve();
};

// eslint-disable-next-line @typescript-eslint/unbound-method
queue.error = (error) => {
reject(error);
};
Expand Down
1 change: 0 additions & 1 deletion server/gitrest/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export async function commitToICommit(commit: git.Commit): Promise<resources.ICo
author: authorToIAuthor(commit.author(), commit.date()),
committer: committerToICommitter(commit.committer(), commit.date()),
message: commit.message(),
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
parents: commit.parents() && commit.parents().length > 0 ?
// eslint-disable-next-line no-null/no-null
commit.parents().map((parent) => oidToCommitHash(parent)) : null,
Expand Down
4 changes: 2 additions & 2 deletions server/gitrest/src/www.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function normalizePort(val) {
const normalizedPort = parseInt(val, 10);

if (isNaN(normalizedPort)) {
// named pipe
// named pipe
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return val;
}

Expand Down Expand Up @@ -59,7 +60,6 @@ winston.configure({
/**
* Get port from environment and store in Express.
*/
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const port = normalizePort(process.env.PORT || "3000");
const historian = app.create(provider);
historian.set("port", port);
Expand Down

0 comments on commit b12c903

Please sign in to comment.