Skip to content

Commit

Permalink
fix: move from tslint to eslint (#178)
Browse files Browse the repository at this point in the history
* fix: move from tslint to eslint

closes #159
* feat: add workit-cli for eslint
* update workit template to 4.1.0 as well
* fix: ignore tests folder
* fix: add prettierignore file
* ci: remove travis config
* fix: convert examples to eslint

Signed-off-by: Olivier Albertini <olivier.albertini@montreal.ca>
  • Loading branch information
OlivierAlbertini committed Mar 23, 2020
1 parent cfa88f9 commit 0dce14b
Show file tree
Hide file tree
Showing 251 changed files with 1,835 additions and 1,620 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.*
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

39 changes: 39 additions & 0 deletions eslint.rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
// prettier conflicts
"no-underscore-dangle": "off",
"max-len": "off",
"max-classes-per-file": "off",
"class-methods-use-this": "off",
"no-await-in-loop": "off",
"import/prefer-default-export": "off",
"comma-dangle": "off",
"object-curly-newline":"off",
"arrow-parens": "off",
"implicit-arrow-linebreak": "off",
"prettier/prettier": "error",
"@typescript-eslint/no-useless-constructor": "off", // not good with inversify
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/interface-name-prefix": ["error", { "prefixWithI": "always" }],
"@typescript-eslint/explicit-member-accessibility": ["error", {
"accessibility": "explicit",
"overrides": {
"accessors": "explicit",
"constructors": "no-public",
"methods": "explicit",
"properties": "explicit",
"parameterProperties": "explicit"
}
}],
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "memberLike",
"modifiers": ["private"],
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "require"
}
],
"header/header": [2, "block", [
`\n * Copyright (c) ${new Date().getFullYear()} Ville de Montreal. All rights reserved.\n * Licensed under the MIT license.\n * See LICENSE file in the project root for full license information.\n `
]]
};
7 changes: 7 additions & 0 deletions examples/basic/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
lib
.vscode
coverage
*lock*
*.md
tests
22 changes: 22 additions & 0 deletions examples/basic/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
"plugins": [
"@typescript-eslint",
"prettier",
"header"
],
"extends": [
"airbnb-typescript/base",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier/@typescript-eslint"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
...require('../../eslint.rules.js'),
"no-console": "off"
}
}
27 changes: 15 additions & 12 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"compile": "rm -rf ./lib/ && npm run build",
"build": "tsc -p ./tsconfig.json",
"watch": "tsc -p ./tsconfig.json --watch",
"lint": "tslint --project ./tsconfig.json && prettier -l \"src/**/*.ts\"",
"lint-fix": "tslint --project ./tsconfig.json --fix && prettier \"src/**/*.ts\" --write",
"lint": "eslint . --ext .ts && prettier -l \"src/**/*.ts\"",
"lint-fix": "prettier \"./**/*.ts\" --write && eslint . --ext .ts --fix",
"check-conflicts":"eslint --print-config tests/utils/func-test.ts | eslint-config-prettier-check",
"camunda:deploy": "node ./lib/src/deploy.js",
"camunda:create-instance": "node ./lib/src/create-process-instances.js",
"camunda:worker": "node ./lib/src/worker.js"
Expand All @@ -24,18 +25,20 @@
"url": "git+https://github.com/VilledeMontreal/workit.git"
},
"devDependencies": {
"@types/node": "^13.1.6",
"prettier": "^1.19.1",
"prettier-tslint": "^0.4.2",
"tslint": "^5.20.1",
"tslint-config-airbnb": "^5.11.2",
"tslint-config-prettier": "^1.18.0",
"tslint-consistent-codestyle": "^1.16.0",
"tslint-microsoft-contrib": "^6.2.0",
"typescript": "^3.6.3"
"@types/node": "^13.9.3",
"prettier": "^2.0.1",
"eslint": "^6.8.0",
"eslint-plugin-header":"^3.0.0",
"eslint-config-airbnb-typescript": "^7.2.0",
"eslint-plugin-import": "^2.20.1",
"eslint-config-prettier":"^6.10.1",
"eslint-plugin-prettier":"^3.1.2",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"typescript": "^3.8.3"
},
"dependencies": {
"axios": "^0.19.0",
"axios": "^0.19.2",
"workit-camunda": "^4.1.0",
"workit-core": "^4.1.0",
"workit-types": "^4.1.0"
Expand Down
15 changes: 7 additions & 8 deletions examples/basic/src/create-process-instances.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright (c) 2019 Ville de Montreal. All rights reserved.
/*
* Copyright (c) 2020 Ville de Montreal. All rights reserved.
* Licensed under the MIT license.
* See LICENSE file in the project root for full license information.
*/
Expand All @@ -8,18 +8,17 @@ import { SERVICE_IDENTIFIER as CORE_IDENTIFIER, TAG } from 'workit-camunda';
import { IoC } from 'workit-core';
import { IWorkflowClient } from 'workit-types';

// tslint:disable-next-line: no-floating-promises
(async () => {
(async (): Promise<void> => {
const cm = IoC.get<IWorkflowClient>(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); // TAG.zeebe
for (let index = 0; index < 1; index++) {
for (let index = 0; index < 1; index += 1) {
await cm.createWorkflowInstance({
bpmnProcessId: 'BPMN_DEMO',
variables: {
amount: 1000,
hello: 'world'
}
hello: 'world',
},
});
}
// tslint:disable-next-line: no-console

console.log('Success!');
})();
8 changes: 3 additions & 5 deletions examples/basic/src/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/*!
* Copyright (c) 2019 Ville de Montreal. All rights reserved.
/*
* Copyright (c) 2020 Ville de Montreal. All rights reserved.
* Licensed under the MIT license.
* See LICENSE file in the project root for full license information.
*/
// tslint:disable: no-floating-promises
// tslint:disable: no-console
import { SERVICE_IDENTIFIER as CORE_IDENTIFIER, TAG } from 'workit-camunda';
import { IoC } from 'workit-core';
import { IWorkflowClient } from 'workit-types';

(async () => {
(async (): Promise<void> => {
const cm = IoC.get<IWorkflowClient>(CORE_IDENTIFIER.client_manager, TAG.camundaBpm);
// const cm = IoC.get<IWorkflowClient>(CORE_IDENTIFIER.client_manager, TAG.zeebe);
const path = `${process.cwd()}/bpmn/BPMN_DEMO.bpmn`;
Expand Down
54 changes: 25 additions & 29 deletions examples/basic/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
/*!
* Copyright (c) 2019 Ville de Montreal. All rights reserved.
/*
* Copyright (c) 2020 Ville de Montreal. All rights reserved.
* Licensed under the MIT license.
* See LICENSE file in the project root for full license information.
*/
// tslint:disable: no-floating-promises
// tslint:disable: no-console

import { SERVICE_IDENTIFIER as CORE_IDENTIFIER, TAG } from 'workit-camunda';
import { IoC, Worker } from 'workit-core';
import { HelloWorldTask } from '../tasks/helloWorldTask';

(async () => {
enum LOCAL_IDENTIFIER {
sample_activity = 'sample_activity'
}
enum LOCAL_IDENTIFIER {
sampleActivity = 'sample_activity',
}

IoC.bindTo(HelloWorldTask, LOCAL_IDENTIFIER.sample_activity);
const worker = IoC.get<Worker>(CORE_IDENTIFIER.worker, TAG.camundaBpm); // TAG.zeebe
IoC.bindTo(HelloWorldTask, LOCAL_IDENTIFIER.sampleActivity);
const worker = IoC.get<Worker>(CORE_IDENTIFIER.worker, TAG.camundaBpm); // TAG.zeebe

const stop = () => {
console.info('SIGTERM signal received.');
console.log('Closing worker');
worker
.stop()
.then(() => {
console.log('worker closed');
process.exit(0);
})
.catch((e: Error) => {
console.log(e);
process.exit(1);
});
};
const stop = (): void => {
console.info('SIGTERM signal received.');
console.log('Closing worker');
worker
.stop()
.then(() => {
console.log('worker closed');
process.exit(0);
})
.catch((e: Error) => {
console.log(e);
process.exit(1);
});
};

worker.start();
worker.run();
worker.start();
worker.run();

process.on('SIGINT', stop);
process.on('SIGTERM', stop);
})();
process.on('SIGINT', stop);
process.on('SIGTERM', stop);
25 changes: 12 additions & 13 deletions examples/basic/tasks/helloWorldTask.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
/*!
* Copyright (c) 2019 Ville de Montreal. All rights reserved.
/*
* Copyright (c) 2020 Ville de Montreal. All rights reserved.
* Licensed under the MIT license.
* See LICENSE file in the project root for full license information.
*/

import axios from 'axios';
import { TaskBase } from "workit-core";
import { TaskBase } from 'workit-core';
import { IMessage } from 'workit-types';

// tslint:disable:no-console
export class HelloWorldTask extends TaskBase<IMessage> {
public async execute(message: IMessage): Promise<IMessage> {
const { properties } = message;

console.log(`Executing task: ${properties.activityId}`);
console.log(`${properties.bpmnProcessId}::${properties.processInstanceId} Servus!`);

const response = await axios.get('https://jsonplaceholder.typicode.com/todos/1');
const { properties } = message;

console.log('\ndata:');
console.log(response.data);
console.log(`Executing task: ${properties.activityId}`);
console.log(`${properties.bpmnProcessId}::${properties.processInstanceId} Servus!`);

return message;
const response = await axios.get('https://jsonplaceholder.typicode.com/todos/1');

console.log('\ndata:');
console.log(response.data);

return message;
}
}
17 changes: 0 additions & 17 deletions examples/basic/tslint.json

This file was deleted.

7 changes: 7 additions & 0 deletions examples/binding/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
lib/
.vscode
coverage
*lock*
*.md
tests/
22 changes: 22 additions & 0 deletions examples/binding/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
"plugins": [
"@typescript-eslint",
"prettier",
"header"
],
"extends": [
"airbnb-typescript/base",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier/@typescript-eslint"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
...require('../../eslint.rules.js'),
"no-console": "off"
}
}
Loading

0 comments on commit 0dce14b

Please sign in to comment.