Coder Social home page Coder Social logo

typescript-schema-generator / typescript-schema-generator Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 211 KB

An extendable generator for TypeScript schemas.

TypeScript 99.84% JavaScript 0.16%
typescript code-generator nx open-api open-api-v3 open-api-v2

typescript-schema-generator's Introduction

TypeScript Schema Generator

License: MIT Codacy Badge

Typescript Schema Generator logo

The core package of this mono repository is responsible for rendering TypeScript types and therefore entire schemas.

Development Prerequisites

  • Make sure you have the Node.js runtime installed.
  • Make sure you are using Node.js version 18. A simple way to switch versions is with the npm package n.
npm install --global n
sudo n 18

typescript-schema-generator's People

Contributors

cemyil03 avatar

typescript-schema-generator's Issues

Setup EditorConfig

EditorConfig documentation
Add editorconfig.editorconfig to .vscode/extensions.json

Default

# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false

Transition to ESM

Aside from the serve / watch command, Jest seems to be the thing making the biggest issues.

ts-jest-resolver ad a dev dependency helped, but the serve command made issues.

export default {
    displayName: 'core',
    preset: '../../jest.preset.js',
    resolver: 'ts-jest-resolver', // <--This helped
    testEnvironment: 'node',
    transform: {
        '^.+\\.[tj]s?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
    },
    moduleFileExtensions: ['ts', 'js'],
    coverageDirectory: '../../coverage/packages/core',
};

Setup nx mono repository

Nx doucmentation
To scaffold a nx workspace of the latest version run npx create-nx-workspace@latest.
Implicitly this also defines the usage of npm instead of yarn.
Choose the option for an Integrated monorepo.
Add @nrwl/node dependecy to the repository.

To .vscode/extensions.json add

  • davidanson.vscode-markdownlint for linting of markdown files

package.json

"name": "@typescript-schema-generator/typescript-schema-generator",
"repository": {
   "type": "git",
   "url": "https://github.com/typescript-schema-generator/typescript-schema-generator.git"
},
"bugs": {
   "url": "https://github.com/typescript-schema-generator/typescript-schema-generator/issues"
},

Setup nx open api v3 package

nx g @nrwl/node:lib open-api-v3 --buildable --publishable --importPath=@typescript-schema-generator/open-api-v3

Add prettier auto import organisation

Just install the development dependency prettier-plugin-organize-imports, prettier should pick it up automatically.

npm i -D prettier-plugin-organize-imports

Setup nx open api v2 package

nx g @nrwl/node:lib open-api-v2 --buildable --publishable --importPath=@typescript-schema-generator/open-api-v2

Setup nx core package

nx g @nrwl/node:lib core --buildable --publishable --importPath=@typescript-schema-generator/core

Setup Prettier

Prettier documentation
Add esbenp.prettier-vscode to .vscode/extensions.json

Also the following scripts, one for detecting violations and one for also tring to automatically fix them.

"format": "prettier --write .",
"format:check": "prettier --check .",

.prettierignore

# Add files here to ignore them from prettier formatting
/dist
/coverage

.prettierrc.json

Setup ESLint

ESLint documentation
Add dbaeumer.vscode-eslint to .vscode/extensions.json

Integrate with prettier by using eslint-config-prettier and eslint-plugin-prettier

npm i -D eslint eslint-config-prettier eslint-plugin-prettier @typescript-eslint/eslint-plugin @typescript-eslint/parser

package.json

   "lint": "eslint . --ext js,cjs,mjs,ts,cts,mts --fix",
   "lint:check": "eslint . --ext js,cjs,mjs,ts,cts,mts",

Forbid yarn

Create .npmrc file with engine-strict = true.
In the package.json set

"engines": {
   "yarn": "please-use-npm",
}

Setup Codacy

Setup cspell

CSpell documentation

npm i -D cspell

Create a .cspell.json.
Add streetsidesoftware.code-spell-checker to .vscode/extensions.json
Add a script "spell:check": "cspell ." to package.json

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.