eslint / js

Monorepo for the JS language tools.
BSD 2-Clause "Simplified" License
2.29k stars 195 forks source link

Is it possible to configure tokenize method to return hyphenated word as one token? #597

Closed vanessadnguyen closed 8 months ago

vanessadnguyen commented 8 months ago

Hi, By default the tokenizer splits words on hyphens , so for example "i-mac" is tokenized to "i" and "mac" Is there any way to configure the behavior of the tokenizer to stop it splitting words on hyphens?

Thanks for reading my message, Vanessa

nzakas commented 8 months ago

No. i-mac is not an identifier in JavaScript. It's broken up into:

  1. i an identifier
  2. - a punctuator
  3. mac an identifier

If you want that to be treated as a single identifier, then you'd need something other than a JavaScript parser/tokenizer.