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

Crash running jsx-no-target-blank #2851

Closed
dbeckwith opened this issue Nov 6, 2020 · 0 comments
Closed

Crash running jsx-no-target-blank #2851

dbeckwith opened this issue Nov 6, 2020 · 0 comments
Labels

Comments

@dbeckwith
Copy link

With code like <a target={3} /> the jsx-no-target-blank rule crashes.

$PROJECT/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

TypeError: attr.value.expression.value.toLowerCase is not a function
Occurred while linting $PROJECT/src/App.tsx:18
    at isTargetBlank ($PROJECT/node_modules/eslint-plugin-react/lib/rules/jsx-no-target-blank.js:26:38)
    at JSXAttribute ($PROJECT/node_modules/eslint-plugin-react/lib/rules/jsx-no-target-blank.js:94:15)
    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.enterNode ($PROJECT/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode ($PROJECT/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at $PROJECT/node_modules/eslint/lib/linter/linter.js:952:32 {
  currentNode: <ref *1> {
    type: 'JSXAttribute',
    name: {
      type: 'JSXIdentifier',
      name: 'target',
      range: [ 406, 412 ],
      loc: {
        start: { line: 18, column: 10 },
        end: { line: 18, column: 16 }
      },
      parent: [Circular *1]
    },
    value: <ref *2> {
      type: 'JSXExpressionContainer',
      expression: {
        type: 'Literal',
        value: 3,
        raw: '3',
        range: [ 414, 415 ],
        loc: {
          start: { line: 18, column: 18 },
          end: { line: 18, column: 19 }
        },
        parent: [Circular *2]
      },
      range: [ 413, 416 ],
      loc: {
        start: { line: 18, column: 17 },
        end: { line: 18, column: 20 }
      },
      parent: [Circular *1]
    },
    range: [ 406, 416 ],
    loc: { start: { line: 18, column: 10 }, end: { line: 18, column: 20 } },
    parent: <ref *3> {
      type: 'JSXOpeningElement',
      typeParameters: undefined,
      selfClosing: false,
      name: {
        type: 'JSXIdentifier',
        name: 'a',
        range: [ 326, 327 ],
        loc: {
          start: { line: 15, column: 9 },
          end: { line: 15, column: 10 }
        },
        parent: [Circular *3]
      },
      attributes: [
        <ref *4> {
          type: 'JSXAttribute',
          name: {
            type: 'JSXIdentifier',
            name: 'className',
            range: [Array],
            loc: [Object],
            parent: [Circular *4]
          },
          value: {
            type: 'Literal',
            raw: '"App-link"',
            value: 'App-link',
            range: [Array],
            loc: [Object],
            parent: [Circular *4]
          },
          range: [ 338, 358 ],
          loc: { start: [Object], end: [Object] },
          parent: [Circular *3]
        },
        <ref *5> {
          type: 'JSXAttribute',
          name: {
            type: 'JSXIdentifier',
            name: 'href',
            range: [Array],
            loc: [Object],
            parent: [Circular *5]
          },
          value: {
            type: 'Literal',
            raw: '"https://reactjs.org"',
            value: 'https://reactjs.org',
            range: [Array],
            loc: [Object],
            parent: [Circular *5]
          },
          range: [ 369, 395 ],
          loc: { start: [Object], end: [Object] },
          parent: [Circular *3]
        },
        [Circular *1],
        <ref *6> {
          type: 'JSXAttribute',
          name: {
            type: 'JSXIdentifier',
            name: 'rel',
            range: [Array],
            loc: [Object],
            parent: [Circular *6]
          },
          value: {
            type: 'Literal',
            raw: '"noopener noreferrer"',
            value: 'noopener noreferrer',
            range: [Array],
            loc: [Object],
            parent: [Circular *6]
          },
          range: [ 427, 452 ],
          loc: { start: [Object], end: [Object] },
          parent: [Circular *3]
        }
      ],
      range: [ 325, 462 ],
      loc: { start: { line: 15, column: 8 }, end: { line: 20, column: 9 } },
      parent: <ref *8> {
        type: 'JSXElement',
        openingElement: [Circular *3],
        closingElement: <ref *7> {
          type: 'JSXClosingElement',
          name: {
            type: 'JSXIdentifier',
            name: 'a',
            range: [Array],
            loc: [Object],
            parent: [Circular *7]
          },
          range: [ 493, 497 ],
          loc: { start: [Object], end: [Object] },
          parent: [Circular *8]
        },
        children: [
          {
            type: 'JSXText',
            value: '\n          Learn React\n        ',
            raw: '\n          Learn React\n        ',
            range: [Array],
            loc: [Object],
            parent: [Circular *8]
          }
        ],
        range: [ 325, 497 ],
        loc: {
          start: { line: 15, column: 8 },
          end: { line: 22, column: 12 }
        },
        parent: <ref *9> {
          type: 'JSXElement',
          openingElement: {
            type: 'JSXOpeningElement',
            typeParameters: undefined,
            selfClosing: false,
            name: [Object],
            attributes: [Array],
            range: [Array],
            loc: [Object],
            parent: [Circular *9]
          },
          closingElement: {
            type: 'JSXClosingElement',
            name: [Object],
            range: [Array],
            loc: [Object],
            parent: [Circular *9]
          },
          children: [
            [Object],
            [Object],
            [Object],
            [Object],
            [Object],
            [Circular *8],
            [Object]
          ],
          range: [ 141, 513 ],
          loc: { start: [Object], end: [Object] },
          parent: {
            type: 'JSXElement',
            openingElement: [Object],
            closingElement: [Object],
            children: [Array],
            range: [Array],
            loc: [Object],
            parent: [Object]
          }
        }
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants