Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow type components #235

Merged
merged 19 commits into from
Aug 28, 2018
Merged

Flow type components #235

merged 19 commits into from
Aug 28, 2018

Conversation

landonreed
Copy link
Member

@landonreed landonreed commented Aug 21, 2018

Add flow typing to library (nearly) all components. Notable components this avoids are some of the modal components, which need to be refactored altogether because they rely heavily on refs and accept state/props through their open method, and the Settings components, which should see a refactor in #41.

This PR raises the flow coverage to a semi-respectable 76%.

@landonreed landonreed requested a review from evansiroky August 21, 2018 17:02
@codecov-io
Copy link

codecov-io commented Aug 21, 2018

Codecov Report

Merging #235 into dev will decrease coverage by 0.05%.
The diff coverage is 0.38%.

Impacted file tree graph

@@           Coverage Diff            @@
##             dev    #235      +/-   ##
========================================
- Coverage    3.6%   3.55%   -0.06%     
========================================
  Files        327     325       -2     
  Lines      11839   12035     +196     
  Branches    4202    4297      +95     
========================================
+ Hits         427     428       +1     
- Misses      9373    9526     +153     
- Partials    2039    2081      +42
Impacted Files Coverage Δ
lib/editor/reducers/index.js 0% <ø> (ø) ⬆️
lib/admin/reducers/organizations.js 27.77% <ø> (ø) ⬆️
lib/editor/reducers/settings.js 29.41% <ø> (ø) ⬆️
lib/alerts/reducers/alerts.js 10.95% <ø> (ø) ⬆️
lib/editor/reducers/mapState.js 28.57% <ø> (ø) ⬆️
lib/signs/containers/ActiveSignEditor.js 0% <ø> (ø) ⬆️
lib/manager/containers/ActiveFeedSourceViewer.js 0% <ø> (ø) ⬆️
lib/manager/actions/status.js 0% <ø> (ø) ⬆️
lib/manager/components/ProjectsList.js 0% <ø> (ø) ⬆️
lib/editor/util/map.js 10% <ø> (ø) ⬆️
... and 168 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9ccc70...17fd1cf. Read the comment docs.

@@ -86,36 +111,39 @@ export default class AffectedServices extends Component {
}
}

class ServicesHeader extends Component {
class ServicesHeader extends Component<{entities: Array<any>}> {
Copy link

@evansiroky evansiroky Aug 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Array<AlertEntity> instead? Seems like that would then negate the need for typing within each filter function.

this.setState({rectangle: e.layer})
// To edit this polyline call : polyline.handler.enable()
console.log('Path created !', polyline)
// _onCreate (e) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we still need this even with comments, please indicate why and perhaps create a github issue.

@@ -194,6 +194,7 @@ class Auth0Manager {
// Get profile with access token and return profile and ID token to store.
return this._getProfileFromToken(accessToken)
.then(profile => {
console.log(profile)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@@ -116,7 +116,7 @@ export function setActiveGtfsEntity (
const {locationBeforeTransitions} = getState().routing
const pathname = locationBeforeTransitions && locationBeforeTransitions.pathname
if (!locationBeforeTransitions || !pathname || pathname !== url) {
// console.log('updating url', url, pathname)
console.log('updating url', url, pathname)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

selectValue,
style,
valueArray
}: any) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elaborate a bit on this type


_onContainsChange = (input) => {
export default class FareRuleSelections extends Component<Props> {
_onContainsChange = (input: any) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please elaborate a bit on the types of these change functions

handleControlPointDrag: () => void,
handleControlPointDragEnd: () => void,
handleControlPointDragStart: () => void,
setActivePatternSegment: () => void,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's alphabetize these. Try using this plugin.

mapState: MapState,
feedSource: Feed,
feedInfo: FeedInfo,
zoomToTarget: ?number,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please alphabetize this.

}
}
}
// if (activeComponent === 'stop') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining why this code is being kept.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove the code entirely. The click to select stop functionality was essentially completely hidden from users and not entirely reliable or necessary.

<ControlPointsLayer
activePattern={activePattern}
activePattern={this.props.activePattern}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please destructure out all these props.

activeEntity={this.props.activeEntity}
activePattern={this.props.activePattern}
activePatternId={this.props.activePatternId}
activePatternTripCount={this.props.activePatternTripCount}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please destructure

isSelected: boolean,
lightText: boolean,
onChange: (any, number, TimetableColumn, number) => void,
renderTime: boolean,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please alphabetize

setOffset: number => void,
showHelpModal: () => void,
timetable: TimetableState,
columns: Array<TimetableColumn>,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetize

feedSource: Feed,
fetchTripsForCalendar: (string, Pattern, string) => void,
offsetRows: ({rowIndexes: Array<any>, offset: number}) => void,
saveTripsForCalendar: (string, Pattern, string, Array<Trip>) => void,
setActiveEntity: (string, string, any) => void,
setActiveCell: ?string => void,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetize

@@ -278,15 +303,15 @@ export default class TimetableGrid extends Component {
}
}

_renderLeftHeaderCell = ({ columnIndex, key, rowIndex, style }) => (
_renderLeftHeaderCell = ({ columnIndex, key, rowIndex, style }: { columnIndex: number, key: string, rowIndex: number, style: Style}) => (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's unwrap these to be more readable

setOffset: number => void,
offsetWithDefaults: (boolean) => void,
toggleDepartureTimes: () => void,
addNewRow: (?boolean, ?boolean) => void,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetize

gtfsEntitySelected: (string, Entity) => void,
getGtfsEntity: (string, string) => Entity,
newRowsDisplayed: Array<any> => void,
pageCount: number,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetize

updateFeedSource: (Feed, any) => void,
saveFeedSource: (any) => void,
onHover: (?Feed) => void,
active: boolean,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetize

Copy link

@evansiroky evansiroky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of great work here. I think we should enable this eslint rule: https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-sort-keys That way we can quickly alphabetize all these type definitions.

@landonreed
Copy link
Member Author

OK, @evansiroky. I've addressed all of your comments. Good to merge?

Copy link

@evansiroky evansiroky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work and let's keep up the trend of keeping the e2e tests passing!

@landonreed landonreed merged commit 9dca466 into dev Aug 28, 2018
@landonreed landonreed deleted the flow-type-components branch August 28, 2018 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants