Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
chore: replace tslint with eslint
  • Loading branch information
roggervalf committed May 4, 2021
1 parent b75b4f1 commit 5770aef
Show file tree
Hide file tree
Showing 14 changed files with 800 additions and 193 deletions.
22 changes: 22 additions & 0 deletions .eslintignore
@@ -0,0 +1,22 @@
.DS_Store
node_modules
/dist

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Coverage files
.nyc_output

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
temp
docs/gitbook/api
57 changes: 57 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,57 @@
{
"parser": "@typescript-eslint/parser",
"env": { "es6": true, "node": true, "mocha": true },
"globals": { "Atomics": "readonly", "SharedArrayBuffer": "readonly" },
"plugins": ["promise", "prettier", "@typescript-eslint/eslint-plugin"],
"extends": [
"prettier",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-empty-interface": [
"error",
{
"allowSingleExtends": false
}
],
"@typescript-eslint/no-explicit-any": "off",

"@typescript-eslint/ban-types": [
"error",
{
"extendDefaults": true,
"types": {
"object": false,
"Object": false,
"Function": false
}
}
],
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-empty-function": 1,
"@typescript-eslint/no-this-alias": 0,
"space-before-function-paren": [
"error",
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}
],
"arrow-parens": [2, "as-needed", { "requireForBlockBody": false }],
"no-async-promise-executor": 0,
"no-extraneous-class": 0,
"@typescript-eslint/no-inferrable-types": 2,
"semi": 2,
"no-bitwise": 0,
"eol-last": 2,
"prefer-const": 1,
"forin": 0,
"max-len": [
"error",
{ "code": 120, "ignorePattern": "^import\\s.+\\sfrom\\s.+;$" }
]
}
}
8 changes: 8 additions & 0 deletions .prettierrc.js
@@ -0,0 +1,8 @@
module.exports = {
singleQuote: true,
trailingComma: 'all',
tabWidth: 2,
printWidth: 80,
semi: true,
arrowParens: 'avoid',
};
30 changes: 17 additions & 13 deletions package.json
Expand Up @@ -11,16 +11,19 @@
"dist"
],
"scripts": {
"dry-run": "npm publish --dry-run",
"build": "tsc && yarn copylua",
"copylua": "copyfiles -f ./src/commands/*.lua ./dist/commands",
"coverage": "nyc --reporter=text npm run test",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"docs": "(api-extractor run || true) && api-documenter markdown -i ./temp -o docs/gitbook/api",
"lint": "tslint --project tsconfig.json -c tslint.json 'src/**/*.ts'",
"precommit": "yarn lint",
"dry-run": "npm publish --dry-run",
"eslint:fix": "./node_modules/.bin/eslint . --ignore-path ./.eslintignore --fix",
"lint": "./node_modules/.bin/eslint . --ignore-path ./.eslintignore",
"lint:staged": "./node_modules/.bin/lint-staged",
"precommit": "yarn pretty:quick && yarn lint:staged",
"prepare": "yarn build",
"prettier": "prettier --config package.json src/**/*.ts",
"pretty:quick": "./node_modules/.bin/pretty-quick --ignore-path ./.eslintignore --staged",
"semantic-release": "semantic-release",
"semantic-release-prepare": "ts-node tools/semantic-release-prepare",
"test": "yarn lint && tsc && ts-mocha --paths 'src/**/test_*.ts' --exit",
Expand Down Expand Up @@ -57,24 +60,28 @@
"@types/semver": "^6.0.1",
"@types/sinon": "^7.0.13",
"@types/uuid": "^3.4.5",
"@typescript-eslint/eslint-plugin": "4.5.0",
"@typescript-eslint/parser": "4.5.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"copyfiles": "^2.1.1",
"coveralls": "^3.0.7",
"eslint": "6.8.0",
"eslint-config-prettier": "6.7.0",
"eslint-plugin-prettier": "3.1.2",
"eslint-plugin-promise": "4.2.1",
"husky": "^3.0.3",
"istanbul": "^0.4.5",
"lint-staged": "10.5.4",
"mocha": "^6.1.4",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^14.1.1",
"prettier": "^1.18.2",
"prettier": "^2.1.2",
"pretty-quick": "^3.1.0",
"semantic-release": "^17.3.1",
"sinon": "^7.2.2",
"ts-mocha": "^6.0.0",
"ts-node": "^8.4.1",
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.2.2"
},
"nyc": {
Expand All @@ -92,14 +99,11 @@
"@commitlint/config-conventional"
]
},
"prettier": {
"singleQuote": true,
"trailingComma": "all",
"printWidth": 80
"lint-staged": {
"*.{js,ts}": "yarn eslint:fix"
},
"husky": {
"hooks": {
"pre-commit": "yarn precommit",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/classes/scripts.ts
Expand Up @@ -102,7 +102,7 @@ export class Scripts {
static async pause(queue: MinimalQueue, pause: boolean) {
const client = await queue.client;

var src = 'wait',
let src = 'wait',
dst = 'paused';
if (!pause) {
src = 'paused';
Expand Down
2 changes: 2 additions & 0 deletions src/test/fixtures/delay.js
@@ -1,3 +1,5 @@
'use strict';

module.exports = function delay(ms) {
return new Promise(function(resolve) {
return setTimeout(resolve, ms);
Expand Down
8 changes: 4 additions & 4 deletions src/test/test_events.ts
@@ -1,11 +1,11 @@
import { Queue } from '@src/classes';
import { QueueEvents } from '@src/classes/queue-events';
import { Worker } from '@src/classes/worker';
import { Queue } from '../classes';
import { QueueEvents } from '../classes/queue-events';
import { Worker } from '../classes/worker';
import { expect } from 'chai';
import * as IORedis from 'ioredis';
import { beforeEach, describe, it } from 'mocha';
import { v4 } from 'uuid';
import { delay, removeAllQueueData } from '@src/utils';
import { delay, removeAllQueueData } from '../utils';

describe('events', function() {
this.timeout(4000);
Expand Down
10 changes: 6 additions & 4 deletions src/test/test_flow.ts
Expand Up @@ -231,7 +231,7 @@ describe('flows', () => {

let childrenProcessor;
const processingChildren = new Promise<void>(resolve => [
(childrenProcessor = async (job: Job) => {
(childrenProcessor = async () => {
resolve();
throw new Error('failed job');
}),
Expand Down Expand Up @@ -275,15 +275,15 @@ describe('flows', () => {

let childrenProcessor, parentProcessor;
const processingChildren = new Promise<void>(resolve => [
(childrenProcessor = async (job: Job) => {
(childrenProcessor = async () => {
resolve();
}),
]);

const childrenWorker = new Worker(queueName, childrenProcessor);

const processingParent = new Promise<void>(resolve => [
(parentProcessor = async (job: Job) => {
(parentProcessor = async () => {
resolve();
}),
]);
Expand Down Expand Up @@ -410,7 +410,9 @@ describe('flows', () => {

try {
await tree.job.remove();
} catch (err) {}
} catch (err) {
return;
}

expect(await tree.job.getState()).to.be.equal('waiting-children');
expect(await tree.children[0].job.getState()).to.be.equal('active');
Expand Down
20 changes: 12 additions & 8 deletions src/test/test_job.ts
Expand Up @@ -219,21 +219,21 @@ describe('Job', function() {
{ idx: 1, baz: 'something' },
];
const token = 'my-token';

const parentQueueName = 'parent-queue';

const parentQueue = new Queue(parentQueueName);

const parentWorker = new Worker(parentQueueName);
const childrenWorker = new Worker(queueName);
await parentWorker.waitUntilReady();
await childrenWorker.waitUntilReady();

const data = { foo: 'bar' };
const parent = await Job.create(parentQueue, 'testParent', data);
const parentKey = getParentKey({
id: parent.id,
queue: 'bull:' + parentQueueName
queue: 'bull:' + parentQueueName,
});
const client = await queue.client;
const child1 = new Job(queue, 'testJob1', values[0]);
Expand All @@ -256,12 +256,14 @@ describe('Job', function() {
const isActive = await job.isActive();
expect(isActive).to.be.equal(true);

await expect(job.moveToCompleted('return value', token)).to.be.rejectedWith(`Job ${job.id} has pending dependencies finished`);
await expect(
job.moveToCompleted('return value', token),
).to.be.rejectedWith(`Job ${job.id} has pending dependencies finished`);

const isCompleted = await job.isCompleted();

expect(isCompleted).to.be.false;

await childrenWorker.close();
await parentWorker.close();
await parentQueue.close();
Expand Down Expand Up @@ -456,7 +458,9 @@ describe('Job', function() {
try {
await job.promote();
throw new Error('Job should not be promoted!');
} catch (err) {}
} catch (err) {
return;
}
});

it('should promote delayed job to the right queue if queue is paused', async () => {
Expand Down
21 changes: 12 additions & 9 deletions src/test/test_sandboxed_process.ts
Expand Up @@ -88,8 +88,6 @@ describe('sandboxed process', () => {
it('should process with concurrent processors', async function() {
this.timeout(10000);

let worker: Worker;

await Promise.all([
queue.add('test', { foo: 'bar1' }),
queue.add('test', { foo: 'bar2' }),
Expand All @@ -98,7 +96,7 @@ describe('sandboxed process', () => {
]);

const processFile = __dirname + '/fixtures/fixture_processor_slow.js';
worker = new Worker(queueName, processFile, {
const worker = new Worker(queueName, processFile, {
concurrency: 4,
drainDelay: 1,
});
Expand Down Expand Up @@ -131,9 +129,8 @@ describe('sandboxed process', () => {
it('should reuse process with single processors', async function() {
this.timeout(30000);

let worker: Worker;
const processFile = __dirname + '/fixtures/fixture_processor_slow.js';
worker = new Worker(queueName, processFile, {
const worker = new Worker(queueName, processFile, {
concurrency: 1,
drainDelay: 1,
});
Expand Down Expand Up @@ -262,13 +259,15 @@ describe('sandboxed process', () => {
it('should fail if the process crashes', async () => {
const processFile = __dirname + '/fixtures/fixture_processor_crash.js';

const worker = new Worker(queueName, processFile, {
new Worker(queueName, processFile, {
drainDelay: 1,
});

const job = await queue.add('test', {});

await expect(job.waitUntilFinished(queueEvents)).to.be.rejectedWith('boom!');
await expect(job.waitUntilFinished(queueEvents)).to.be.rejectedWith(
'boom!',
);
});

it('should fail if the process exits 0', async () => {
Expand All @@ -280,7 +279,9 @@ describe('sandboxed process', () => {

const job = await queue.add('test', { exitCode: 0 });

await expect(job.waitUntilFinished(queueEvents)).to.be.rejectedWith('Unexpected exit code: 0 signal: null');
await expect(job.waitUntilFinished(queueEvents)).to.be.rejectedWith(
'Unexpected exit code: 0 signal: null',
);
});

it('should fail if the process exits non-0', async () => {
Expand All @@ -292,7 +293,9 @@ describe('sandboxed process', () => {

const job = await queue.add('test', { exitCode: 1 });

await expect(job.waitUntilFinished(queueEvents)).to.be.rejectedWith('Unexpected exit code: 1 signal: null');
await expect(job.waitUntilFinished(queueEvents)).to.be.rejectedWith(
'Unexpected exit code: 1 signal: null',
);
});

it('should remove exited process', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/test/test_stalled_jobs.ts
@@ -1,5 +1,5 @@
import { Queue, QueueScheduler, Worker, QueueEvents } from '@src/classes';
import { delay, removeAllQueueData } from '@src/utils';
import { Queue, QueueScheduler, Worker, QueueEvents } from '../classes';
import { delay, removeAllQueueData } from '../utils';
import * as IORedis from 'ioredis';
import { after } from 'lodash';
import { beforeEach, describe, it } from 'mocha';
Expand Down

0 comments on commit 5770aef

Please sign in to comment.