1. Summary
I couldn’t find, how I can get all warnings for all files except specific warnings (not suppression tags).
In my case, I can’t suppress WARNING - [JSC_VAR] Using var (prefer const or let).
2. MCVE
2.1. Data
KiraVar.js:var KiraVariable = 4147;CLI command:
google-closure-compiler --js KiraVar.js --language_out ECMASCRIPT_NEXT --warning_level VERBOSE --jscomp_warning *
2.2. Behavior
2.2.1. ExpectedNo warnings.
2.2.2. CurrentKiraVar.js:1:0: WARNING - [JSC_VAR] Using `var` (prefer `const` or `let`).
1| var KiraVariable = 4147;
^^^^^^^^^^^^^^^^^^^^^^^^
0 error(s), 1 warning(s), 100.0% typed
'use strict';var KiraVariable=4147;
3. Reason for suppression
I use CoffeeScript, that not support let and const.
- the official CoffeeScript documentation — Unsupported ECMAScript features:
letandconst; - the official CoffeeScript issue tracker — Allow
constkeyword.
4. Not helped
- I couldn’t find any tool, that can automatically correctly replace
vartoconstorletin JavaScript files.eslint --fixwithno-varoption doesn’t do it. - I tried
--jscomp_offoption with values fromParserConfig.javaandDiagnosticGroups.javafiles. - I couldn’t find how I can solve my problem in Google, Stack Overflow and closure-compiler GitHub repository.
5. Don’t offer
- Please don’t tell me that I shouldn’t be using CoffeeScript.
- I don’t need suppress warnings in specific files. I use
varin many files; it would be nice suppress this warning for all files one time. For the same reason, please don’t suggest that I add annotations every time I usevar. --jscomp_off lintChecksworks for me, but it will disable 40 errors. I need solely suppress[JSC_VAR], not all of these 40 errors of the supression tag.
The compiler doesn't allow for the suppression of individual lint warnings. If you are willing to create a custom build of the compiler, you can:
Removing the check is likely easier to merge with future versions.