Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Wrong highlight for a property name #334

Open
KSXGitHub opened this issue Mar 4, 2016 · 4 comments
Open

Wrong highlight for a property name #334

KSXGitHub opened this issue Mar 4, 2016 · 4 comments
Labels

Comments

@KSXGitHub
Copy link
Contributor

I just updated the lastest version of language-javascript (v0.112.0) which has the following bugs. I don't know which old version I used but it hasn't these bugs. Also, I think property names should be highlighted (in JSON objects and ES6 classes), it would be a good way to avoid these bugs.

I can use a keyword as a property name in JavaScript, but language-javascript matchs it wrong

image

test1 = {
    normal: "It's okay",
    function: "'function' is just a property name, and it's valid, please don't highlight this 'function' here"
}

image

class test2 {
    normal() {/* It's okay */}
    function() {/* Again, this 'function' is just a property name, not a keyword */}
}

image

test3 = {
    normal() {/* It's okay */},
    function() {/* This 'function' is a property name, not a keyword */}
}
@winstliu winstliu added the bug label Mar 4, 2016
@winstliu
Copy link
Contributor

winstliu commented Mar 4, 2016

Also, I think property names should be highlighted (in JSON objects and ES6 classes), it would be a good way to avoid these bugs.

We're working on this - see #307.

@KSXGitHub
Copy link
Contributor Author

@50Wliu Thank you, it's a good way to solve the first bug.

@adamreisnz
Copy link

Fwiw, the same happens for default as a property name:

image

@doughsay
Copy link

I'd like to throw in another example if it helps. This one's a little more complicated though, since it breaks the highlighting completely:

// highlights the contents of the string correctly as a string:
{ func: 'function foo() { return "foo"; }' };
"things are ok";

// now it thinks the string contents are actually a function definition:
{ function: 'function foo() { return "foo"; }' };
"not ok... :("

I filed this in linguist here: github-linguist/linguist#3003; they sent me here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants