mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
Fixed: 1183727 Change-Id: I7bb5a859fdab4c42693623e87a3763fe141a46e0 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2729038 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
39 lines
1000 B
JavaScript
39 lines
1000 B
JavaScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
'use strict';
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'problem',
|
|
docs: {
|
|
description: 'check for commented out console.{warn/log/etc} lines',
|
|
category: 'Possible Errors',
|
|
},
|
|
fixable: 'code',
|
|
schema: [] // no options
|
|
},
|
|
create: function(context) {
|
|
const sourceCode = context.getSourceCode();
|
|
|
|
function checkCommentAndReportError(comment) {
|
|
const trimmed = comment.value.trim();
|
|
if (trimmed.startsWith('console.log(')) {
|
|
context.report({node: comment, message: 'Found a commented out console call.'});
|
|
}
|
|
}
|
|
|
|
return {
|
|
Program() {
|
|
const comments = sourceCode.getAllComments();
|
|
if (!comments) {
|
|
return;
|
|
}
|
|
for (const comment of comments) {
|
|
checkCommentAndReportError(comment);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
};
|