Closed
Description
Hello, jsx-no-constructed-context-values
rule seems to crash in certain cases. This issue was spotted by automated CI run - it is not blocking my development or anything. https://github.com/AriPerkkio/eslint-remote-tester/actions/runs/454180745
"eslint-plugin-react": "^7.22.0",
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"settings": {
"react": {
"version": "16.13.1"
}
},
"plugins": ["react"],
"rules": {
"react/jsx-no-constructed-context-values": "error"
}
}
Minimal repro:
The boolean shorthand in JSX seems to trigger the crash.
import React from 'react';
import BooleanContext from './BooleanContext';
function ContextProvider(props) {
return (
<BooleanContext.Provider value>
{props.children}
</BooleanContext.Provider>
)
}
TypeError: Cannot read property 'type' of null
Occurred while linting <text>:157
at JSXOpeningElement(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/jsx-no-constructed-context-values.js:170:23)
Crash reports from real projects
Rule: jsx-no-constructed-context-values
- Message:
Cannot read property 'type' of null Occurred while linting <text>:157
- Path:
Shopify/polaris-react/src/components/Banner/Banner.tsx
- Link
</div>
);
return (
<BannerContext.Provider value>
<div
className={className}
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
ref={wrapperRef}
TypeError: Cannot read property 'type' of null
Occurred while linting <text>:157
at JSXOpeningElement(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/jsx-no-constructed-context-values.js:170:23)
at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
at NodeEventGenerator.applySelectors(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
at NodeEventGenerator.enterNode(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
at CodePathAnalyzer.enterNode(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:952:32
at Array.forEach (<anonymous>)
Rule: jsx-no-constructed-context-values
- Message:
Cannot read property 'type' of null Occurred while linting <text>:204
- Path:
Shopify/polaris-react/src/components/Banner/tests/Banner.test.tsx
- Link
expect(unstyledLink.prop('rel')).toBe('noopener noreferrer');
});
const bannerWithContentContext = mountWithAppProvider(
<WithinContentContext.Provider value>
<Banner
action={{
content: 'Primary action',
}}
>
TypeError: Cannot read property 'type' of null
Occurred while linting <text>:204
at JSXOpeningElement(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/jsx-no-constructed-context-values.js:170:23)
at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
at NodeEventGenerator.applySelectors(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
at NodeEventGenerator.enterNode(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
at CodePathAnalyzer.enterNode(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:952:32
at Array.forEach (<anonymous>)
Rule: jsx-no-constructed-context-values
- Message:
Cannot read property 'type' of null Occurred while linting <text>:127
- Path:
Shopify/polaris-react/src/components/Card/Card.tsx
- Link
</div>
) : null;
return (
<WithinContentContext.Provider value>
<div className={className}>
{headerMarkup}
{content}
{footerMarkup}
</div>
TypeError: Cannot read property 'type' of null
Occurred while linting <text>:127
at JSXOpeningElement(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/jsx-no-constructed-context-values.js:170:23)
at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
at NodeEventGenerator.applySelectors(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
at NodeEventGenerator.enterNode(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
at CodePathAnalyzer.enterNode(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:952:32
at Array.forEach (<anonymous>)
Metadata
Metadata
Assignees
Labels
No labels