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

[#IC-501] migrated tslint to eslint #110

Merged
merged 4 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
"env": {
"browser": true,
BurnedMarshal marked this conversation as resolved.
Show resolved Hide resolved
"es6": true,
"node": true
},
"ignorePatterns": [
"node_modules",
"generated",
"**/__tests__/*",
"**/__mocks__/*",
"Dangerfile.*",
BurnedMarshal marked this conversation as resolved.
Show resolved Hide resolved
"*.d.ts"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"extends": [
"@pagopa/eslint-config/strong",
],
"rules": {

}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ coverage
*.pem
.npmrc
.DS_Store

# eslint section
!.eslintrc.js
.eslintcache
1 change: 0 additions & 1 deletion Dangerfile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// import custom DangerJS rules
// see http://danger.systems/js
// see https://github.com/teamdigitale/danger-plugin-digitalcitizenship/
// tslint:disable-next-line:prettier
BurnedMarshal marked this conversation as resolved.
Show resolved Hide resolved
import checkDangers from 'danger-plugin-digitalcitizenship';

checkDangers();
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"hot-reload": "nodemon --legacy-watch --watch ./dist --inspect=0.0.0.0 --nolazy dist/example.js",
"postversion": "git push && git push --tags",
"test": "jest -i",
"lint": "tslint --project .",
"lint": "eslint . -c .eslintrc.js --ext .ts,.tsx",
"preversion": "auto-changelog --config .auto-changelog.json --unreleased --commit-limit false --stdout --template preview.hbs",
"version": "auto-changelog -p --config .auto-changelog.json --unreleased && git add CHANGELOG.md"
},
"devDependencies": {
"@pagopa/eslint-config": "^1.3.1",
"@types/express": "4.17.0",
"@types/jest": "^24.0.13",
"@types/node": "10.14.1",
Expand All @@ -41,8 +42,8 @@
"auto-changelog": "^2.2.1",
"danger": "^7.0.0",
"danger-plugin-digitalcitizenship": "*",
"eslint-plugin-prettier": "^3.0.0",
"express": "4.17.0",
"italia-tslint-rules": "*",
"jest": "^24.8.0",
"mock-redis-client": "^0.91.13",
"nock": "^11.7.1",
Expand All @@ -52,7 +53,6 @@
"shx": "^0.3.2",
"supertest": "^4.0.2",
"ts-jest": "^24.0.2",
"tslint": "^5.1.0",
"typescript": "^3.7.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/__mocks__/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IDPEntityDescriptor } from "../types/IDPEntityDescriptor";

import { NonEmptyArray } from "fp-ts/lib/NonEmptyArray";

// tslint:disable-next-line: no-submodule-imports
// eslint-disable-next-line import/no-internal-modules
BurnedMarshal marked this conversation as resolved.
Show resolved Hide resolved
import { NonEmptyString } from "@pagopa/ts-commons/lib/strings";

export const mockIdpMetadata: Record<string, IDPEntityDescriptor> = {
Expand Down
2 changes: 1 addition & 1 deletion src/__mocks__/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:no-any
// eslint-disable @typescript-eslint/no-explicit-any
BurnedMarshal marked this conversation as resolved.
Show resolved Hide resolved

/**
* mockReq
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable-next-line: no-submodule-imports
// eslint-disable-next-line import/no-internal-modules
BurnedMarshal marked this conversation as resolved.
Show resolved Hide resolved
import { ResponsePermanentRedirect } from "@pagopa/ts-commons/lib/responses";
import * as express from "express";
import { left, right } from "fp-ts/lib/Either";
Expand Down Expand Up @@ -141,7 +141,7 @@ const serviceProviderConfig: IServiceProviderConfig = {
}
};

// tslint:disable-next-line: no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mockRedisClient: RedisClient = (createMockRedis() as any).createClient();

function initMockFetchIDPMetadata(): void {
Expand Down Expand Up @@ -174,7 +174,7 @@ describe("io-spid-commons withSpid", () => {
appConfig,
samlConfig,
serviceProviderConfig,
// tslint:disable-next-line: object-literal-sort-keys
// eslint-disable-next-line sort-keys
redisClient: mockRedisClient,
app,
acs: async () => ResponsePermanentRedirect({ href: "/success?acs" }),
Expand Down Expand Up @@ -217,7 +217,7 @@ describe("io-spid-commons withSpid", () => {
appConfig,
samlConfig,
serviceProviderConfig,
// tslint:disable-next-line: object-literal-sort-keys
// eslint-disable-next-line sort-keys
redisClient: mockRedisClient,
app,
acs: async () => ResponsePermanentRedirect({ href: "/success?acs" }),
Expand Down
21 changes: 12 additions & 9 deletions src/bin/startup-idps-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,37 @@ const argv = yargs
demandOption: false,
description: "ENV var name containing IDP Metadata URL",
normalize: true,
// eslint-disable-next-line id-blacklist
string: true
})
.option("testenv-metadata-url-env", {
demandOption: false,
description: "ENV var name containing TestEnv2 Metadata URL",
normalize: true,
// eslint-disable-next-line id-blacklist
string: true
})
.option("cie-metadata-url-env", {
demandOption: false,
description: "ENV var name containing CIE Metadata URL",
normalize: true,
// eslint-disable-next-line id-blacklist
string: true
})
.help().argv;

interface IIDPSMetadataXML {
idps?: string;
xx_testenv2?: string;
xx_servizicie?: string;
readonly idps?: string;
readonly xx_testenv2?: string;
readonly xx_servizicie?: string;
}

function printIdpsMetadata(
const printIdpsMetadata = (
idpsMetadataENV: string | undefined,
testEnv2MetadataENV: string | undefined,
cieMetadataENV: string | undefined
): Promise<IIDPSMetadataXML> {
// tslint:disable: no-object-mutation no-any no-empty
): Promise<IIDPSMetadataXML> => {
// eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-function
logger.info = (): any => {};
const maybeIdpsMetadataURL = pipe(
O.fromNullable(idpsMetadataENV),
Expand Down Expand Up @@ -89,16 +92,16 @@ function printIdpsMetadata(
maybeTestEnvMetadataURL,
maybeCIEMetadataURL
),
// tslint:disable-next-line: no-inferred-empty-object-type

T.map(A.reduce({}, (prev, current) => ({ ...prev, ...current })))
)();
}
};

printIdpsMetadata(
argv["idp-metadata-url-env"],
argv["testenv-metadata-url-env"],
argv["cie-metadata-url-env"]
)
// tslint:disable-next-line: no-console
// eslint-disable-next-line no-console
.then(metadata => console.log(JSON.stringify(metadata, null, 2)))
.catch(() => logger.error("Error fetching IDP metadata"));
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
export const SPID_IDP_IDENTIFIERS = {
"https://id.lepida.it/idp/shibboleth": "lepidaid",
"https://identity.infocert.it": "infocertid",
Expand Down
32 changes: 17 additions & 15 deletions src/example.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
// tslint:disable-next-line: no-submodule-imports
import * as fs from "fs";
import { ResponsePermanentRedirect } from "@pagopa/ts-commons/lib/responses";
import {
EmailString,
FiscalCode,
NonEmptyString
// tslint:disable-next-line: no-submodule-imports
} from "@pagopa/ts-commons/lib/strings";
import * as bodyParser from "body-parser";
import * as express from "express";
import { pipe } from "fp-ts/lib/function";
import * as T from "fp-ts/lib/Task";
import * as fs from "fs";
import * as t from "io-ts";
import passport = require("passport");
import { SamlConfig } from "passport-saml";
import * as redis from "redis";
import {
AssertionConsumerServiceT,
IApplicationConfig,
LogoutT,
withSpid
} from ".";
import { logger } from "./utils/logger";
import {
AggregatorType,
ContactType,
EntityType,
IServiceProviderConfig
} from "./utils/middleware";
import {
AssertionConsumerServiceT,
IApplicationConfig,
LogoutT,
withSpid
} from ".";

export const SpidUser = t.intersection([
t.interface({
// the following values may be set
// by the calling application:
// authnContextClassRef: SpidLevel,
// issuer: Issuer
// authnContextClassRef -> SpidLevel,
// issuer -> Issuer
BurnedMarshal marked this conversation as resolved.
Show resolved Hide resolved
getAssertionXml: t.Function
}),
t.partial({
Expand Down Expand Up @@ -87,10 +85,13 @@ const serviceProviderConfig: IServiceProviderConfig = {
// this line is commented due to a future refactor that enables spid-saml-check locally
// spidValidatorUrl: "http://localhost:8080",
strictResponseValidation: {
// eslint-disable-next-line @typescript-eslint/naming-convention
"http://localhost:8080": true,
// eslint-disable-next-line @typescript-eslint/naming-convention
"https://spid-testenv2:8088": true
},

// eslint-disable-next-line sort-keys
contacts: [
{
company: "Sogetto Aggregatore s.r.l",
Expand Down Expand Up @@ -147,12 +148,13 @@ proxyApp.get("*", (req, res) => {
});
proxyApp.listen(8080);

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const doneCb = (ip: string | null, request: string, response: string) => {
// tslint:disable-next-line: no-console
// eslint-disable-next-line no-console
console.log("*************** done", ip);
// tslint:disable-next-line: no-console
// eslint-disable-next-line no-console
console.log(request);
// tslint:disable-next-line: no-console
// eslint-disable-next-line no-console
console.log(response);
};

Expand Down Expand Up @@ -200,5 +202,5 @@ pipe(
withSpidApp.listen(3000);
})
)()
// tslint:disable-next-line: no-console
// eslint-disable-next-line no-console
.catch(e => console.error("Application error: ", e));