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

linter crash from :: bind operator in JSX #39

Closed
tsheaff opened this issue May 19, 2017 · 2 comments
Closed

linter crash from :: bind operator in JSX #39

tsheaff opened this issue May 19, 2017 · 2 comments

Comments

@tsheaff
Copy link

tsheaff commented May 19, 2017

Migrated from babel/babel-eslint#472

I'm using this syntax:

::this.foo()

However, eslint crashes in this case:

The prop value with an expression type of BindExpression could not be resolved.
  Please file issue to get this fixed immediately.
Error: The prop value with an expression type of BindExpression could not be resolved.
  Please file issue to get this fixed immediately.
    at Object.extract [as JSXExpressionContainer] (/Users/tsheaff/Code/private/calm/www/node_modules/jsx-ast-utils/lib/values/expressions/index.js:173:11)
    at getValue (/Users/tsheaff/Code/private/calm/www/node_modules/jsx-ast-utils/lib/values/index.js:48:27)
    at extractValue (/Users/tsheaff/Code/private/calm/www/node_modules/jsx-ast-utils/lib/getPropValue.js:24:12)
    at getPropValue (/Users/tsheaff/Code/private/calm/www/node_modules/jsx-ast-utils/lib/getPropValue.js:41:10)
    at /Users/tsheaff/Code/private/calm/www/node_modules/eslint-plugin-jsx-a11y/lib/rules/no-static-element-interactions.js:76:95
    at Array.some (native)
    at EventEmitter.JSXOpeningElement (/Users/tsheaff/Code/private/calm/www/node_modules/eslint-plugin-jsx-a11y/lib/rules/no-static-element-interactions.js:75:52)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:191:7)
    at NodeEventGenerator.applySelector (/Users/tsheaff/Code/private/calm/www/node_modules/eslint/lib/util/node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (/Users/tsheaff/Code/private/calm/www/node_modules/eslint/lib/util/node-event-generator.js:294:22)

Here is my .eslintrc:

module.exports = {
  'env': {
    'browser': true,
    'node': true,
  },
  'plugins': [ 'react' ],
  'parser': 'babel-eslint',
  'extends': 'airbnb', /* see https://github.com/airbnb/javascript */
  'rules': {
    /* override a few airbnb rules */
    'strict': 0,
    'space-before-function-paren': ['error', 'never'],
    'func-names': 'off',
    'no-console': 'error',
    'max-len': 'off',
    'global-require': 'error',
    'consistent-return': 'off',
    'class-methods-use-this': 'off',
    'object-shorthand': ['error', 'never'],
    'no-param-reassign': ['error', {
      'props': false
    }],
    'brace-style': ['error', '1tbs', { allowSingleLine: false }],
    'arrow-parens': ['error', 'always'],
    'arrow-body-style': 'off',
    'import/prefer-default-export': 'off',
    'import/extensions': ['error', {
      'js': 'never',
      'json': 'always'
    }],
  },
}

Here are my dependencies:

    "babel-eslint": "^7.2.3",
    "eslint": "^3.19.0",
    "eslint-config-airbnb": "^15.0.1",

When I remove the 'parser': 'babel-eslint', line from the config, this crash goes away. However in that case native eslint doesn't recognize the :: and says Parsing error: Unexpected token : (Fatal) It also goes away if the file I'm linting does not use the :: syntax

This mini-repo recreates the error: https://gist.github.com/tsheaff/003685ca6a163fb467a29fb7c70fbf10

The :: operator on line this line is the offending one. If I remove that or switch to .bind(this) syntax I don't get the error. I also don't get the error if the :: is not in JSX

@tsheaff
Copy link
Author

tsheaff commented May 19, 2017

the reason is that it doesn't account for :: because it's using acorn-jsx instead of babylon. the rule would need to update it's version of that util

@ljharb
Copy link
Member

ljharb commented May 19, 2017

Duplicate of #33.

@tsheaff tsheaff closed this as completed May 19, 2017
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