简体   繁体   中英

PhpStorm for React gives me a red underline

I'm using PhpStorm 2018.1, and coding a ReactJS based project. I was a little annoyed with the red underline which seemed to say that my code was error even though it wasn't.

问题1 问题2

I have followed the answers given from this forum:

  1. WebStorm/PhpStorm warning for react attributes in jsx like className
  2. PHPStorm JSX/React syntax highlighting

but this red underline still appears.

I installed a few plugins for JavaScript and ES6 debugging 在此输入图像描述 在此输入图像描述

The question is is there another PhpStorm plugin that I didn't install?

These errors are reported by JShint linter, not by PhpStorm itself. You have to tell JSHint that you are using ES2015 syntax. This can be done by adding

/*jshint esversion: 6 */

comment to your file ( http://jshint.com/docs/options/#esversion ), or by specifying


{
  "esversion": 6
}

in .jshintrc file. If you don't have your own config file, you can enable EcmaScript.next in Relaxing options in Settings | Languages & Frameworks | JavaScript | Code Quality Tools | JSHint

If you didn't mean to use JSHint for linting your React application (and I'd say that this linter is a bit outdated and doesn't work well for JSX + ES6), just disable it by unchecking Enable in Settings | Languages & Frameworks | JavaScript | Code Quality Tools | JSHint

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM