eslint-no-inferred-method-name
eslint-no-inferred-method-name copied to clipboard
TypeError: Cannot read property 'type' of null
The following line:
myPromise.then(doSomething)
Generates the following error in ESLint:
[Error - 11:23:34 AM] ESLint stack trace: [Error - 11:23:34 AM] TypeError: Cannot read property 'type' of null Occurred while linting /myapp/script.js:2 at /myapp/node_modules/eslint-plugin-no-inferred-method-name/lib/rules/no-inferred-method-name.js:40:51 at Array.forEach (<anonymous>) at Program:exit (/myapp/node_modules/eslint-plugin-no-inferred-method-name/lib/rules/no-inferred-method-name.js:37:29) at /myapp/node_modules/eslint/lib/linter/safe-emitter.js:45:58 at Array.forEach (<anonymous>) at Object.emit (/myapp/node_modules/eslint/lib/linter/safe-emitter.js:45:38) at NodeEventGenerator.applySelector (/myapp/node_modules/eslint/lib/linter/node-event-generator.js:254:26) at NodeEventGenerator.applySelectors (/myapp/node_modules/eslint/lib/linter/node-event-generator.js:283:22) at NodeEventGenerator.leaveNode (/myapp/node_modules/eslint/lib/linter/node-event-generator.js:306:14) at CodePathAnalyzer.leaveNode (/myapp/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:655:23)
confirming an issue with [email protected]
ESLint: 7.9.0
TypeError: Cannot read property 'type' of null
Occurred while linting /project/src/components/text-chunk-url.tsx:1
at /project/node_modules/eslint-plugin-no-inferred-method-name/lib/rules/no-inferred-method-name.js:40:51
at Array.forEach (<anonymous>)
at Program:exit (/project/node_modules/eslint-plugin-no-inferred-method-name/lib/rules/no-inferred-method-name.js:37:29)
at /project/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/project/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/project/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
at NodeEventGenerator.applySelectors (/project/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
at NodeEventGenerator.leaveNode (/project/node_modules/eslint/lib/linter/node-event-generator.js:306:14)
at CodePathAnalyzer.leaveNode (/project/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:732:23)
currently disabling a plugin.
the code of the text-chunk-url.tsx
file:
import * as React from 'react'
import { Link } from 'gatsby'
import { motion as m, HTMLMotionProps } from 'framer-motion'
import { get } from 'total-functions'
import useMedia from 'use-media'
import ArrowRight from '../svg/arrow-right'
import ColorBar from './color-bar'
import * as styles from './text-chunk-url.module.css'
interface Props extends HTMLMotionProps<'div'> {
inView: boolean
heading: JSX.Element | string
body: JSX.Element | string
linkText: string
linkUrl: string
headingWidths: number[]
bodyWidths: number[]
}
const chunkVariants = {
hide: {
opacity: 0,
y: 40,
},
show: (i: number) => ({
opacity: 1,
y: 0,
transition: {
type: 'spring',
damping: 40,
delay: i * 0.05 + 0.3,
},
}),
}
function TextChunkUrl({
inView,
heading,
body,
linkText,
linkUrl,
headingWidths,
bodyWidths,
...props
}: Props): JSX.Element {
const isMobile: boolean = useMedia({ maxWidth: 1024 })
const headlineStyle = React.useMemo(function memo() {
return isMobile ? {
width: (typeof headingWidths !== 'undefined' &&
Array.isArray(headingWidths) &&
typeof get(headingWidths, 1) === 'number') ? headingWidths[1] : '100%'
} : {
width: (typeof headingWidths !== 'undefined' &&
Array.isArray(headingWidths) &&
typeof get(headingWidths, 0) === 'number') ? headingWidths[0] : '100%'
}
}, [isMobile, headingWidths])
const hrStyle = React.useMemo(function memo() {
return isMobile ? {} : {
width: (typeof headingWidths !== 'undefined' &&
Array.isArray(headingWidths) &&
typeof get(headingWidths, 0) === 'number') ? headingWidths[0] : '89%'
}
}, [headingWidths])
const pStyle = React.useMemo(function memo() {
return isMobile ? {
width: (typeof bodyWidths !== 'undefined' &&
Array.isArray(bodyWidths) &&
typeof get(bodyWidths, 0) === 'number') ? bodyWidths[0] : '70%'
} : {
width: typeof bodyWidths !== 'undefined' &&
Array.isArray(bodyWidths) &&
typeof get(bodyWidths, 0) === 'number' ? bodyWidths[0] : '100%'
}
}, [isMobile, bodyWidths])
return (
<m.div className={styles.wrapper} animate={inView ? 'show' : 'hide'} {...props}>
<div className={styles.colorBar}>
<ColorBar inView={inView} />
</div>
<m.h2
className={styles.headline}
custom={0}
initial='hide'
variants={chunkVariants}
style={headlineStyle}
>
{heading}
</m.h2>
<m.p
className={styles.paragraph}
custom={1}
initial='hide'
variants={chunkVariants}
style={pStyle}
>
{body}
</m.p>
<m.hr
className={styles.hr}
custom={2}
initial='hide'
variants={chunkVariants}
style={hrStyle}
/>
<m.div className={styles.explore} custom={3} initial='hide' variants={chunkVariants}>
<Link to={linkUrl}>
<span>{linkText}</span>
<ArrowRight />
</Link>
</m.div>
</m.div>
)
}
export default React.memo(TextChunkUrl)
PS: An error occures only in terminal, doesn't happen in vscode.