How can I configure Web Essentials 2013 to ignore files?
Asked Answered
P

4

26

I have a fresh MVC 5.1 web app project in VS 2013 (Update 1) w/ Web Essential 2013 (latest as of today) installed. After building the project, Web Essentials scans for javascript files and post messages to the output window for any issues it finds. For a brand new MVC 5.1 project, it generates over 11,000 messages - not really useful.

I've tried two methods to get it to ignore the offending javascript files that are included with new MVC 5 projects by default:

  1. Used the Web Essentials > Edit Global JSCS Settings command to open the .jscs.json file in my user profile directory. Then modified the "excludeFiles" property to ["test/data/.js", "Scripts/jquery.js"].

  2. Created a .jshintignore file in my Scripts folder with "jquery*.js".

Neither of these methods has had any impact on the JSCS messages generated. Am I doing something wrong, or is this an issue with Web Essentials?

Penthea answered 1/2, 2014 at 14:52 Comment(2)
Same issue here, except I have Kendo & Angular too so get 175k errors. Tried *.js in the excludeFiles but that doesn't seem to do anything. Really slowing down builds/F5'sShimberg
I have deactivated jshint and jscs to be able to compile. Tools -> Options -> Web Essentials -> Javascript. Set Run on Build and Run on Save to false.Waac
T
18

Update 4:

The newest Web Essentials 2013 1.9 has "Better ignore logic for the lint runners", all the problems are cleared. You can turn on "Run on build" now. It has default ignore rule for common js library and minified js. The following excludeFiles config still works, but not necessary anymore.

Update 3:

Cross my post from https://github.com/madskristensen/WebEssentials2013/issues/603.

If you don't need JSHint and JSCS's function, just go to "Tools - Options - Web Essentials - JavaScript", set "Run on build" and "Run on save" to False.

If you wish to use them, keep "Run on build" False, set "Run on save" to True. All js will be JSHint and JSCS while preview, open and save. With this change, you can build successfully without slow down. Error list will only be filled with currently opened js's JSHint and JSCS items.

By default setting, JSHint won't run on all minified and some common js library, but JSCS will run always. While JSCS, it may delay you about serval seconds with minified js. If you don't wanna wait, then go to "Web Essentials - Edit global JSCS settings". Change

"excludeFiles": ["test/data/*.js"],

into

"excludeFiles": ["**/*.min.js", "**/*.debug.js", "**/*.intellisense.js", "**/*-vsdoc.js"],

to skip JSCS only on minified js. Or change to

"excludeFiles": ["**"],

to stop JSCS totally, only keep JSHint running.

Of cause you can write your own rule to exclude those you don't need. Just put double stars at the beginning, use '/' instead of '\', other part just use single star for wildcard. Like "**/Scripts/*.js".

With exclude rule, it will still generate an xml information item for each js, that will be fix later (hopefully), but at last you can start coding.

At last, you can upgrade to 1.8.5, but it only stop "Run on build" from running. "Run on save" still need these settings. So it don't change what I say here.

Hope these informations are right and helpful, with current version of 1.8 and 1.8.5.


Update 1:

Install new version 1.8.5. It will stop "Run on build" function. That means even you turn it on, it will not run on build. But "Run on save True" will still and actually run on preview, open and save. The right relative pattern of excludeFiles is **/Script/**.

So the recommand exclude rule for minified js will be:

    "excludeFiles": ["**/Scripts/**.min.js", "**/Scripts/**.debug.js", "**/Scripts/**.intellisense.js", "**/Scripts/**-vsdoc.js"],

Or just use **/Script/** to exclude them all.

The <?xml problem will be fix by next version, according to JSHint/JSCS Errors on .min files and others?. So this pattern should be the final right one, with one problem that should and will be fix by next Web Essentials version. Or maybe next WE will provide a good default excludeFiles rule.


Update 2:

A better one:

"excludeFiles": ["**/*.min.js", "**/*.debug.js", "**/*.intellisense.js", "**/*-vsdoc.js"],

to exclude all minified js no matter where it is.


The easy way I found is go to "Tools - Options - Web Essentials - JavaScript", set Run on Build/Save to False.

Another method is go to "Web Essentials - Edit global JSCS settings", to set excludeFiles.

But multiple excludeFiles is wrong syntax. Should use [ "a", "b"] syntax.

And should use absolute path, (while setting in global?) with path divider '/', '\' is not allowed.

Sub directory is no use, you should specify every single path.

So a valid setting like this:

"excludeFiles": ["C:/Solution/Project/Scripts/*", "C:/Solution/Project/Scripts/kendo/*"]

But this way will generate another Build error per js file:

JSCS parse error: <?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
</checkstyle>

And information item per js file:

<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
</checkstyle>

I don't know how to avoid it. So maybe the best way is just the first easy way.

Tacky answered 6/2, 2014 at 9:11 Comment(4)
I have report it to JSCS github.com/mdevils/node-jscs/issues/232 and Web Essentials github.com/madskristensen/WebEssentials2013/issues/603, JSCS guy say it should be relative path... I have test to put a .jscs.json on project root folder, still without luck.Tacky
vswebessentials.com/changelog have new version 1.8.5 - February 6, 2014: * Performance fixes * Disabled JS linting on build * Was causing node.exe to run wild. But problem still remain.Tacky
"...the best way is just the first easy way", by ChrisTorngDisk
I just don't think this is the answer. I am on the latest Web Essentials; I work on websites that have lots of folders, some of which I never touch (think Umbraco, Drupal, WordPress). I haven't messed with any of the Web Essentials config and from what I can tell either Web essentials is simply slow or the default config isn't good enough and needs to be customized still.Bolten
P
7

I had the same issue after installing KendoUI. It was basically impossible to run the project. I solved it by going to Web Essentials -> Edit global JSCS settings and adding:

"excludeFiles": ["Scripts/kendo/*"]

below the "excludeFiles": ["test/data/*.js"] entry.

Now the .jscs.json file looks like this:

{
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
"disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"requireRightStickedOperators": ["!"],
"requireLeftStickedOperators": [","],
"disallowImplicitTypeConversion": ["string"],
"disallowKeywords": ["with"],
"disallowMultipleLineBreaks": true,
"disallowKeywordsOnNewLine": ["else"],
"excludeFiles": ["test/data/*.js"],
"excludeFiles": ["Scripts/kendo/*"]
"validateJSDoc": {
    "checkParamNames": true,
    "requireParamTypes": true
    }
}

Just replace the ["Scripts/kendo/*"] with whatever you want to exclude. Worked like a charm for me.  

Pandora answered 5/2, 2014 at 4:14 Comment(2)
Thanks, Nikolai. Did you have to restart VS? I made the same change but it didn't take immediately. I loaded up the solution later in a new VS session and it seemed to kick in.Penthea
I did restart VS as a creature of habit:) I am not certain that it was needed. If it worked for you, could you vote up my answer?;)Pandora
L
2

The excludeFiles option in the .jscsrc is the right way to go but you need to specify it as a full file system path and not a relative path for your project to get it to work. Note the leading forward slash / rather than just the **. You can target more specific folders as well but it seems you need to include the / to get it to work. I suspect you could research node file globbing documentation to really understand the options.

On my machine, with Web Essentials 2013 for Update 2, the following steps disabled JSCS for all files:

  • Select the Web Essentials Menu->Edit Global JSCS settings (.jscsrc)...
  • Add "excludeFiles": ["/**"], and save the settings file
  • Run JSCS manually on the problem JS file or by saving it again (Dependent on Tools->Options->Web Essentials->JavaScript->Linter->Run on save option

It is not necessary to restart Visual Studio.

Legwork answered 23/6, 2014 at 2:24 Comment(0)
T
2

Web Essentials 2013 Version 2.3 add a new way to deal this problem: .weignore. See http://vswebessentials.com/features/general#weignore or https://github.com/madskristensen/WebEssentials2013/pull/1250. The new way is better then old way, because this is the centralize and consistent place to manage all compilers and linters. And it is faster because the old way will still need to run each target file by compilers and linters, and then ignored by them. New way will just ignore from Web Essentials itself, reduce the time/CPU/disk that runs into compilers and linters. And no need to understand each compilers and linters specific config format to do the same thing.

Tacky answered 1/9, 2014 at 4:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.