admin管理员组

文章数量:1279110

I just upgraded an ASP.NET Core 2.0 Razor app to 2.1 to get the new functionality for EF Core 2.1. This is my first major project in ASP.NET ing from a WinForms & PHP background.

I'm trying to go through and clear out the error list, but I'm getting ESLint errors, and I've never used ESLint before so I don't know where to start. Google isn't too helpful on this issue either.

Here's the warnings:

Warning react/jsx-sort-prop-types   (ESLint) Definition for rule 'react/jsx-sort-prop-types' was not found
Warning react/wrap-multilines   (ESLint) Definition for rule 'react/wrap-multilines' was not found
Warning react/require-extension (ESLint) Definition for rule 'react/require-extension' was not found

I don't even know what these mean, googling them doesn't enlighten me, and they don't seem to point to a specific line of code.

What the hell are these warnings trying to tell me?

I just upgraded an ASP.NET Core 2.0 Razor app to 2.1 to get the new functionality for EF Core 2.1. This is my first major project in ASP.NET ing from a WinForms & PHP background.

I'm trying to go through and clear out the error list, but I'm getting ESLint errors, and I've never used ESLint before so I don't know where to start. Google isn't too helpful on this issue either.

Here's the warnings:

Warning react/jsx-sort-prop-types   (ESLint) Definition for rule 'react/jsx-sort-prop-types' was not found
Warning react/wrap-multilines   (ESLint) Definition for rule 'react/wrap-multilines' was not found
Warning react/require-extension (ESLint) Definition for rule 'react/require-extension' was not found

I don't even know what these mean, googling them doesn't enlighten me, and they don't seem to point to a specific line of code.

What the hell are these warnings trying to tell me?

Share Improve this question edited Sep 14, 2018 at 20:58 Louis Ingenthron asked Sep 9, 2018 at 18:24 Louis IngenthronLouis Ingenthron 1,3688 silver badges22 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 8

If you are using ESLint, and don't want to add code to all your files, then you can disable the three rules in your ESLint configuration file. There are actually two ways to do this.

The long way is to find the configuration file, which is at c:\Users{username}.eslintrc You can open it with a text editor, find the rule and set the value to 0 (zero), which means disabled. For example:

"react/jsx-sort-prop-types": 0,

The shorter way is to go to Tools/Options/Text Editor/'JavaScript/TypeScript'/Linting/General. On that page is a button 'Reset global .eslintrc'. If you click that you get a newer version of the .eslintrc configuration file that doesn't have these rules in at all, assuming you have a recent version of Visual Studio.

Whichever method you use you'll need to restart Visual Studio, and after that the errors should go away.

I think the problem is arising because you (and I) have an old version of this file (.eslintrc) with rules that aren't supported or no longer work for the React plugin that ships with ESLint for Visual Studio. I was getting these errors in projects that had no npm modules installed, and definitely no React. I think upgrades to Visual Studio probably don't overwrite this file in case you've changed it.

It's also possible to put a .eslintrc file into your project folder and it will override the settings in the default location. So for an enterprise project where you're seeing this issue on multiple machines you could just check in an .eslintrc that fixed it. However, if you do a clean install of Visual Studio on a new machine I don't think you'll see the problem, so I'm not sure that should be necessary.

I used Visual Studio 2017 15.8.1 to test this. ESLint got quite a big upgrade in 15.8.

If you want to keep using EsLint (which is good), You can disable and reenable EsLint at the start of the .js files to avoid those warnings and still have EsLint checks avaliable for the rest of the file:

/* eslint-disable */

/* eslint-enable */

And for files that you don't control like jquery.js, bootstrap.js, etc you can just disable pletely with this line at the start of the file:

/* eslint-disable */

You just need to remember to add again this line after you have updated them.

If you're NOT using ESLint, and you are using Visual Studio, you can go to:

Tools -> Options -> Text Editor -> JavaScript/TypeScript -> Linting -> General.

From there you can uncheck the "Enable ESLint" checkbox, and check the global configuration file for that tool.

I am using Visual Studio 2017 (15.8.4), to find this menu.

本文标签: javascriptHow do I fix or get rid of ESLint definition requirement in ASPNET Razor appStack Overflow