Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing master lint #3640

Merged
merged 11 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn format-staged && yarn lint-staged
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"link-check": "repo-link-check -c config/link-check/config.yml",
"link-check-diff": "repo-link-check -c config/link-check/config.yml -d master",
"link-check-dev-server": "repo-link-check -c config/link-check/config.yml -r http://localhost:3000",
"link-check-exclude": "repo-link-check -c config/link-check/config.yml --unused-patterns-only"
"link-check-exclude": "repo-link-check -c config/link-check/config.yml --unused-patterns-only",
"prepare": "husky install"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Husky works different after v8! See husky docs

},
"repository": {
"type": "git",
Expand Down Expand Up @@ -111,7 +112,6 @@
"@types/react-instantsearch-dom": "^6.12.3",
"@types/react-popover": "^0.5.3",
"@types/react-slick": "^0.23.8",
"@types/rehype-react": "^6.0.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed that we no longer need this package and deleted it.

"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"autoprefixer": "^10.4.7",
Expand Down Expand Up @@ -149,7 +149,7 @@
"gatsby-transformer-remark": "^5.15.0",
"gatsby-transformer-sharp": "^4.15.0",
"hast-util-select": "^5.0.2",
"husky": "^8.0.1",
"husky": "^8.0.0",
"iframe-resizer-react": "^1.1.0",
"jest": "^28.1.0",
"lint-staged": "^12.4.2",
Expand All @@ -170,11 +170,6 @@
"typescript": "^4.7.2",
"unist-util-remove-position": "^4.0.1"
},
"husky": {
"hooks": {
"pre-commit": "yarn format-staged && yarn lint-staged"
}
},
"lint-staged": {
"*.{js,ts,tsx,json}": [
"eslint"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some errors were simple to fix.

import React, { PropsWithChildren } from 'react'
import cn from 'classnames'

import Link from '@dvcorg/gatsby-theme-iterative/src/components/Link'
Expand All @@ -14,10 +14,12 @@ export interface IPopupProps {
closePopup: () => void
}

export const BasePopup: React.FC<{
className?: string
isVisible: boolean
}> = ({ children, isVisible, className }) => (
export const BasePopup: React.FC<
PropsWithChildren<{
className?: string
isVisible: boolean
}>
> = ({ children, isVisible, className }) => (
<div className={cn(styles.popup, isVisible && styles.visible, className)}>
{children}
</div>
Expand Down Expand Up @@ -58,7 +60,7 @@ export const OtherPopup: React.FC<IPopupProps> = ({
key={i}
onClick={closePopup}
>
{text}
{text as React.ReactNode}
</Link>
)
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ const MainLayout: LayoutComponent = ({
id="layoutContent"
// className={styles.pageContent}
>
{!pageContext.isDocs && <SkipNavContent id="main-content" />}
{children}
<>
{!pageContext.isDocs && <SkipNavContent id="main-content" />}
{children}
</>
</div>
<LayoutFooter />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.cmlIcon {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how stylelint missed this but it's fixed now!

background-image: url('../../../../../static/img/cml_icon-color--square_vector.svg');
background-image: url("../../../../../static/img/cml_icon-color--square_vector.svg");
}

.dvcIcon {
background-image: url('../../../../../static/img/dvc_icon-color--square_vector.svg');
background-image: url("../../../../../static/img/dvc_icon-color--square_vector.svg");
}

.studioIcon {
background-image: url('../../../../../static/img/studio_icon-color--square_vector.svg');
background-image: url("../../../../../static/img/studio_icon-color--square_vector.svg");
}

.mlemIcon {
background-image: url('../../../../../static/img/mlem-icon.svg');
background-image: url("../../../../../static/img/mlem-icon.svg");
}

.other {
Expand Down
2 changes: 1 addition & 1 deletion src/components/SubscribeSection/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Form: React.FC = () => {
const hiddenInputRef = useRef<HTMLInputElement>(null)
const honeypotNameRef = useRef(nanoid())
const sendGAEvent = useCallback(
e => {
(e: React.FormEvent) => {
if (hiddenInputRef.current?.value) {
// It's a bot.
return e.preventDefault()
Expand Down
17 changes: 11 additions & 6 deletions src/components/Support/Popover/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import React, { useState } from 'react'
import ReactPopover, { PopoverProps } from 'react-popover'
import React, { useState, PropsWithChildren } from 'react'
import ReactPopover from 'react-popover'

import { isTriggeredFromKB } from '@dvcorg/gatsby-theme-iterative/src/utils/front/keyboard'

import './styles.module.css'

type IPopoverProps = {
children: React.ReactNode
} & PopoverProps
interface IPopoverProps {
body: React.ReactNode
enterExitTransitionDurationMs: number
}

const Popover: React.FC<IPopoverProps> = ({ children, ...restProps }) => {
const Popover: React.FC<PropsWithChildren<IPopoverProps>> = ({
children,
...restProps
}) => {
const [isOpened, setOpened] = useState(false)
const toggle = (): void => setOpened(prev => !prev)
const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>): void => {
Expand All @@ -20,6 +24,7 @@ const Popover: React.FC<IPopoverProps> = ({ children, ...restProps }) => {
const close = (): void => setOpened(false)

return (
// @ts-expect-error Error is caused by package and out of our control
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out how to clear this error because it seemed to be caused by the fact that ReactPopover doesn't expect children. But the package here isn't very well maintained... The only thing I could come up with was ignoring the error but does anyone have a better alternative?

No overload matches this call.
  Overload 1 of 2, '(props: PopoverProps | Readonly<PopoverProps>): Popover', gave the following error.
    Type '{ children: Element; body: ReactNode; enterExitTransitionDurationMs: number; isOpen: boolean; onOuterAction: () => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Popover> & Readonly<PopoverProps>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Popover> & Readonly<PopoverProps>'.
  Overload 2 of 2, '(props: PopoverProps, context: any): Popover', gave the following error.
    Type '{ children: Element; body: ReactNode; enterExitTransitionDurationMs: number; isOpen: boolean; onOuterAction: () => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Popover> & Readonly<PopoverProps>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Popover> & Readonly<PopoverProps>'.

<ReactPopover isOpen={isOpened} onOuterAction={close} {...restProps}>
<div onClick={toggle} role="button" onKeyDown={onKeyDown} tabIndex={0}>
{children}
Expand Down
4 changes: 2 additions & 2 deletions src/templates/doc-jsx.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { PropsWithChildren } from 'react'
import { getItemByPath } from '@dvcorg/gatsby-theme-iterative/src/utils/shared/sidebar'

import SEO from '@dvcorg/gatsby-theme-iterative/src/components/SEO'
Expand All @@ -12,7 +12,7 @@ interface IJSXDocPageProps {
headings: []
}

const JSXDocPage: React.FC<IJSXDocPageProps> = ({
const JSXDocPage: React.FC<PropsWithChildren<IJSXDocPageProps>> = ({
title,
description,
children,
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"alwaysStrict": true,
"noEmit": true
},
"include": ["./src/**/*", "./*.js"]
"include": ["./src/**/*", "./*.js"],
"exclude": ["./node_modules/**/*"]
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good chunk of errors were based around PACKAGE_NAME cannot be used as a JSX component or NODE_MODULE PATH.ReactNode' is not assignable to type 'React.ReactNode'.

I found this StackOverflow thread but adding resolutions didn't work. I ended up deleting yarn.lock and reinstalling which cleared all the errors. I looked over the site and everything looks built correctly 🤔 But if anyone has a better idea to clearing the errors, please let me know!

node_modules/@dvcorg/gatsby-theme-iterative/src/components/MainLayout/index.tsx:59:9 - error TS2322: Type 'import("/home/circleci/repo/node_modules/@dvcorg/gatsby-theme-iterative/node_modules/@types/react/index").ReactNode' is not assignable to type 'React.ReactNode'.

node_modules/@dvcorg/gatsby-theme-iterative/src/components/Page/DefaultSEO/index.tsx:105:6 - error TS2786: 'Helmet' cannot be used as a JSX component.
  Its instance type 'Helmet' is not a valid JSX element.

Loading