Skip to content

Commit

Permalink
Use the correct type inplace any where applicable (#1533)
Browse files Browse the repository at this point in the history
* Add the @typescript-eslint no-explicit-any rule to eslint

* Add lint script to package.json file

* Add public to eslint ignore file

* Run lint, fix existing any type errors and the other type errors

* Remove the @typescript-eslint/no-explicit-any type rule from eslint

* Remove the lint script from package.json file

* remove eslint exceptions and revert unknown to any type

Co-authored-by: Phil Leggetter <[email protected]>
  • Loading branch information
chidexebere and leggetter authored Aug 27, 2021
1 parent f1960e7 commit b7bbefc
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
gatsby/
gatsby*
mdxImportGen.js
mdxImportGen.js
public
3 changes: 3 additions & 0 deletions plugins/gasby-remark-lazy-imgix/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */
// eslint-disable-next-line no-redeclare
/* global __dirname, require, module */

const visit = require('unist-util-visit')
const imageSize = require(`probe-image-size`)
const fs = require(`fs-extra`)
Expand Down
2 changes: 1 addition & 1 deletion src/components/AnchorScrollNavbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ButtonLink = ({
}: {
section: string
currentSection: string
children: any
children: React.ReactNode
}) => {
const baseClasses = 'px-3 py-2 rounded'
const classList =
Expand Down
2 changes: 1 addition & 1 deletion src/components/Blog/BlogPostLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { BlogIntro } from '../BlogIntro'

interface BlogPostLayoutProps {
pageTitle: string
children: any
children: React.ReactNode
featuredImage?: string | null | undefined
featuredImageType?: string
blogArticleSlug: string
Expand Down
2 changes: 1 addition & 1 deletion src/components/CallToAction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface CallToActionProps {
type?: string
icon?: string
iconBg?: string
children: any
children: React.ReactNode
width?: string
href?: string
to?: string
Expand Down
2 changes: 1 addition & 1 deletion src/components/Careers/InterviewProcess/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import offerImg from './images/offer.svg'
interface InterviewStepProps {
image: string
title: string
children: any
children: React.ReactNode
titleColor: string
className?: string
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Careers/Transparency/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import feedbackImg from './images/feedback.svg'
interface TransparencyFeatureProps {
image: string
title: string
children: any
children: React.ReactNode
titleColor: string
className?: string
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/CodeBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const CodeBlock = (props: CodeBlockProps) => {
setProjectName(getCookie('ph_current_project_name') || '')
const phToken = getCookie('ph_current_project_token')
if (phToken) {
let updatedCode = props.children.props.children
const updatedCode = props.children.props.children
.trim()
.replace(/<ph_project_api_key>/g, phToken)
.replace(/<ph_instance_address>/g, 'https://app.posthog.com')
Expand Down Expand Up @@ -71,7 +71,7 @@ export const CodeBlock = (props: CodeBlockProps) => {
)
const tokenHighlightHtml = `<span class='code-block-ph-token' data-tooltip='This is the API key of your ${projectName} project in PostHog Cloud.'>${token}</span>`
const tokenMatchRegex = new RegExp(token, 'g')
let snapshotIndex = 0
const snapshotIndex = 0
let node: HTMLElement | null = phTokenElements.snapshotItem(snapshotIndex) as HTMLElement
while (node) {
node.innerHTML = node.innerHTML.replace(tokenMatchRegex, tokenHighlightHtml)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Container/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface ContainerProps {
onPostPage: boolean
className: string
containerStyle?: any
children: any
children: React.ReactNode
}

export const Container = ({ onPostPage, className, containerStyle = {}, children }: ContainerProps) => {
Expand Down
9 changes: 8 additions & 1 deletion src/components/ContributorCard/emojiKey.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
export const emojiKey: Record<string, any> = {
interface EmojiKeyInterface {
[key: string]: {
symbol: string
description: string
}
}

export const emojiKey: EmojiKeyInterface = {
a11y: {
symbol: '️️️️♿️',
description: 'Accessibility',
Expand Down
6 changes: 3 additions & 3 deletions src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { mergeClassList } from '../../lib/utils'
interface FooterListItemProps {
to?: string
href?: string
children: any
children: React.ReactNode
border?: boolean
}

Expand All @@ -27,11 +27,11 @@ const FooterListItem = ({ to = '', border = true, href = '', children }: FooterL
)
}

const FooterSubCategory = ({ children }: { children: any }) => (
const FooterSubCategory = ({ children }: { children: React.ReactNode }) => (
<header className="block text-white mt-8 mb-2 font-bold text-sm">{children}</header>
)

const FooterCategory = ({ children, title }: { children: any; title: string }) => {
const FooterCategory = ({ children, title }: { children: React.ReactNode; title: string }) => {
const [expanded, setExpanded] = useState(false)

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Sprites from './Sprites'
import Link from '../Link'
import AnimatedBurger from '../AnimatedBurger'

const PrimaryCta = ({ children, className = '' }: { children: any; className?: string }) => {
const PrimaryCta = ({ children, className = '' }: { children: React.ReactNode; className?: string }) => {
const classList = `button-primary ${className} border-none px-4 py-2 ml-2 lg:ml-4 mt-4 lg:mt-0 transition-none hover:transition-none text-xs rounded-sm`

return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/HiddenSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import './style.scss'

interface HiddenSectionProps {
headingType: Heading
title: any
children: any
title: string
children: React.ReactNode
endWithDivider?: boolean
defaultIsOpen?: boolean
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface LayoutProps {
isDocsPage?: boolean
isHomePage?: boolean
blogArticleSlug?: string
children?: any
children?: React.ReactNode
className?: string
containerStyle?: Record<string, any>
menuActiveKey?: string
Expand Down
7 changes: 6 additions & 1 deletion src/components/LibraryStats/libraries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export const librariesList: Record<string, any>[] = [
interface LibrariesListInterface {
name: string
path: string
}

export const librariesList: LibrariesListInterface[] = [
{
name: 'JavaScript',
path: 'PostHog/posthog-js',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Structure/SectionFullWidth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const SectionFullWidth = ({
}: {
className?: string
width?: string
children?: any
children?: React.ReactNode
}) => {
const baseClasses = `max-w-${width} mx-auto`
const classList = mergeClassList(baseClasses, className)
Expand Down
2 changes: 1 addition & 1 deletion src/components/seo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useStaticQuery, graphql } from 'gatsby'
interface SEOProps {
title: string
description?: string
image?: any
image?: string
article?: boolean
canonicalUrl?: string
}
Expand Down
4 changes: 2 additions & 2 deletions src/custom.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
declare module '*.svg' {
const content: any
const content: React.HTMLImageElement
export default content
}
declare module '*.png' {
const content: any
const content: React.HTMLImageElement
export default content
}

0 comments on commit b7bbefc

Please sign in to comment.