Skip to content

Commit

Permalink
build: lint for unused exports (Uniswap#5513)
Browse files Browse the repository at this point in the history
* build: fail on unused exports

* fix

* dedupe

* add unused export to test

* fix

* some fixes

* unused

* rm unresolved

* add .eslintignore

* rm

* unused modal

* unused useragent
  • Loading branch information
vm authored Dec 5, 2022
1 parent e15ccc3 commit 6bc9836
Show file tree
Hide file tree
Showing 11 changed files with 262 additions and 455 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.config.ts
*.d.ts
16 changes: 13 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
"settings": {
"react": {
"version": "detect"
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
}
}
},
"ignorePatterns": [
Expand Down Expand Up @@ -38,10 +46,12 @@
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
"plugin:import/typescript"
],
"plugins": ["simple-import-sort", "unused-imports"],
"plugins": ["import", "simple-import-sort", "unused-imports"],
"rules": {
"import/no-unused-modules": [2, { "unusedExports": true }],
"unused-imports/no-unused-imports": "error",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
Expand All @@ -52,7 +62,7 @@
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"react/react-in-jsx-scope": "off",
"react/jsx-curly-brace-presence": ["error", {"props": "never", "children": "never" }],
"react/jsx-curly-brace-presence": ["error", { "props": "never", "children": "never" }],
"object-shorthand": ["error", "always"],
"no-restricted-imports": [
"error",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@
"env-cmd": "^10.1.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.11.0",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-better-styled-components": "^1.1.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.6.0",
Expand Down
230 changes: 0 additions & 230 deletions src/components/claim/ClaimModal.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/graphql/data/TopTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ const tokenSparklineQuery = graphql`
}
`

export type PrefetchedTopToken = NonNullable<TopTokens100Query['response']['topTokens']>[number]

function useSortedTokens(tokens: NonNullable<TopTokens100Query['response']['topTokens']>) {
const sortMethod = useAtomValue(sortMethodAtom)
const sortAscending = useAtomValue(sortAscendingAtom)
Expand Down
2 changes: 1 addition & 1 deletion src/state/claim/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function fetchClaim(account: string): Promise<UserClaimData> {

// parse distributorContract blob and detect if user has claim data
// null means we know it does not
export function useUserClaimData(account: string | null | undefined): UserClaimData | null {
function useUserClaimData(account: string | null | undefined): UserClaimData | null {
const { chainId } = useWeb3React()

const [claimInfo, setClaimInfo] = useState<{ [account: string]: UserClaimData | null }>({})
Expand Down
20 changes: 0 additions & 20 deletions src/state/transactions/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,3 @@ export function useHasPendingApproval(token?: Token, spender?: string): boolean
[allTransactions, spender, token?.address]
)
}

// watch for submissions to claim
// return null if not done loading, return undefined if not found
export function useUserHasSubmittedClaim(account?: string): {
claimSubmitted: boolean
claimTxn: TransactionDetails | undefined
} {
const allTransactions = useAllTransactions()

// get the txn if it has been submitted
const claimTxn = useMemo(() => {
const txnIndex = Object.keys(allTransactions).find((hash) => {
const tx = allTransactions[hash]
return tx.info.type === TransactionType.CLAIM && tx.info.recipient === account
})
return txnIndex && allTransactions[txnIndex] ? allTransactions[txnIndex] : undefined
}, [account, allTransactions])

return { claimSubmitted: Boolean(claimTxn), claimTxn }
}
4 changes: 0 additions & 4 deletions src/state/user/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ const userSlice = createSlice({
updateHideClosedPositions(state, action) {
state.userHideClosedPositions = action.payload.userHideClosedPositions
},
updateShowSurveyPopup(state, action) {
state.showSurveyPopup = action.payload.showSurveyPopup
},
updateHideNFTWelcomeModal(state, action) {
state.hideNFTWelcomeModal = action.payload.hideNFTWelcomeModal
},
Expand Down Expand Up @@ -189,7 +186,6 @@ export const {
addSerializedToken,
updateHideClosedPositions,
updateMatchesDarkMode,
updateShowSurveyPopup,
updateUserClientSideRouter,
updateHideNFTWelcomeModal,
updateUserDarkMode,
Expand Down
2 changes: 1 addition & 1 deletion src/theme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function getSettings(darkMode: boolean) {
}
}

export function getTheme(darkMode: boolean) {
function getTheme(darkMode: boolean) {
return {
darkMode,
...(darkMode ? darkTheme : lightTheme),
Expand Down
2 changes: 0 additions & 2 deletions src/utils/userAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ import { UAParser } from 'ua-parser-js'
const parser = new UAParser(window.navigator.userAgent)
const { type } = parser.getDevice()

export const userAgent = parser.getResult()

export const isMobile = type === 'mobile' || type === 'tablet'
Loading

0 comments on commit 6bc9836

Please sign in to comment.