Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update server-admin to ESLint 7 #3792

Merged
merged 1 commit into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions server/admin/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

module.exports = {
"extends": [
"@fluidframework/eslint-config-fluid"
"@fluidframework/eslint-config-fluid/eslint7"
],
"rules": {
"@typescript-eslint/strict-boolean-expressions": "off", // requires strictNullChecks=true in tsconfig
}
}
}
1,214 changes: 1,112 additions & 102 deletions server/admin/package-lock.json

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions server/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"clean": "rimraf dist *.tsbuildinfo *.build.log",
"docker:build": "docker build -t admin .",
"docker:start": "docker run --rm -t --network routerlicious_default -p 7000:3000 admin",
"eslint": "eslint --ext=ts,tsx --format stylish src",
"eslint": "eslint --format stylish src",
"eslint:fix": "eslint --ext=ts,tsx --format stylish src --fix",
"less": "lessc src/stylesheets/style.less public/stylesheets/dist/style.css",
"lint": "npm run eslint",
Expand Down Expand Up @@ -75,7 +75,7 @@
"winston": "^2.4.0"
},
"devDependencies": {
"@fluidframework/eslint-config-fluid": "^0.19.1",
"@fluidframework/eslint-config-fluid": "^0.20.0-0",
"@types/compression": "0.0.35",
"@types/connect-ensure-login": "^0.1.4",
"@types/connect-redis": "0.0.7",
Expand All @@ -98,18 +98,17 @@
"@types/serve-favicon": "^2.2.28",
"@types/split": "^0.3.28",
"@types/winston": "^2.3.7",
"@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",
"concurrently": "^3.5.1",
"css-loader": "^3.0.0",
"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",
"less": "~3.9.0",
"rimraf": "^2.6.2",
"source-map-loader": "^0.2.3",
Expand Down
12 changes: 3 additions & 9 deletions server/admin/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import * as compression from "compression";
import * as connectRedis from "connect-redis";
import * as cookieParser from "cookie-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 expressSession from "express-session";
import * as morgan from "morgan";
Expand Down Expand Up @@ -101,14 +100,12 @@ export function create(config: Provider, mongoManager: core.MongoManager) {

// Create a redis session store.
let sessionStore: any;
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (config.get("login:enabled")) {
const redisStore = connectRedis(expressSession);
const redisHost = config.get("redis:host");
const redisPort = config.get("redis:port");
const redisPass = config.get("redis:pass");
const options: redis.ClientOpts = { auth_pass: redisPass };
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const options: redis.ClientOpts = { auth_pass: redisPass };
if (config.get("redis:tls")) {
options.tls = {
servername: redisHost,
Expand All @@ -135,7 +132,7 @@ export function create(config: Provider, mongoManager: core.MongoManager) {
tokenURL: "https://login.microsoftonline.com/organizations/oauth2/v2.0/token",
},
(req, iss, sub, profile, jwtClaims, accessToken, refreshToken, params, done) => {
// eslint-disable-next-line no-null/no-null
// eslint-disable-next-line no-null/no-null,@typescript-eslint/no-unsafe-return
return done(null, jwtClaims);
},
),
Expand Down Expand Up @@ -194,7 +191,6 @@ export function create(config: Provider, mongoManager: core.MongoManager) {
// The below is to check to make sure the session is available (redis could have gone down for instance) and if
// not return an error
app.use((request, response, next) => {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (!request.session) {
return next(new Error("Session not available"));
} else {
Expand All @@ -219,7 +215,6 @@ export function create(config: Provider, mongoManager: core.MongoManager) {
// 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.render("error", {
error: err,
Expand All @@ -231,7 +226,6 @@ export function create(config: Provider, mongoManager: core.MongoManager) {
// 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.render("error", {
error: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class CreateKeyValueModal extends React.Component<IKeyValueCreateProps> {

public render() {
const { confirmLoading, visible, onCancel, onCreate, form } = this.props;
// eslint-disable-next-line @typescript-eslint/unbound-method
const { getFieldDecorator } = form;
return (
<Modal
Expand Down
4 changes: 0 additions & 4 deletions server/admin/src/controllers/components/KeyValueManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ class EditableCell extends React.Component<ICellProps<IKeyValue>, ICellState> {
dataIndex,
title,
record,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
index,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
handleEdit,
...restProps
} = this.props;
Expand Down Expand Up @@ -124,7 +122,6 @@ class EditableCell extends React.Component<ICellProps<IKeyValue>, ICellState> {
private readonly toggle = (e) => {
const { record, handleEdit } = this.props;
this.form.validateFields((error, values) => {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (error && error[e.currentTarget.id]) {
return;
}
Expand Down Expand Up @@ -268,7 +265,6 @@ export class KeyValueManager extends React.Component<ITableProps, ITableState> {
private readonly handleAdd = () => {
const form = this.form;
form.validateFields((err, newKeyValue: IKeyValue) => {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (err) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export class CreateTenantModal extends React.Component<ITenantCreateProps, ITena

public render() {
const { confirmLoading, visible, onCancel, onCreate, form } = this.props;
// eslint-disable-next-line @typescript-eslint/unbound-method
const { getFieldDecorator } = form;
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
return (
<Modal
visible={visible}
Expand Down Expand Up @@ -126,7 +126,6 @@ export class CreateTenantModal extends React.Component<ITenantCreateProps, ITena
</Form>
</Modal>
);
/* eslint-enable @typescript-eslint/strict-boolean-expressions */
}

private onStorageInputChange(e) {
Expand Down
2 changes: 0 additions & 2 deletions server/admin/src/controllers/components/TenantInfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ export class TenantInfoModal extends React.Component<ITenantInfoProps> {

public render() {
const { visible, record, onOk } = this.props;
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
const name = !record ? "" : record.name;
const id = !record ? "" : record.id;
const key = !record ? "" : record.key;
const orderer = !record ? "" : record.orderer.url;
const storage = !record ? "" : record.historianUrl;
/* eslint-enable @typescript-eslint/strict-boolean-expressions */

return (
<div>
Expand Down
1 change: 0 additions & 1 deletion server/admin/src/controllers/components/TenantManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export class TenantManager extends React.Component<ITableProps, ITableState > {
console.log("Begin create");
const form = this.form;
form.validateFields((err, tenant) => {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (err) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions server/admin/src/controllers/utils/keyValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export async function addKeyValue(url: string, keyValueToAdd: IKeyValue): Promis
},
json: true,
});
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return newKeyValue;
}

Expand Down
1 change: 1 addition & 0 deletions server/admin/src/controllers/utils/tenants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export async function addTenant(url: string, tenant: ITenantInput): Promise<any>
},
json: true,
});
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return newTenant;
}

Expand Down
1 change: 0 additions & 1 deletion server/admin/src/routes/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function create(
* Creates a new tenant
*/
router.post("/tenants", ensureLoggedIn(), (request, response) => {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const oid = request.user ? request.user.oid : "local";
const tenantInput = request.body as ITenantInput;
const tenantP = tenantManager.addTenant(oid, tenantInput);
Expand Down
2 changes: 0 additions & 2 deletions server/admin/src/routes/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ export function create(
* Route to retrieve the home page for the app
*/
router.get("/", ensureLoggedIn(), (request, response, next) => {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const oid = request.user ? request.user.oid : "local";
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const user = request.user ? request.user : { displayName: "local" };
const tenantsP = tenantManager.getTenantsforUser(oid);
// Return empty result if the key-value document was not loaded properly.
Expand Down
2 changes: 1 addition & 1 deletion server/admin/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export function create(
config: Provider,
mongoManager: core.MongoManager,
tenantManager: TenantManager): IRoutes {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const ensureLoggedIn = config.get("login:enabled")
? ensureAuth.ensureLoggedIn
: () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return (req, res, next) => next();
};

Expand Down
3 changes: 1 addition & 2 deletions server/admin/src/runnerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export class AdminResourcesFactory implements utils.IResourcesFactory<AdminResou
const mongoFactory = new services.MongoDbFactory(mongoUrl);
const mongoManager = new core.MongoManager(mongoFactory);

// This wanst to create stuff
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
// This wants to create stuff
const port = utils.normalizePort(process.env.PORT || "3000");

return new AdminResources(
Expand Down
2 changes: 1 addition & 1 deletion server/admin/src/tenantManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ export class TenantManager {
}

private getProviderForEndpoint(url: string) {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (!url) {
return "Unknown";
}
Expand All @@ -232,6 +231,7 @@ export class TenantManager {
_id: userId,
orgIds: [orgId],
});
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return orgId;
}

Expand Down
2 changes: 1 addition & 1 deletion server/admin/src/webServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class HttpServer implements core.IHttpServer {
}

public async close(): Promise<void> {
// tslint:disable-next-line
// eslint-disable-next-line @typescript-eslint/ban-types
await util.promisify(((callback) => this.server.close(callback)) as Function)();
}

Expand Down