Skip to content

Commit

Permalink
rewrite source files to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Dec 22, 2023
1 parent 828a192 commit 68d31fe
Show file tree
Hide file tree
Showing 33 changed files with 7,393 additions and 9,773 deletions.
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

135 changes: 70 additions & 65 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,70 +1,75 @@
module.exports = {
/** @type {import('eslint').Linter.Config} */
const config = {
root: true,
'env': {
'node': true
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'unicorn', 'import'],
extends: ['eslint:recommended'],
env: {
node: true,
es6: true,
},
"parser": "@babel/eslint-parser",
extends: [
'eslint:recommended'
],
// add your custom rules here
rules: {
'semi': 1,
'no-useless-escape': 0,
'function-paren-newline': 0,
'no-multi-spaces': 0,
'object-curly-newline': 0,
'prefer-destructuring': 0,
'no-param-reassign': 0,
'no-mixed-operators': 0,
'no-unused-vars': 1,
'no-plusplus': 0,
'no-console': 0,
'prefer-template': 0,
'import/no-extraneous-dependencies': 0,
'import/extensions': 0,
'class-methods-use-this': 0,
'consistent-return': 0,
'no-restricted-syntax': 0,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'max-len': ['warn', 140, { 'ignoreComments': true }],
'quote-props': ['error', 'as-needed'],
'comma-dangle': ['error', {
'arrays': 'always-multiline',
'objects': 'always-multiline',
}],
'one-var': ['error', 'never'],
'space-in-parens': ['error', 'never'],
'space-before-blocks': ['error', 'always'],
'quotes': ['error', 'single', { 'allowTemplateLiterals': true }],
'no-var': 2,
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
globals:{
window: true,
document: true,
jest: true,
describe: true,
fdescribe: true,
xdescribe: true,

beforeAll: true,
afterAll: true,

beforeEach: true,
afterEach: true,

it: true,
fit: true,
xit: true,

expect: true,
spyOn: true,
rules: {
quotes: ['error', 'single', { avoidEscape: true }],
camelcase: ['error', { properties: 'never' }],
semi: ['error', 'never'],
indent: [2, 4],
eqeqeq: ['error', 'always'],

$: true,
browser: true,
Promise: true,
Atomics: true,
Int32Array: true,
SharedArrayBuffer: true,
}
'prefer-const': 'error',
'no-multiple-empty-lines': [2, { max: 1, maxEOF: 1 }],
'array-bracket-spacing': ['error', 'never'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'comma-spacing': ['error', { before: false, after: true }],
'no-lonely-if': 'error',
'dot-notation': 'error',
'no-else-return': 'error',
'no-tabs': 'error',
'no-trailing-spaces': [
'error',
{
skipBlankLines: false,
ignoreComments: false,
},
],
'no-var': 'error',
'unicode-bom': ['error', 'never'],
curly: ['error', 'all'],
'object-curly-spacing': ['error', 'always'],
'keyword-spacing': ['error'],
'require-atomic-updates': 0,
'linebreak-style': ['error', 'unix'],
'unicorn/prefer-node-protocol': ['error'],
'import/extensions': ['error', 'ignorePackages'],
'no-restricted-syntax': [
'error',
'IfStatement > ExpressionStatement > AssignmentExpression',
],
'unicorn/prefer-ternary': 'error',
},
overrides: [
{
files: ['*.ts'],
rules: {
// see https://stackoverflow.com/questions/55280555/typescript-eslint-eslint-plugin-error-route-is-defined-but-never-used-no-un
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'no-undef': 'off',
// allow overloads
'no-redeclare': 'off',
},
},
{
files: ['*.test.ts'],
rules: {
'dot-notation': 'off',
},
},
],
}

module.exports = config
3 changes: 0 additions & 3 deletions __mocks__/@ffmpeg-installer/ffmpeg.js

This file was deleted.

3 changes: 3 additions & 0 deletions __mocks__/@ffmpeg-installer/ffmpeg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
path: 'ffmpeg'
}
9 changes: 0 additions & 9 deletions __mocks__/@wdio/allure-reporter.js

This file was deleted.

11 changes: 11 additions & 0 deletions __mocks__/@wdio/allure-reporter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { vi } from 'vitest'

export const allureMocks = {
addAttachment: vi.fn(),
addArgument: vi.fn()
}

export default {
addAttachment(...args: []) { allureMocks.addAttachment(...args) },
addArgument(...args: []) { allureMocks.addArgument(...args) }
};
13 changes: 8 additions & 5 deletions __mocks__/@wdio/reporter.js → __mocks__/@wdio/reporter.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
export let writeMock;
import { vi } from 'vitest'

export let writeMock: Function

export const resetWriteMock = () => {
writeMock = jest.fn();
writeMock = vi.fn();
};

resetWriteMock();

export default class Reporter {
constructor(options) {
optionsSetInConstructor: any;
constructor(options: any) {
this.optionsSetInConstructor = options;
}

write(msg) {
write(msg: any) {
writeMock(msg);
}
}
}
5 changes: 0 additions & 5 deletions __mocks__/child_process.js

This file was deleted.

7 changes: 7 additions & 0 deletions __mocks__/child_process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { vi } from 'vitest'

export const cpMocks = {
spawn: vi.fn().mockReturnValue({ on: vi.fn() }),
};

export const spawn = (...args: any[]) => { return cpMocks.spawn(...args); };
1 change: 0 additions & 1 deletion __mocks__/file-mock.js

This file was deleted.

1 change: 1 addition & 0 deletions __mocks__/file-mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'file-mock'
35 changes: 0 additions & 35 deletions __mocks__/fs-extra.js

This file was deleted.

36 changes: 36 additions & 0 deletions __mocks__/fs-extra.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { vi } from 'vitest'
export let fsMocks: any

export const resetFsMocks = () => {
fsMocks = {
copy: vi.fn(),
copySync: vi.fn(),
removeSync: vi.fn(),
writeFile: vi.fn(),
existsSync: vi.fn().mockReturnValue('MOCK'),
mkdirsSync: vi.fn(),
readFileSync: vi.fn()
.mockReturnValueOnce('outputDir/MOCK-VIDEO-1.webm')
.mockReturnValueOnce('outputDir/MOCK-VIDEO-1.webm')
.mockReturnValueOnce('outputDir/MOCK-VIDEO-1.webm')
.mockReturnValueOnce('outputDir/MOCK-VIDEO-2.webm')
.mockReturnValueOnce('outputDir/MOCK-VIDEO-2.webm')
.mockReturnValueOnce('outputDir/MOCK-VIDEO-2.webm'),
readdirSync: vi.fn().mockReturnValue(['MOCK-ALLURE-1.webm', 'MOCK-ALLURE-2.webm']),
statSync: vi.fn().mockReturnValue(({ size: 128 })),
};
};

resetFsMocks();

export default {
copy(...args: any[]) { fsMocks.copy(...args); },
copySync(...args: any[]) { fsMocks.copySync(...args); },
removeSync(...args: any[]) { fsMocks.removeSync(...args); },
existsSync(...args: any[]) { return fsMocks.existsSync(...args); },
mkdirsSync(...args: any[]) { fsMocks.mkdirsSync(...args); },
readFileSync(...args: any[]) { return fsMocks.readFileSync(...args); },
readdirSync(...args: any[]) { return fsMocks.readdirSync(...args); },
statSync(...args: any[]) { return fsMocks.statSync(...args); },
writeFile(...args: any[]) { return fsMocks.writeFile(...args); },
};
11 changes: 0 additions & 11 deletions __mocks__/glob.js

This file was deleted.

13 changes: 13 additions & 0 deletions __mocks__/glob.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { vi } from 'vitest'

export let globMocks: { glob: Function };

export const resetGlobMocks = () => {
globMocks = {
glob: vi.fn((_, cb) => cb(null, [])),
}
}

resetGlobMocks();

export default (...args: any[]) => globMocks.glob(...args);
3 changes: 0 additions & 3 deletions __mocks__/mkdirp.js

This file was deleted.

5 changes: 5 additions & 0 deletions __mocks__/mkdirp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { vi } from 'vitest'

export default {
sync: vi.fn()
};
4 changes: 2 additions & 2 deletions __mocks__/path.js → __mocks__/path.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default {
resolve(...args) {
resolve(...args: any[]) {
return args
.slice(1)
.reduce((acc, cur) => acc + '/' + cur, arguments[0]).replace(/\/\//g, '/');
},
dirname(file) {
dirname(file: string) {
return file.replace(/[^\/]+?$/, '');
},
};
Loading

0 comments on commit 68d31fe

Please sign in to comment.