ESLint unexpected character '@' for JS decorators

前端 未结 3 730
无人共我
无人共我 2021-01-11 11:27

I\'m trying to use decorators in my JS project, however ESLint is throwing an error stating that the @ symbol is a unexpected character.

My code:

@o         


        
3条回答
  •  有刺的猬
    2021-01-11 11:56

    You probably want to use babel-eslint which uses Babel to parse things that ESLint hasn't implemented yet (usually experimental features like this). From their README:

    At the moment, you'll need it if you use stuff like class properties, decorators, types.

    It is used with your current eslint setup, you just have to update some configuration in your .eslintrc

提交回复
热议问题