Skip to content

Commit

Permalink
WIP: feat(ts): convert js src files to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
tduyng committed Jan 9, 2022
1 parent 51156b3 commit c6d6989
Show file tree
Hide file tree
Showing 133 changed files with 8,626 additions and 7,383 deletions.
47 changes: 40 additions & 7 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
root: true
parser: '@typescript-eslint/parser'
parserOptions:
ecmaVersion: 2019
sourceType: script
project: './tsconfig.json'
sourceType: module
env:
node: true
es6: true
jest: true
extends: eslint:recommended
node: true
es6: true
jest: true
mocha: true
plugins:
- 'import'
extends:
- 'eslint:recommended'
- 'plugin:@typescript-eslint/recommended'
- 'plugin:@typescript-eslint/recommended-requiring-type-checking'
- 'plugin:prettier/recommended'
- 'plugin:import/errors'
- 'plugin:import/warnings'
- 'plugin:import/typescript'
ignorePatterns:
- 'build/*'
- 'tests/**/*.js'
- 'examples/*'
- 'bin/*'
- '.yarn/*'
- 'scripts/*'
- 'jest.config.js'
rules:
no-unused-vars: off
'no-console': 'warn'
'no-duplicate-imports': 'error'
'no-return-await': 'error'
'no-unneeded-ternary': 'error'
'no-unused-vars': [ 'off' ]
'prefer-object-spread': 'error'
'require-await': 'off'
'@typescript-eslint/ban-ts-comment': 'warn'
'@typescript-eslint/restrict-template-expressions': 'warn'
'@typescript-eslint/unbound-method': 'warn'
'@typescript-eslint/no-unsafe-argument': 'warn'
'@typescript-eslint/explicit-function-return-type': 'error'
'@typescript-eslint/no-unsafe-assignment': 'warn'
'@typescript-eslint/no-unsafe-member-access': 'warn'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ coverage

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
build/

# Dependency directories
node_modules
Expand Down
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# .prettierrc
arrowParens: always
printWidth: 100
semi: false
singleQuote: true
tabWidth: 4
overrides:
- files:
- "*.yml"
- "*.yaml"
options:
bracketSpacing: false
tabWidth: 2
- files: "*.json"
options:
trailingComma: all
tabWidth: 4
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
Expand Down
2 changes: 1 addition & 1 deletion examples/features/http_api/fixtures/fixtures/module_00.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'

module.exports = () => ({
data: 'fixture loaded from javascript module'
data: 'fixture loaded from javascript module',
})
5 changes: 0 additions & 5 deletions examples/support/definitions.js

This file was deleted.

4 changes: 4 additions & 0 deletions examples/support/definitions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

import { Given } from "@cucumber/cucumber"

Given(/^(?:I )?define http mock from (.+)$/, function () {})
20 changes: 0 additions & 20 deletions examples/support/http_api/fixtures.steps.js

This file was deleted.

11 changes: 11 additions & 0 deletions examples/support/http_api/fixtures.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Given } from "@cucumber/cucumber"
import nock from "nock"

Given(
/^I mock http call to forward request body for path (.+)$/,
function (path) {
nock("http://fake.io")
.post(path)
.reply(200, (uri, requestBody) => requestBody)
}
)
12 changes: 9 additions & 3 deletions examples/support/world.js → examples/support/world.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
'use strict'

const { setWorldConstructor } = require('@cucumber/cucumber')
const { state, fixtures, httpApi, cli, fileSystem, snapshot } = require('../../src')
import { setWorldConstructor } from "@cucumber/cucumber"
import {
state,
fixtures,
httpApi,
cli,
fileSystem,
snapshot,
} from "../../src/index"

setWorldConstructor(function () {
state.extendWorld(this)
Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ module.exports = {
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
modulePathIgnorePatterns: ['<rootDir>/build'],
collectCoverageFrom: ['src/**/*.ts'],
coverageDirectory: './coverage',
}
192 changes: 107 additions & 85 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,88 +1,110 @@
{
"name": "@ekino/veggies",
"version": "1.1.0",
"description": "Veggies is an awesome cucumberjs library for API/CLI testing. Great for testing APIs built upon Express, Koa, HAPI, Loopback and others. It's also the perfect companion for testing CLI applications built with commander, meow & Co.",
"tags": [
"bdd",
"cucumber",
"gherkin",
"testing",
"api",
"http",
"cli"
],
"repository": {
"type": "git",
"url": "https://github.com/ekino/veggies.git"
},
"main": "src/index.js",
"bin": "./bin/veggies.js",
"author": "plouc <https://github.com/plouc>",
"maintainers": [
{
"name": "Raphaël Benitte"
"name": "@ekino/veggies",
"version": "1.1.0",
"description": "Veggies is an awesome cucumberjs library for API/CLI testing. Great for testing APIs built upon Express, Koa, HAPI, Loopback and others. It's also the perfect companion for testing CLI applications built with commander, meow & Co.",
"tags": [
"bdd",
"cucumber",
"gherkin",
"testing",
"api",
"http",
"cli"
],
"repository": {
"type": "git",
"url": "https://github.com/ekino/veggies.git"
},
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"bin": "build/bin/veggies.js",
"author": "plouc <https://github.com/plouc>",
"maintainers": [
{
"name": "Raphaël Benitte"
}
],
"license": "MIT",
"engines": {
"node": ">=12"
},
"engineStrict": true,
"dependencies": {
"arg": "5.0.1",
"chai": "4.3",
"fs-extra": "10.0.0",
"glob": "7.2.0",
"jest-diff": "27.4.2",
"js-yaml": "4.1.0",
"lodash": "4.17.21",
"moment-timezone": "0.5.34",
"natural-compare": "1.4.0",
"pretty-format": "27.4.2",
"request": "2.88.2",
"tough-cookie": "4.0.0"
},
"devDependencies": {
"@commitlint/config-conventional": "15.x",
"@cucumber/cucumber": "7.x",
"@types/babylon": "6.x",
"@types/chai": "4.x",
"@types/fs-extra": "9.x",
"@types/glob": "7.x",
"@types/jest": "27.x",
"@types/js-yaml": "4.x",
"@types/lodash": "4.x",
"@types/moment-timezone": "0.5.x",
"@types/mustache": "4.x",
"@types/natural-compare": "1.x",
"@types/node": "16.x",
"@types/proxyquire": "^1.3.28",
"@types/request": "2.x",
"@types/sinon": "10.x",
"@types/tough-cookie": "4.x",
"@typescript-eslint/eslint-plugin": "5.x",
"@typescript-eslint/parser": "5.x",
"babylon": "6.x",
"chalk": "4.x",
"commitlint": "15.x",
"conventional-changelog-cli": "2.x",
"coveralls": "3.x",
"eslint": "8.x",
"eslint-config-prettier": "8.x",
"eslint-plugin-import": "2.x",
"eslint-plugin-prettier": "4.x",
"gh-pages": "3.x",
"husky": "7.0.4",
"jest": "27.x",
"jsdoc": "3.x",
"lint-staged": "12.x",
"minami": "1.x",
"mustache": "4.x",
"nock": "13.x",
"prettier": "2.x",
"proxyquire": "^2.1.3",
"sinon": "12.x",
"ts-jest": "27.x",
"ts-node": "10.x",
"typescript": "4.5.x"
},
"peerDependencies": {
"@cucumber/cucumber": ">=7.0.0"
},
"scripts": {
"build": "rm -rf build & tsc -d",
"test": "jest --verbose --colors tests",
"test-cover": "jest --verbose --colors --coverage",
"test-cli": "veggies --require tests/cli/support tests/cli/features",
"coverage": "cat ./coverage/lcov.info | coveralls",
"fmt": "prettier --print-width 100 --tab-width=4 --single-quote --bracket-spacing --no-semi --color --write \"{src,tests,scripts}/**/*.js\"",
"check-fmt": "prettier --print-width 100 --tab-width=4 --single-quote --bracket-spacing --no-semi --list-different \"{src,tests,scripts}/**/*.js\"",
"lint": "eslint . --quiet",
"lint-fix": "eslint --fix . --quiet",
"readme": "ts-node -T -s scripts/generate_readme.ts",
"check-readme": "ts-node -T -s scripts/generate_readme.ts --check",
"doc": "jsdoc -c .jsdoc.json --verbose",
"doc-pub": "yarn run readme && yarn run doc && gh-pages -d _doc",
"examples": "veggies --require examples/support examples/features",
"changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s"
}
],
"license": "MIT",
"engines": {
"node": ">=12"
},
"engineStrict": true,
"dependencies": {
"arg": "5.0.1",
"chai": "4.3",
"fs-extra": "10.0.0",
"glob": "7.2.0",
"jest-diff": "27.4.2",
"js-yaml": "4.1.0",
"lodash": "4.17.21",
"moment-timezone": "0.5.34",
"natural-compare": "1.4.0",
"pretty-format": "27.4.2",
"request": "2.88.2",
"tough-cookie": "4.0.0"
},
"devDependencies": {
"@commitlint/config-conventional": "15.x",
"@cucumber/cucumber": "7.x",
"@types/jest": "27.x",
"@types/node": "16.x",
"babylon": "6.x",
"chalk": "4.x",
"commitlint": "15.x",
"conventional-changelog-cli": "2.x",
"coveralls": "3.x",
"eslint": "8.x",
"gh-pages": "3.x",
"husky": "^7.0.4",
"jest": "27.x",
"jsdoc": "3.x",
"lint-staged": "12.x",
"minami": "1.x",
"mustache": "4.x",
"nock": "13.x",
"prettier": "2.x",
"sinon": "12.x",
"ts-jest": "27.x",
"typescript": "4.5.x"
},
"peerDependencies": {
"@cucumber/cucumber": ">=7.0.0"
},
"scripts": {
"test": "jest --verbose --colors tests",
"test-cover": "jest --verbose --colors --coverage",
"test-cli": "veggies --require tests/cli/support tests/cli/features",
"coverage": "cat ./coverage/lcov.info | coveralls",
"fmt": "prettier --print-width 100 --tab-width=4 --single-quote --bracket-spacing --no-semi --color --write \"{src,tests,scripts}/**/*.js\"",
"check-fmt": "prettier --print-width 100 --tab-width=4 --single-quote --bracket-spacing --no-semi --list-different \"{src,tests,scripts}/**/*.js\"",
"lint": "eslint .",
"lint-fix": "eslint --fix .",
"readme": "node scripts/generate_readme",
"check-readme": "node scripts/generate_readme --check",
"doc": "jsdoc -c .jsdoc.json --verbose",
"doc-pub": "yarn run readme && yarn run doc && gh-pages -d _doc",
"examples": "veggies --require examples/support examples/features",
"changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s"
}
}
Loading

0 comments on commit c6d6989

Please sign in to comment.