Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
[Cleanup] Enable noUnusedLocals, remove all refs
Browse files Browse the repository at this point in the history
  • Loading branch information
damassi committed Dec 8, 2017
1 parent c83501e commit f4522b3
Show file tree
Hide file tree
Showing 135 changed files with 494 additions and 671 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,8 @@
"stylelint.additionalDocumentSelectors": ["typescript", "typescriptreact"],
"todohighlight.exclude": ["node_modules/**", ".vscode/**", "externals/**"],
"tslint.autoFixOnSave": true,
"typescript.format.enable": false
"typescript.format.enable": false,
"[json]": {
"editor.formatOnSave": false
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- QA on Inbox and Active Bids spacing - maxim
- iPad support for Active Bids - maxim
- Get rid of image view flag that would skip on-the-fly resizing - alloy
- Add noUnusedLocals / noUnusedParameters to tslint config; clean up refs in app -chris

### 1.4.0-beta.9

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "/__tests__/.*-tests.(ts|tsx|js)$",
"testPathIgnorePatterns": ["\\.snap$", "<rootDir>/node_modules/"],
"testPathIgnorePatterns": ["\\.snap$", "<rootDir>/build", "<rootDir>/node_modules/"],
"setupFiles": ["./src/setupJest.ts"],
"cacheDirectory": ".jest/cache"
},
Expand Down
25 changes: 9 additions & 16 deletions src/lib/AppRegistry.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as _ from "lodash"
import React from "react"
import { AppRegistry, View, ViewProperties } from "react-native"
import { TrackingInfo } from "react-tracking"
import { AppRegistry, View } from "react-native"

import Consignments from "./Components/Consignments"
import Containers from "./Containers/index"
Expand All @@ -12,24 +10,18 @@ import {
InboxRenderer,
InquiryRenderer,
MyProfileRenderer,
RenderCallback,
SaleRenderer,
WorksForYouRenderer,
} from "./relay/QueryRenderers"
import FavoritesScene from "./Scenes/Favorites"
import HomeScene from "./Scenes/Home"
import renderWithLoadProgress from "./utils/renderWithLoadProgress"
import { Schema, screenTrack as track, Track } from "./utils/track"

// Analytics wrapper for all of our top level React components
function AddTrack(pageName: string) {
return component => component
}
import { Schema, screenTrack as track } from "./utils/track"

interface ArtistProps {
artistID: string
isPad: boolean
}

const Artist: React.SFC<ArtistProps> = track<ArtistProps>(props => {
return {
context_screen: Schema.PageNames.ArtistPage,
Expand All @@ -38,7 +30,7 @@ const Artist: React.SFC<ArtistProps> = track<ArtistProps>(props => {
}
})(props => <ArtistRenderer {...props} render={renderWithLoadProgress(Containers.Artist, props)} />)

const Inbox: React.SFC<{}> = track<{}>(props => {
const Inbox: React.SFC<{}> = track<{}>(() => {
return { context_screen: Schema.PageNames.InboxPage, context_screen_owner_type: null }
})(props => <InboxRenderer {...props} render={renderWithLoadProgress(Containers.Inbox, props)} />)

Expand All @@ -52,10 +44,11 @@ const Gene: React.SFC<GeneProps> = ({ geneID, refineSettings: { medium, price_ra
return <GeneRenderer {...initialProps} render={renderWithLoadProgress(Containers.Gene, initialProps)} />
}

const Sale: React.SFC<{ saleID: string }> = ({ saleID }) => {
const initialProps = { saleID }
return <SaleRenderer {...initialProps} render={renderWithLoadProgress(Containers.Sale, initialProps)} />
}
// FIXME: This isn't being used
// const Sale: React.SFC<{ saleID: string }> = ({ saleID }) => {
// const initialProps = { saleID }
// return <SaleRenderer {...initialProps} render={renderWithLoadProgress(Containers.Sale, initialProps)} />
// }

// TODO: This was required to trigger the 1px wake-up hack (in case the scrollview goes blank)
//
Expand Down
15 changes: 1 addition & 14 deletions src/lib/Components/Artist/Articles/Article.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,7 @@ import fonts from "lib/data/fonts"
import SwitchBoard from "lib/NativeModules/SwitchBoard"
import ImageView from "../../OpaqueImageView"

interface Props extends ViewProperties {
article: {
href: string
author: {
name
}
thumbnail_image: {
url
}
thumbnail_title: string
}
}

class Article extends React.Component<Props, {}> {
class Article extends React.Component<RelayProps & ViewProperties> {
handleTap() {
SwitchBoard.presentNavigationViewController(this, this.props.article.href)
}
Expand Down
8 changes: 2 additions & 6 deletions src/lib/Components/Artist/Articles/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React from "react"
import React, { Component } from "react"
import { ScrollView, StyleSheet, View, ViewProperties } from "react-native"
import { createFragmentContainer, graphql } from "react-relay"

import SerifText from "../../Text/Serif"
import Article from "./Article"

interface Props extends ViewProperties {
articles: any[]
}

class Articles extends React.Component<Props, {}> {
class Articles extends Component<RelayProps & ViewProperties> {
render() {
const articles = this.props.articles
return (
Expand Down
29 changes: 7 additions & 22 deletions src/lib/Components/Artist/Artworks/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react"
import React, { Component } from "react"
import { StyleSheet, View, ViewProperties } from "react-native"
import { createFragmentContainer, graphql } from "react-relay"

Expand All @@ -19,28 +19,13 @@ interface RenderSectionParams {
mapPropsToArtworksConnection: (Props) => any
}

interface Props extends ViewProperties {
artist: {
counts: {
for_sale_artworks: number
artworks: number
}
not_for_sale_artworks: any[]
for_sale_artworks: any[]
}
relay: any
}

interface State {
completedForSaleWorks: boolean
}

class Artworks extends React.Component<Props, State> {
constructor(props) {
super(props)
this.state = {
completedForSaleWorks: false,
}
class Artworks extends Component<RelayProps & ViewProperties, State> {
state = {
completedForSaleWorks: false,
}

render() {
Expand Down Expand Up @@ -141,10 +126,10 @@ export default createFragmentContainer(
interface RelayProps {
artist: {
counts: {
artworks: boolean | number | string | null
for_sale_artworks: boolean | number | string | null
artworks: number | null
for_sale_artworks: number | null
} | null
for_sale_artworks: Array<boolean | number | string | null> | null
for_sale_artworks: Array<number | null> | null
not_for_sale_artworks: Array<boolean | number | string | null> | null
}
}
6 changes: 1 addition & 5 deletions src/lib/Components/Artist/Biography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import SerifText from "../Text/Serif"

const sideMargin = Dimensions.get("window").width > 700 ? 50 : 0

interface Props extends ViewProperties {
artist: any
}

class Biography extends React.Component<Props, any> {
class Biography extends React.Component<RelayProps & ViewProperties> {
render() {
const artist = this.props.artist
if (!artist.blurb && !artist.bio) {
Expand Down
6 changes: 4 additions & 2 deletions src/lib/Components/Artist/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { createFragmentContainer, graphql } from "react-relay"
import { Dimensions, NativeModules, StyleSheet, TextStyle, View, ViewStyle } from "react-native"
const { ARTemporaryAPIModule } = NativeModules

import Events from "lib/NativeModules/Events"

import colors from "lib/data/colors"
import InvertedButton from "../Buttons/InvertedButton"
import Headline from "../Text/Headline"
Expand Down Expand Up @@ -49,6 +47,10 @@ class Header extends React.Component<Props, State> {

componentDidMount() {
NativeModules.ARTemporaryAPIModule.followStatusForArtist(this.props.artist._id, (error, following) => {
if (error) {
// FIXME: Handle error
console.error("Artist/Header.tsx", error.message)
}
this.setState({ following })
})
}
Expand Down
18 changes: 1 addition & 17 deletions src/lib/Components/Artist/Shows/Metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,7 @@ import SerifText from "lib/Components/Text/Serif"
import colors from "lib/data/colors"
import fonts from "lib/data/fonts"

interface Props extends ViewProperties {
show: {
name: string
kind: string
exhibition_period: string
location?: {
city: string
}
status_update?: string
status: string
partner?: {
name: string
}
}
}

class Metadata extends React.Component<Props, any> {
class Metadata extends React.Component<RelayProps & ViewProperties> {
render() {
const partnerName = this.props.show.partner && this.props.show.partner.name
return (
Expand Down
10 changes: 2 additions & 8 deletions src/lib/Components/Artist/Shows/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@ import SwitchBoard from "../../../NativeModules/SwitchBoard"
import OpaqueImageView from "../../OpaqueImageView"
import Metadata from "./Metadata"

interface Props extends ViewProperties {
show: {
href: string
cover_image: {
url: string
}
}
interface Props extends RelayProps, ViewProperties {
styles?: {
container?: any
image?: any
metadata?: any
}
}

class Show extends React.Component<Props, {}> {
class Show extends React.Component<Props> {
handleTap() {
SwitchBoard.presentNavigationViewController(this, this.props.show.href)
}
Expand Down
6 changes: 1 addition & 5 deletions src/lib/Components/Artist/Shows/SmallList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ import Show from "./Show"

import colors from "lib/data/colors"

interface Props extends ViewProperties {
shows: any[]
}

interface State {
dataSource: ListViewDataSource
}

class SmallList extends React.Component<Props, State> {
class SmallList extends React.Component<RelayProps & ViewProperties, State> {
constructor(props) {
super(props)
this.state = {
Expand Down
17 changes: 6 additions & 11 deletions src/lib/Components/Artist/Shows/VariableSizeShowsList.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
import React from "react"
import React, { Component } from "react"
import { createFragmentContainer, graphql } from "react-relay"

import { LayoutChangeEvent, StyleSheet, View, ViewProperties, ViewStyle } from "react-native"

import Show from "./Show"

interface Props extends ViewProperties {
interface Props extends RelayProps, ViewProperties {
showSize: "medium" | "large"
shows: any[]
}

interface State {
width: number
height: number
}

class ShowsList extends React.Component<Props, State> {
constructor(props) {
super(props)

this.state = {
width: 1,
height: 1,
}
class ShowsList extends Component<Props, State> {
state = {
width: 1,
height: 1,
}

imageDimensions(layout) {
Expand Down
6 changes: 2 additions & 4 deletions src/lib/Components/Artist/Shows/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import React from "react"
import { createFragmentContainer, graphql } from "react-relay"

import { Dimensions, StyleSheet, TextStyle, View, ViewProperties, ViewStyle } from "react-native"
import { StyleSheet, TextStyle, View, ViewStyle } from "react-native"

import Separator from "../../Separator"
import SerifText from "../../Text/Serif"
import SmallList from "./SmallList"
import VariableSizeShowsList from "./VariableSizeShowsList"

const windowDimensions = Dimensions.get("window")

class Shows extends React.Component<RelayProps, any> {
class Shows extends React.Component<RelayProps> {
render() {
return (
<View style={styles.container}>
Expand Down
2 changes: 0 additions & 2 deletions src/lib/Components/Artist/__stories__/ArtistHeader.story.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { storiesOf } from "@storybook/react-native"
import React from "react"
import { View } from "react-native"
import { Environment, Network, RecordSource, Store } from "relay-runtime"
// import StubContainer from "react-storybooks-relay-container"

import Header from "../Header"

Expand Down
12 changes: 6 additions & 6 deletions src/lib/Components/ArtworkGrids/InfiniteScrollGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import React from "react"
import { Dimensions, LayoutChangeEvent, ScrollView, StyleSheet, View, ViewStyle } from "react-native"
import { RelayPaginationProp } from "react-relay"

import { get } from "lodash"

import Spinner from "../Spinner"
import Artwork from "./Artwork"

Expand All @@ -20,7 +18,7 @@ import { isCloseToBottom } from "lib/utils/isCloseToBottom"
import { ArtistRelayProps } from "./RelayConnections/ArtistForSaleArtworksGrid"
import { GeneRelayProps } from "./RelayConnections/GeneArtworksGrid"

export const PageSize = 10
import { PAGE_SIZE } from "lib/data/constants"

/**
* TODO:
Expand Down Expand Up @@ -110,8 +108,6 @@ class InfiniteScrollArtworksGrid extends React.Component<Props, State> {
fetchingNextPage: false,
}

private sentEndForContentLength: null | number = null

artworksConnection(): ArtworksConnection {
return this.props.mapPropsToArtworksConnection(this.props)
}
Expand All @@ -121,7 +117,11 @@ class InfiniteScrollArtworksGrid extends React.Component<Props, State> {
return
}
this.setState({ fetchingNextPage: true })
this.props.relay.loadMore(PageSize, error => {
this.props.relay.loadMore(PAGE_SIZE, error => {
if (error) {
// FIXME: Handle error
console.error("InfiniteScrollGrid.tsx", error.message)
}
this.setState({ fetchingNextPage: false })
if (!this.artworksConnection().pageInfo.hasNextPage && this.props.onComplete) {
this.props.onComplete()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createPaginationContainer, graphql } from "react-relay"
import InfiniteScrollArtworksGrid, { PageSize } from "../InfiniteScrollGrid"
import InfiniteScrollArtworksGrid from "../InfiniteScrollGrid"

import Artwork from "../Artwork"
// tslint:disable-next-line:no-unused-expression
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createPaginationContainer, graphql } from "react-relay"
import InfiniteScrollArtworksGrid, { PageSize } from "../InfiniteScrollGrid"
import InfiniteScrollArtworksGrid from "../InfiniteScrollGrid"

import Artwork from "../Artwork"
// tslint:disable-next-line:no-unused-expression
Expand Down
Loading

0 comments on commit f4522b3

Please sign in to comment.