Git Product home page Git Product logo

express-ts-base's Introduction

Base REST

A project made for the free _Building a Node.js/TypeScript REST API.

This branch contains some setup for linting and prettifying code that is outside the scope of the series.

In addition to the inclusion of .eslintrc.json and .prettierrc files, some development dependencies were added to package.json, namely @typescript-eslint/eslint-plugin eslint-plugin-mocha eslint-plugin-prettier eslint-config-prettier.

You likely have to npm i -g prettier as well.

From here (after running npm i) there are two things you can do.

One-time Prettification

For this, you can go to the project root, and run:

find . -name '*.js' -or -name '*.ts' | grep -v .history | grep -v dist | grep -v node_modules | xargs prettier --write --single-quote

Continuous Prettification and Linting

In this scenario, whenever you save a file in VSCode (or VSCodium) that you were working on, it automatically runs Prettier and ESLint on it.

To set it up, find your settings.json file (e.g., ~/.config/VSCodium/User/settings.json) and add these lines to it:

  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true,
  "eslint.validate": ["typescript", "javascript"]

With that, try making some changes to the project, like adding a line const neverused =1;. If all went well, Prettier will reformat your code for you, and ESLint will generate warnings in the Problems pane about the unused variable neverused.


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.