Skip to content

Commit

Permalink
modernize setup with babel jest (vega#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz authored Oct 10, 2020
1 parent 26e3268 commit f55be9f
Show file tree
Hide file tree
Showing 74 changed files with 1,109 additions and 294 deletions.
92 changes: 46 additions & 46 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "prettier"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
"prettier/standard"
],
env: {
browser: true,
node: true
},
parserOptions: {
ecmaVersion: 2018,
sourceType: "module"
},
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-parameter-properties": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
vars: "all",
args: "none",
ignoreRestSiblings: true
}
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "prettier"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
"prettier/standard",
],
"@typescript-eslint/no-object-literal-type-assertion": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"max-len": ["error", { code: 120, tabWidth: 4 }],
"linebreak-style": ["error", "unix"],
"no-alert": "error",
"prefer-const": "error",
"no-return-assign": "error",
"no-useless-call": "error",
"no-shadow": "error",
"no-useless-concat": "error",
"no-undef": "off",
"no-prototype-builtins": "off",
"prettier/prettier": "error"
}
env: {
browser: true,
node: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: "module",
},
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-parameter-properties": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
vars: "all",
args: "none",
ignoreRestSiblings: true,
},
],
"@typescript-eslint/no-object-literal-type-assertion": "off",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"max-len": ["error", { code: 120, tabWidth: 4 }],
"linebreak-style": ["error", "unix"],
"no-alert": "error",
"prefer-const": "error",
"no-return-assign": "error",
"no-useless-call": "error",
"no-shadow": "error",
"no-useless-concat": "error",
"no-undef": "off",
"no-prototype-builtins": "off",
"prettier/prettier": "error",
},
};
14 changes: 2 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/setup-node@v1
with:
node-version: 14

- name: Install Node dependencies
run: yarn --frozen-lockfile
Expand Down
17 changes: 0 additions & 17 deletions .npmignore

This file was deleted.

3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [["@babel/preset-env", { targets: { node: "current" } }], "@babel/preset-typescript"],
};
2 changes: 1 addition & 1 deletion factory/parser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AsExpressionNodeParser } from "./../src/NodeParser/AsExpressionNodeParser";
import * as ts from "typescript";
import ts from "typescript";
import { BasicAnnotationsReader } from "../src/AnnotationsReader/BasicAnnotationsReader";
import { ExtendedAnnotationsReader } from "../src/AnnotationsReader/ExtendedAnnotationsReader";
import { ChainNodeParser } from "../src/ChainNodeParser";
Expand Down
2 changes: 1 addition & 1 deletion factory/program.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as glob from "glob";
import * as path from "path";
import * as ts from "typescript";
import ts from "typescript";

import { Config } from "../src/Config";
import { DiagnosticError } from "../src/Error/DiagnosticError";
Expand Down
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
moduleFileExtensions: ["js", "ts", "json"],
testPathIgnorePatterns: ["<rootDir>/dist/", "<rootDir>/node_modules/", "<rootDir>/build/"],
coverageDirectory: "./coverage/",
collectCoverage: false,
testEnvironment: "node",
transform: {
".*": "babel-jest",
},
};
48 changes: 13 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"bin": {
"ts-json-schema-generator": "./bin/ts-json-schema-generator"
},
"files": [
"src",
"factory"
],
"author": {
"name": "Alexander Evtushenko",
"email": "[email protected]"
Expand All @@ -30,16 +34,21 @@
"jsonschema"
],
"engines": {
"node": ">=6.0.0"
"node": ">=10.0.0"
},
"dependencies": {
"@types/json-schema": "^7.0.6",
"commander": "~6.1.0",
"glob": "~7.1.6",
"commander": "^6.1.0",
"fast-json-stable-stringify": "^2.1.0",
"glob": "^7.1.6",
"json-stable-stringify": "^1.0.1",
"typescript": "~4.0.3"
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@babel/preset-typescript": "^7.10.4",
"@types/fast-json-stable-stringify": "^2.0.0",
"@types/glob": "^7.1.3",
"@types/jest": "^26.0.14",
"@types/json-stable-stringify": "^1.0.32",
Expand All @@ -48,14 +57,12 @@
"@typescript-eslint/parser": "^4.4.0",
"ajv": "~6.12.5",
"chai": "~4.2.0",
"eslint": "^7.10.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.12.0",
"eslint-plugin-prettier": "^3.1.4",
"jest": "^26.5.2",
"jest-junit": "^12.0.0",
"prettier": "^2.1.2",
"source-map-support": "~0.5.19",
"ts-jest": "^26.4.1",
"ts-node": "^9.0.0"
},
"scripts": {
Expand All @@ -68,34 +75,5 @@
"test:fast": "FAST_TEST=1 jest test/ --verbose",
"debug": "node -r ts-node/register --inspect-brk ts-json-schema-generator.ts",
"run": "ts-node ts-json-schema-generator.ts"
},
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"testPathIgnorePatterns": [
"node_modules",
"test-runtime",
"<rootDir>/build",
"_site",
"src",
"dist"
],
"coverageReporters": [
"html",
"cobertura"
],
"coverageDirectory": "./coverage/",
"collectCoverage": false,
"testEnvironment": "node"
}
}
2 changes: 1 addition & 1 deletion src/AnnotationsReader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Annotations } from "./Type/AnnotatedType";

export interface AnnotationsReader {
Expand Down
2 changes: 1 addition & 1 deletion src/AnnotationsReader/BasicAnnotationsReader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { AnnotationsReader } from "../AnnotationsReader";
import { Annotations } from "../Type/AnnotatedType";
import { symbolAtNode } from "../Utils/symbolAtNode";
Expand Down
2 changes: 1 addition & 1 deletion src/AnnotationsReader/ExtendedAnnotationsReader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Annotations } from "../Type/AnnotatedType";
import { symbolAtNode } from "../Utils/symbolAtNode";
import { BasicAnnotationsReader } from "./BasicAnnotationsReader";
Expand Down
2 changes: 1 addition & 1 deletion src/ChainNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { UnknownNodeError } from "./Error/UnknownNodeError";
import { Context } from "./NodeParser";
import { SubNodeParser } from "./SubNodeParser";
Expand Down
2 changes: 1 addition & 1 deletion src/CircularReferenceNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context } from "./NodeParser";
import { SubNodeParser } from "./SubNodeParser";
import { BaseType } from "./Type/BaseType";
Expand Down
2 changes: 1 addition & 1 deletion src/Error/DiagnosticError.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { BaseError } from "./BaseError";

export class DiagnosticError extends BaseError {
Expand Down
2 changes: 1 addition & 1 deletion src/Error/UnknownNodeError.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { BaseError } from "./BaseError";

export class UnknownNodeError extends BaseError {
Expand Down
2 changes: 1 addition & 1 deletion src/ExposeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context } from "./NodeParser";
import { SubNodeParser } from "./SubNodeParser";
import { BaseType } from "./Type/BaseType";
Expand Down
4 changes: 2 additions & 2 deletions src/NodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as stringify from "json-stable-stringify";
import * as ts from "typescript";
import stringify from "fast-json-stable-stringify";
import ts from "typescript";
import { BaseType } from "./Type/BaseType";
import { ReferenceType } from "./Type/ReferenceType";
import { getKey } from "./Utils/nodeKey";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/AnnotatedNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { AnnotationsReader } from "../AnnotationsReader";
import { ExtendedAnnotationsReader } from "../AnnotationsReader/ExtendedAnnotationsReader";
import { Context } from "../NodeParser";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/AnyTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { AnyType } from "../Type/AnyType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/ArrayLiteralExpressionNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/ArrayNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { ArrayType } from "../Type/ArrayType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/AsExpressionNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NodeParser } from "./../NodeParser";
import * as ts from "typescript";
import ts from "typescript";
import { Context } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/BooleanLiteralNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/BooleanTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/CallExpressionParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/ConditionalTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/EnumNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/ExpressionWithTypeArgumentsNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/FunctionNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
import { FunctionType } from "./../Type/FunctionType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/HiddenTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { Context } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
import { BaseType } from "../Type/BaseType";
Expand Down
2 changes: 1 addition & 1 deletion src/NodeParser/IndexedAccessTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from "typescript";
import ts from "typescript";
import { LogicError } from "../Error/LogicError";
import { Context, NodeParser } from "../NodeParser";
import { SubNodeParser } from "../SubNodeParser";
Expand Down
Loading

0 comments on commit f55be9f

Please sign in to comment.