Giter VIP home page Giter VIP logo

tssa's Introduction

tssa

Build Status

TypeScript Static Analyzer

Usage

yarn add --dev @dev-sam/tssa
# In Command Line
git diff HEAD^ HEAD | yarn tssa path/1/to/ts/project/to/analyze path/2/to/ts/project/to/analyze
# Inside a GitHub Action job triggered by pull request (tssa will auto-fetch PR diff)
GITHUB_TOKEN=<token> GITHUB_PR_NUMBER=<PR number> yarn tssa path/1/to/ts/project/to/analyze path/2/to/ts/project/to/analyze

Contributing

In order for your changes to be accepted, you need to pass all the CI tests. This implies:

  • Your code compiles;
  • Your code passes Prettier and ESLint;
  • Your code passes existing tests and new tests.

You are encouraged to test your changes locally instead of waiting on CI results. You must write unit tests for your added pure functions whenever possible.

You can also test your changes on tssa itself. For example, you can create a test branch test123, do some changes in test123 and commit. Then you can run git diff master test123 | yarn start ., which will give you the diff analysis result on your change in test123. Remember that you need to run yarn build before yarn start to ensure that you are always using the latest compiled code!

What's even more important is that you test your changes against real complex monorepos. To do that, you need to run yarn bundle to produce a self-contained index.js inside bin. Then you can copy index.js into the root of the monorepo, and run the test by git diff master test123 | node index.js monorepo-package-1 monorepo-package-2 .... Note that the root of the monorepo must has typescript as either devDependency or dependency, since the bundled index.js doesn't bundle TypeScript.

tssa's People

Contributors

dependabot-preview[bot] avatar imgbot[bot] avatar meganyin13 avatar samchou19815 avatar

Stargazers

 avatar

Watchers

 avatar

tssa's Issues

Detect chained affect list and print them in a smart way

In a react project, it's not uncommon to have a pattern where:

  1. You fetched data and changed some code in ParentComponent.
  2. You need to pass the data along several layers in the component tree: ParentComponent > ChildComponent > GrandchildComponent.

As a result, you might get this highly repetitive analysis result:

GrandchildComponent.tsx:
GrandchildComponent.tsx > GrandchildComponent
ChildComponent.tsx > ChildComponent
ParentComponent.tsx > ParentComponent

ChildComponent.tsx:
ChildComponent.tsx > ChildComponent
ParentComponent.tsx > ParentComponent

ParentComponent.tsx:
ParentComponent.tsx > ParentComponent

Ideally, tssa should detect this kind of pattern, and display something smart like:

GrandchildComponent.tsx, ChildComponent.tsx, ParentComponent.tsx:
GrandchildComponent.tsx > GrandchildComponent
ChildComponent.tsx > ChildComponent
ParentComponent.tsx > ParentComponent

This detection should be done conservatively. i.e. only do it when there's a clear subset relationship between affect lists.

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.