-
Notifications
You must be signed in to change notification settings - Fork 78
[Cleanup] Enable noUnusedLocals/Parameters and remove all refs #877
Conversation
"typescript.format.enable": false | ||
"typescript.format.enable": false, | ||
"[json]": { | ||
"editor.formatOnSave": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For whatever reason, rules like "require trailing comma" would auto-fix in .json
files making it impossible to produce correct JSON.
src/lib/AppRegistry.tsx
Outdated
|
||
// FIXME: This isnt being used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some of the more ambiguous "WIP?" areas I've commented out and added a note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can go, the root component decorator is called screenTrack.
} | null | ||
} | ||
} | ||
// FIXME: This is being unused in code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were many instances of there being a interface Props { ... }
at the top of the file that had the exact same props as interface RelayProps { ... }
at the bottom of the file, though at the top it typically lacked | null
. Why is this? In most instances they're nearly identical so why is one not being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RelayProps were being auto generated. I guess someone didn’t realize these existed and manually added them to Props rather than extending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RelayProps that add null are more correct, though.
2e65561
to
780b468
Compare
"plugins": [{ "name": "typescript-styled-plugin" }], | ||
"baseUrl": "src" | ||
"target": "es6", | ||
"types": ["jest", "react", "react-native"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just alpha + addition of noUnusedLocals
and noUnusedParameters
@@ -5,10 +5,11 @@ | |||
"interface-name": [true, "never-prefix"], | |||
"max-classes-per-file": [false], | |||
"member-access": [false, "check-accessor", "check-constructor"], | |||
"no-console": [true, ["error", ["warn", "error"]]], | |||
"no-unused-variable": [true, { "ignore-pattern": "^_" }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alpha + added the ability to ignore variables via _
, similar to TypeScript compiler. This combined with new TypeScript setting worked well as TSLint seemed to not check anything but parameters once the TypeScript settings were introduced.
(See palantir/tslint#1618 for related info.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
780b468
to
d6c64f6
Compare
bb4210d
to
0b1d05b
Compare
@@ -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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw PAGE_SIZE
being repeated all over so added this new constants file here (unless there's a better location)
const filename = file.split(/\//g).pop() | ||
|
||
// FIXME: This is being unused in 103; does this uploader work? | ||
// const filename = file.split(/\//g).pop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird, check out https://github.com/artsy/emission/pull/877/files#diff-1e4221a2b438a2ae235d95aff0c14c71L103 (a few lines down from here)
key: geminiKey + "/${filename}",
Is the uploader even working? Should have backticks for interpolation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it is weird, but that's actually what it expects ( this is the web version of this code: https://github.com/artsy/gemup/blob/master/gemup.js#L44 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff thus far @damassi, much appreciated! 👏
src/lib/AppRegistry.tsx
Outdated
@@ -38,7 +35,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<{}>(_props => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just () => { ... }
?
// const Sale: React.SFC<{ saleID: string }> = ({ saleID }) => { | ||
// const initialProps = { saleID } | ||
// return <SaleRenderer {...initialProps} render={renderWithLoadProgress(Containers.Sale, initialProps)} /> | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the sale view is a WIP that @ashfurrow works on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After talking with ash confirmed this is on hold for the time being but will leave it around for now
} | null | ||
} | ||
} | ||
// FIXME: This is being unused in code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RelayProps were being auto generated. I guess someone didn’t realize these existed and manually added them to Props rather than extending.
} | null | ||
} | ||
} | ||
// FIXME: This is being unused in code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RelayProps that add null are more correct, though.
const isPadHorizontal = Dimensions.get("window").height > 700 | ||
|
||
// TODO: Reenable when used | ||
// const isPadHorizontal = Dimensions.get("window").height > 700 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just remove for now?
src/lib/Containers/Conversation.tsx
Outdated
// tslint:disable-next-line:no-var-requires | ||
const chevron: ImageURISource = require("../../../images/horizontal_chevron.png") | ||
// const chevron: ImageURISource = require("../../../images/horizontal_chevron.png") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this simply be removed?
@@ -5,10 +5,11 @@ | |||
"interface-name": [true, "never-prefix"], | |||
"max-classes-per-file": [false], | |||
"member-access": [false, "check-accessor", "check-constructor"], | |||
"no-console": [true, ["error", ["warn", "error"]]], | |||
"no-unused-variable": [true, { "ignore-pattern": "^_" }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
170eb16
to
36d3028
Compare
36d3028
to
d414e22
Compare
d414e22
to
4daaa56
Compare
Ok addressed all feedback and re-added |
4daaa56
to
3a60e0a
Compare
3a60e0a
to
5e0b8db
Compare
@@ -5,11 +5,11 @@ import { createFragmentContainer, graphql } from "react-relay" | |||
import SerifText from "../../Text/Serif" | |||
import Article from "./Article" | |||
|
|||
interface Props extends ViewProperties { | |||
interface Props extends RelayProps, ViewProperties { | |||
articles: any[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prop is overriding the actual one from RelayProps
.
not_for_sale_artworks: any[] | ||
for_sale_artworks: any[] | ||
} | ||
interface Props extends RelayProps, ViewProperties { | ||
relay: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t believe this prop is actually used in this module, but if it is then maybe pull in the appropriate typing from react-relay
?
@@ -5,7 +5,7 @@ import { LayoutChangeEvent, StyleSheet, View, ViewProperties, ViewStyle } from " | |||
|
|||
import Show from "./Show" | |||
|
|||
interface Props extends ViewProperties { | |||
interface Props extends RelayProps, ViewProperties { | |||
showSize: "medium" | "large" | |||
shows: any[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is overriding the actual typing from RelayProps
.
// } | ||
interface RelayProps { | ||
artist: { | ||
__id: string | null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prop is not being requested by the fragment, so shouldn’t be here.
5e0b8db
to
d8169b5
Compare
f4522b3
to
0a2dbef
Compare
0a2dbef
to
5430b7d
Compare
} | ||
|
||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alloy - after fixing my typechecker and eliminating some of those top-of-the file Props overrides things got a little stricter and this one was interesting to try to understand...
If you look here and here (this components child) and notice the types, they both say
boolean | number | string | null
Since they're both cast to any of four types the compiler can't make basic inferences, right? And so casting it explicitly above set it through the whole chain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you’re code is correct. Because this value could be of a non number type (according to the typing at least), TS will complain that you can’t just subtract. Casting as a subtype, that is, one of the types in this union allows you to do so.
I don’t recall exactly why these typings are a union like that. Is the field a custom GraphQL scalar? If so, iirc those are indeed not very specific :(
5430b7d
to
d28dbab
Compare
d28dbab
to
6dfaa78
Compare
All looks good to me. Great work! Merge when you think it’s good to go 👍 |
One thing I noticed when I first started working in Emission was all of the unused variables and imports. There's a TSLint rule available, but since the check occurs in TypeScript it never gets fired. This PR enables
noUnusedLocals
andnoUnusedParameters
in tsconfig.json and sweeps through the code.While making edits I also found handful of unguarded error code for which I entered
console.error
s andFIXME: Handle error
notes.Skip New Tests
There are a couple questions which I've noted inline.