Skip to content
This repository has been archived by the owner on May 31, 2022. It is now read-only.

Commit

Permalink
Add all flowtype rules
Browse files Browse the repository at this point in the history
  • Loading branch information
MoOx committed Mar 23, 2017
1 parent 7a36807 commit 98c6bae
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion __tests__/flow.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow

export function something(arg: Something): string {
export function something(arg: SomethingType): string {
return arg.blah
}
20 changes: 10 additions & 10 deletions __tests__/react-class-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
/* eslint-disable import/no-unresolved, import/no-extraneous-dependencies */
import React, { Component } from "react"

type Callback = () => void
type EventCallback = (event: SyntheticEvent) => void
type CallbackType = () => void
type EventCallbackType = (event: SyntheticEvent) => void

type Props = {
onMount?: Callback,
type PropsType = {
onMount?: CallbackType,
}

type State = {
type StateType = {
clicked: boolean,
}

class ReactClass extends Component<void, Props, State> {
props: Props;
class ReactClass extends Component<void, PropsType, StateType> {
props: PropsType;

state: State = {
state: StateType = {
clicked: false,
};

constructor(props: Props) {
constructor(props: PropsType) {
super(props)
}

Expand All @@ -31,7 +31,7 @@ class ReactClass extends Component<void, Props, State> {
}
}

handleClick: EventCallback = (event: SyntheticEvent) => {
handleClick: EventCallbackType = (event: SyntheticEvent) => {
event.preventDefault()

this.setState({ clicked: true })
Expand Down
30 changes: 30 additions & 0 deletions flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,37 @@ module.exports = {
],

rules: {
// avoid false positive eslint errors
"flowtype/define-flow-type": 2,
"flowtype/use-flow-type": 2,

"flowtype/boolean-style": 2,
"flowtype/no-dupe-keys": 2,
"flowtype/no-primitive-constructor-types": 2,
"flowtype/type-id-match": [
2,
"^([A-Z][a-z0-9]*)+Type$"
],

// too brutal
"flowtype/no-weak-types": 0,
"flowtype/require-parameter-type": 0,
"flowtype/require-return-type": 0,
"flowtype/require-valid-file-annotation": 0,
"flowtype/require-variable-type": 0,
"flowtype/sort-keys": 0,

// no styles rules (=> prettier)
"flowtype/semi": 0,
"flowtype/delimiter-dangle": 0,
"flowtype/object-type-delimiter": 0,
"flowtype/generic-spacing": 0,
"flowtype/space-after-type-colon": 0,
"flowtype/space-before-generic-bracket": 0,
"flowtype/space-before-type-colon": 0,
"flowtype/union-intersection-spacing": 0,

// deprecated
"flowtype/valid-syntax": 0,
},
}
2 changes: 1 addition & 1 deletion interfaces/Something.d.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-unused-vars */

type Something = {
type SomethingType = {
blah: string,
}

0 comments on commit 98c6bae

Please sign in to comment.