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

Template string as object key is broken #1116

Closed
Kikobeats opened this issue Apr 25, 2018 · 2 comments

Comments

@Kikobeats
Copy link

commented Apr 25, 2018

Hello,

I noted that using an interpolate string as an object key break the linter.

Example of code

'use strict'

const foo = 'foo'

const routes = {
  [`${foo}`]: 'foobar'
}

Linter output

❯ npx standard test.js
standard: Unexpected linter output:

TypeError: Cannot read property 'range' of null
    at SourceCode.getTokenBefore (/Users/josefranciscoverdugambin/audiense/web/node_modules/standard/node_modules/eslint/lib/token-store/index.js:303:18)
    at checkSpacingBefore (/Users/josefranciscoverdugambin/audiense/web/node_modules/standard/node_modules/eslint/lib/rules/template-curly-spacing.js:52:42)
    at TemplateElement (/Users/josefranciscoverdugambin/audiense/web/node_modules/standard/node_modules/eslint/lib/rules/template-curly-spacing.js:117:17)
    at listeners.(anonymous function).forEach.listener (/Users/josefranciscoverdugambin/audiense/web/node_modules/standard/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/josefranciscoverdugambin/audiense/web/node_modules/standard/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (/Users/josefranciscoverdugambin/audiense/web/node_modules/standard/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/josefranciscoverdugambin/audiense/web/node_modules/standard/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/Users/josefranciscoverdugambin/audiense/web/node_modules/standard/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/Users/josefranciscoverdugambin/audiense/web/node_modules/standard/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)

If you think this is a bug in `standard`, open an issue: https://github.com/standard/standard/issues

Environment info

npx standard --version
11.0.1

npx node --version
v9.11.1

npx npm --version
3.10.10

@Kikobeats Kikobeats changed the title Interpolate string as object key is broken Template string as object key is broken Apr 25, 2018

@feross feross added the bug label Apr 26, 2018

@jdkschang

This comment has been minimized.

Copy link

commented Aug 29, 2018

@Kikobeats This seems to be an babel issue--specifically regarding babel-eslint and types.
See here for more details

@feross

This comment has been minimized.

Copy link
Member

commented Aug 12, 2019

This issue seems to be fixed in babel upstream now, so I am going to close this issue: babel/babel-eslint#530 (comment)

@feross feross closed this Aug 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.