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 6dfaa78
Show file tree
Hide file tree
Showing 137 changed files with 517 additions and 681 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
10 changes: 3 additions & 7 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 All @@ -21,7 +17,7 @@ class Articles extends React.Component<Props, {}> {
scrollsToTop={false}
style={{ overflow: "visible", marginBottom: 40 }}
>
{articles.map(article => <Article key={article.__id} article={article} style={styles.article} />)}
{articles.map(article => <Article key={article.__id} article={article as any} style={styles.article} />)}
</ScrollView>
</View>
)
Expand Down
29 changes: 8 additions & 21 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,33 +19,22 @@ 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 Props extends RelayProps, ViewProperties {
relay?: RelayProps
}

interface State {
completedForSaleWorks: boolean
}

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

render() {
const forSaleCount = this.props.artist.counts.for_sale_artworks
const otherCount = this.props.artist.counts.artworks - forSaleCount
const otherCount = (this.props.artist.counts.artworks as number) - (forSaleCount as number)
if (forSaleCount === 0) {
return this.renderSection({
title: "Works",
Expand Down Expand Up @@ -75,7 +64,7 @@ class Artworks extends React.Component<Props, State> {
<View style={styles.section}>
{this.renderSection({
title: "Works for Sale",
count: forSaleCount,
count: forSaleCount as number,
filter: "IS_FOR_SALE",
onComplete: () => this.setState({ completedForSaleWorks: true }),
Component: ArtistForSaleArtworksGrid,
Expand Down Expand Up @@ -144,7 +133,5 @@ interface RelayProps {
artworks: boolean | number | string | null
for_sale_artworks: boolean | number | string | null
} | null
for_sale_artworks: Array<boolean | number | string | 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
11 changes: 5 additions & 6 deletions src/lib/Components/Artist/Shows/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import React from "react"
import { StyleSheet, TextStyle, View, ViewStyle } from "react-native"
import { createFragmentContainer, graphql } from "react-relay"

import { Dimensions, StyleSheet, TextStyle, View, ViewProperties, 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 Expand Up @@ -98,6 +95,8 @@ interface RelayProps {
current_shows: Array<boolean | number | string | null> | null
upcoming_shows: Array<boolean | number | string | null> | null
past_small_shows: Array<boolean | number | string | null> | null
past_large_shows: Array<boolean | number | string | null> | null
past_large_shows: Array<{
__id: string | null
}> | null
}
}
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
2 changes: 1 addition & 1 deletion src/lib/Components/Artist/__tests__/Artworks-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ it("renders properly", () => {
for_sale_artworks: 2,
},
}
const artworks = renderer.create(<Artworks artist={artist} />).toJSON()
const artworks = renderer.create(<Artworks artist={artist as any} />).toJSON()
expect(artworks).toMatchSnapshot()
})
Loading

0 comments on commit 6dfaa78

Please sign in to comment.