Skip to content

Commit

Permalink
[#IP-86] tslint to eslint migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Disaro committed Apr 2, 2021
1 parent b587ce4 commit c3549ac
Show file tree
Hide file tree
Showing 11 changed files with 1,519 additions and 198 deletions.
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Never lint node_modules
node_modules

# We shouldn't lint assets nor generated files
generated

**/__tests__/*
**/__mocks__/*
Dangerfile.*
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"ignorePatterns": [
"node_modules",
"generated",
"**/__tests__/*",
"**/__mocks__/*",
"Dangerfile.*",
"*.d.ts"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"extends": [
"@pagopa/eslint-config/strong",
],
"rules": {
"import/order": "off",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"functional/prefer-readonly-type": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"no-invalid-this": "off",
"prefer-arrow/prefer-arrow-functions": "off",
"@typescript-eslint/prefer-optional-chain": "off",
"no-underscore-dangle": "off"
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ coverage
.vscode
obj
bin

# eslint section
!.eslintrc.js
.eslintcache
2 changes: 1 addition & 1 deletion Dangerfile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import custom DangerJS rules
// see http://danger.systems/js
// see https://github.com/teamdigitale/danger-plugin-digitalcitizenship/
// tslint:disable-next-line:prettier
// eslint-disable-next-line prettier/prettier
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 @@ -18,11 +18,13 @@
"start": "npm-run-all --parallel start:host watch",
"pretest": "npm run build",
"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": {
"eslint-plugin-prettier": "^3.3.1",
"@pagopa/eslint-config": "^1.1.1",
"@azure/functions": "^1.0.3",
"@types/express": "^4.17.2",
"@types/express-serve-static-core": "^4.17.2",
Expand All @@ -33,14 +35,12 @@
"danger": "^9.2.0",
"danger-plugin-digitalcitizenship": "*",
"express": "^4.17.1",
"italia-tslint-rules": "*",
"jest": "^24.8.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.12.1",
"rimraf": "^2.6.2",
"tree-kill": "^1.2.2",
"ts-jest": "^24.0.2",
"tslint": "^5.1.0",
"typescript": "^3.5.0"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/ExpressAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import OutgoingMessage from "./OutgoingMessage";
* @throws {Error}
* @private
*/
// tslint:disable-next-line: no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const isValidContext = (context: any): context is Context =>
context !== undefined &&
typeof context === "object" &&
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class ExpressAdapter extends EventEmitter {
prev: NonNullable<Context["res"]>
) => NonNullable<Context["res"]>
) => {
// tslint:disable-next-line: no-object-mutation
// eslint-disable-next-line functional/immutable-data
context.res = updater(context.res || {});
};

Expand Down
2 changes: 1 addition & 1 deletion src/IncomingMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class IncomingMessage extends Readable {
context: sanitizeContext(context), // Specific to Azure Function
headers: req.headers || {}, // Should always have a headers object
socket: { destroy: NOOP },
// tslint:disable-next-line: no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
url: (req as any).originalUrl
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/OutgoingMessage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable: variable-name
// eslint-disable camelcase

import { Context } from "@azure/functions";
import {
Expand Down Expand Up @@ -41,7 +41,7 @@ export default class OutgoingMessage extends NativeOutgoingMessage {
// Those methods cannot be prototyped because express explicitelly overrides __proto__
// See https://github.com/expressjs/express/blob/master/lib/middleware/init.js#L29
public end: NativeOutgoingMessage["end"] = (
// tslint:disable-next-line: no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
chunkOrCb?: any
) => {
// 1. Write head
Expand Down Expand Up @@ -72,7 +72,7 @@ export default class OutgoingMessage extends NativeOutgoingMessage {
}

// 2. Status message
// tslint:disable-next-line: no-object-mutation
// eslint-disable-next-line functional/immutable-data
this.statusMessage =
typeof reasonOrHeaders === "string"
? reasonOrHeaders
Expand Down Expand Up @@ -102,7 +102,7 @@ export default class OutgoingMessage extends NativeOutgoingMessage {
// we want to never have undefined headers, but instead empty object
headers:
this._headers && headers === undefined
? // tslint:disable-next-line: no-any
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
(this as any)._renderHeaders()
: headers !== undefined
? headers
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ import * as qs from "querystring";
// do not convert to default import despite vscode hints :-)
import * as treeKill from "tree-kill";

// tslint:disable-next-line: no-let
// eslint-disable-next-line functional/no-let
let spawnedFunc: ChildProcess;
// tslint:disable-next-line: no-let
// eslint-disable-next-line functional/no-let
let funcAddress: string;
// tslint:disable-next-line: no-let
// eslint-disable-next-line functional/no-let
let isStopping = false;

// do not reject promise on non-200 statuses
// tslint:disable-next-line: no-object-mutation
// eslint-disable-next-line functional/immutable-data
axios.defaults.validateStatus = () => true;

const startFunc = () =>
// tslint:disable-next-line: promise-must-complete
// eslint-disable-next-line @typescript-eslint/no-floating-promises
new Promise<{ p: ChildProcess; address: string }>(res => {
const func = spawn("func", ["start"]);
func.stdout.on("data", data => {
if (!isStopping) {
// tslint:disable-next-line: no-console
// eslint-disable-next-line no-console
console.log(`${data}`);
}
const matches = String(data).match(/(http:\/\/[^{]+)/);
if (matches && matches[1]) {
// tslint:disable-next-line: no-console
// eslint-disable-next-line no-console
console.log("serving function at %s", matches[1]);
res({
address: matches[1],
Expand Down
9 changes: 0 additions & 9 deletions tslint.json

This file was deleted.

Loading

0 comments on commit c3549ac

Please sign in to comment.