Skip to content

Commit 198168f

Browse files
committed
chore: should not lint minified css and js files
1 parent cd3a4a1 commit 198168f

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

src/extensions/default/CSSCodeHints/css-lint.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ define(function (require, exports, module) {
5454
* a gold star when no errors are found.
5555
*/
5656
async function lintOneFile(text, fullPath) {
57-
return new Promise((resolve)=>{
57+
return new Promise((resolve, reject)=>{
5858
const languageId = LanguageManager.getLanguageForPath(fullPath).getId();
5959
if(!cssMode[languageId]){
6060
console.error("Unknown language id to lint: ", languageId, fullPath);
61-
resolve();
61+
reject(new Error("Unknown CSS language to lint for "+ fullPath));
6262
return;
6363
}
6464
IndexingWorker.execPeer("cssLint", {
@@ -88,7 +88,10 @@ define(function (require, exports, module) {
8888
for(let language of supportedLanguages){
8989
CodeInspection.register(language, {
9090
name: StringUtils.format(Strings.CSS_LINT_NAME, cssMode[language]),
91-
scanFileAsync: lintOneFile
91+
scanFileAsync: lintOneFile,
92+
canInspect: function (fullPath) {
93+
return fullPath && !fullPath.endsWith(".min.css");
94+
}
9295
});
9396
}
9497
});

src/extensions/default/JSHint/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ define(function (require, exports, module) {
234234
// Register for JS files
235235
CodeInspection.register("javascript", {
236236
name: Strings.JSHINT_NAME,
237-
scanFileAsync: lintOneFile
237+
scanFileAsync: lintOneFile,
238+
canInspect: function (fullPath) {
239+
return fullPath && !fullPath.endsWith(".min.js");
240+
}
238241
});
239242
});

src/language/CodeInspection.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ define(function (require, exports, module) {
255255
return response.promise();
256256
}
257257

258+
providerList = providerList.filter(function (provider) {
259+
return !provider.canInspect || provider.canInspect(file.fullPath);
260+
});
261+
258262
DocumentManager.getDocumentText(file)
259263
.done(function (fileText) {
260264
var perfTimerInspector = PerfUtils.markStart("CodeInspection:\t" + file.fullPath),
@@ -284,6 +288,7 @@ define(function (require, exports, module) {
284288
runPromise.resolve(scanResult);
285289
})
286290
.catch(function (err) {
291+
err = err || new Error("Unknown error while inspecting "+ file.fullPath);
287292
PerfUtils.finalizeMeasurement(perfTimerProvider);
288293
var errError = {
289294
pos: {line: -1, col: 0},
@@ -305,7 +310,8 @@ define(function (require, exports, module) {
305310
message: StringUtils.format(Strings.LINTER_FAILED, provider.name, err),
306311
type: Type.ERROR
307312
};
308-
console.error("[CodeInspection] Provider " + provider.name + " (sync) threw an error: " + err.stack);
313+
console.error("[CodeInspection] Provider " + provider.name +
314+
" (sync) threw an error: " + err && (err.stack || err));
309315
runPromise.resolve({errors: [errError]});
310316
}
311317
}
@@ -558,9 +564,13 @@ define(function (require, exports, module) {
558564
return;
559565
}
560566

561-
var currentDoc = DocumentManager.getCurrentDocument(),
567+
let currentDoc = DocumentManager.getCurrentDocument(),
562568
providerList = currentDoc && getProvidersForPath(currentDoc.file.fullPath);
563569

570+
providerList = providerList && providerList.filter(function (provider) {
571+
return !provider.canInspect || provider.canInspect(currentDoc.file.fullPath);
572+
});
573+
564574
if (providerList && providerList.length) {
565575
var numProblems = 0;
566576
var aborted = false;

0 commit comments

Comments
 (0)