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

jsx-no-script-url: Cannot read property 'type' of null #2871

Closed
AriPerkkio opened this issue Dec 7, 2020 · 0 comments
Closed

jsx-no-script-url: Cannot read property 'type' of null #2871

AriPerkkio opened this issue Dec 7, 2020 · 0 comments
Assignees

Comments

@AriPerkkio
Copy link
Contributor

Hello, jsx-no-script-url 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/runs/1506856587?check_suite_focus=true

"eslint-plugin-react": "^7.21.5"
"extends": ["plugin:react/all"]

Minimal repro:

import React from 'react';

export default function MyComponent() {
  return <a href />;
}
Crash reports from real-world examples

Rule: jsx-no-script-url

Message: Cannot read property 'type' of null
Path: mertJF/tailblocks/src/blocks/blog/dark/a.js
Link

                  Photo booth fam kinfolk cold-pressed sriracha leggings
jianbing
                  microdosing tousled waistcoat.
                </p>
                <div className="flex items-center flex-wrap ">
                  <a href className={`text-${props.theme}-500 inline-flex
items-center md:mb-2 lg:mb-0`}>
                    Learn More
                    <svg
                      className="w-4 h-4 ml-2"
                      viewBox="0 0 24 24"
                      stroke="currentColor"
Error:
TypeError: Cannot read property 'type' of null
Occurred while linting <text>:28
    at hasJavaScriptProtocol(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/jsx-no-script-url.js:19:21)
    at JSXAttribute (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/jsx-no-script-url.js:81:86)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/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/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32

Rule: jsx-no-script-url

Message: Cannot read property 'type' of null
Path: mertJF/tailblocks/src/blocks/blog/dark/b.js
Link

              <p className="leading-relaxed mb-3">
                Photo booth fam kinfolk cold-pressed sriracha leggings jianbing
                microdosing tousled waistcoat.
              </p>
              <a href className={`text-${props.theme}-500 inline-flex
items-center`}>
                Learn More
                <svg
                  className="w-4 h-4 ml-2"
                  viewBox="0 0 24 24"
                  stroke="currentColor"
Error:
TypeError: Cannot read property 'type' of null
Occurred while linting <text>:21
    at hasJavaScriptProtocol (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/jsx-no-script-url.js:19:21)
    at JSXAttribute (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/jsx-no-script-url.js:81:86)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/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/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
@ljharb ljharb self-assigned this Dec 7, 2020
@ljharb ljharb closed this as completed in 63d5a1b Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants