GithubHelp home page GithubHelp logo

withspectrum / danger-plugin-flow Goto Github PK

View Code? Open in Web Editor NEW
21.0 3.0 10.0 417 KB

Ensure all JS files that get touched in a PR are flow typed

License: MIT License

TypeScript 74.03% JavaScript 25.97%
danger danger-plugin

danger-plugin-flow's Introduction

danger-plugin-flow

Build Status npm version

Ensure all new .js files in a project are flow typed

Usage

Install:

yarn add danger-plugin-flow --dev

At a glance:

// dangerfile.js
import { schedule } from 'danger'
import flow from 'danger-plugin-flow'

schedule(flow());

Options

Recommended setup:

schedule(flow({
  modified: "warn",
  created: "fail"
}))

This will fail the build for any newly introduced file that isn't flow typed, but will only warn the developer if they touch a file that's not flow typed. This is what we use because it can be hard to type legacy code, but we want to ensure every newly incoming code is properly typed.

blacklist

Blacklist certain globs from being checked:

schedule(flow({
  blacklist: ['dist/**/*.js']
}))

created

Decide whether you want to warn, fail or ignore newly created files that are untyped:

schedule(flow({
  created: "warn"
}))

schedule(flow({
  created: "fail"
}))

schedule(flow({
  created: false
}))

modified

Decide whether you want to warn, fail or ignore modified files that are untyped:

schedule(flow({
  modified: "warn"
}))

schedule(flow({
  modified: "fail"
}))

schedule(flow({
  modified: false
}))

Changelog

See the GitHub release history.

Contributing

See CONTRIBUTING.md.

danger-plugin-flow's People

Contributors

brianlovin avatar depfu[bot] avatar jakubzitny avatar kevinsuttle avatar mxstbr avatar ryota-murakami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

danger-plugin-flow's Issues

use Travis

There is a sad unknown build badge in README that can be easily fixed by toggling Travis builds for this repo and adding a .travis.yml :)

Post flow errors in comment

It'd be great if this plugin took the JSON output from a flow run and posted it in the comment, similar to what danger-plugin-jest does with the test failures.

Support danger local

Currently, danger-plugin-flow is locked to GitHub, because it uses danger.github object for getting the contents of changed files.

It would be cool to generalize this to danger local run (which will ensure it works for other services and unsupported CIs (e.g. GitLab) as well).

Support for Bitbucket Server

It seems this plugin does not work for Bitbucket Server (depends on Github or local running), any plans for adding that or would a PR for it be accepted?
(Relates to #38 I guess)

Ensure nothing is explicitly typed as "any"

While Flow has its linter, which has a setting that nothing can be typed as "any", that's unfortunately not very applicable in the real-world as you'll encounter tons of dependencies that are untyped and it's simply not feasible to type them all.

Instead, this plugin should check and make sure that nothing is explicitly typed as any in the code. (maybe also include Object since it's too generic?)

Respect max_header_tokens option

Ref #4, thanks to @iamdustan who correctly pointed out that we should respect the max_header_tokens options of the .flowconfig.

Something like

const flowconfig = await danger.github.utils.fileContents('.flowconfig')
// TODO: Figure out how to parse .flowconfig somehow (why isn't it JSON ugh)

Better pragma detection

Right now this plugin basically just checks that the string @flow exists anywhere in the file. Instead of doing that we should be using the same logic Flow uses internally to determine whether to check a file or not.

/cc @calebmer is there a list of rules/heuristics that Flow uses to determine whether to include a file or not?

Needs new release

The latest code isn't released on NPM. I need it for support of the local platform.

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.