summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/lib/rules/no-inline-comments.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-11-22 14:17:22 -0500
committercjihrig <cjihrig@gmail.com>2019-11-25 11:55:40 -0500
commit90fb308de42575adeed82d864da57148049185b3 (patch)
tree79d362bf7f18f1088da78b8b3073252b059b7c3f /tools/node_modules/eslint/lib/rules/no-inline-comments.js
parent02d4c742369975fd7499bb242be61bbb1f8fc1ab (diff)
downloadandroid-node-v8-90fb308de42575adeed82d864da57148049185b3.tar.gz
android-node-v8-90fb308de42575adeed82d864da57148049185b3.tar.bz2
android-node-v8-90fb308de42575adeed82d864da57148049185b3.zip
tools: update ESLint to 6.7.1
Update ESLint to 6.7.1 PR-URL: https://github.com/nodejs/node/pull/30598 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'tools/node_modules/eslint/lib/rules/no-inline-comments.js')
-rw-r--r--tools/node_modules/eslint/lib/rules/no-inline-comments.js36
1 files changed, 25 insertions, 11 deletions
diff --git a/tools/node_modules/eslint/lib/rules/no-inline-comments.js b/tools/node_modules/eslint/lib/rules/no-inline-comments.js
index b35db11410..bd226ecc35 100644
--- a/tools/node_modules/eslint/lib/rules/no-inline-comments.js
+++ b/tools/node_modules/eslint/lib/rules/no-inline-comments.js
@@ -35,22 +35,36 @@ module.exports = {
*/
function testCodeAroundComment(node) {
- // Get the whole line and cut it off at the start of the comment
- const startLine = String(sourceCode.lines[node.loc.start.line - 1]);
- const endLine = String(sourceCode.lines[node.loc.end.line - 1]);
+ const startLine = String(sourceCode.lines[node.loc.start.line - 1]),
+ endLine = String(sourceCode.lines[node.loc.end.line - 1]),
+ preamble = startLine.slice(0, node.loc.start.column).trim(),
+ postamble = endLine.slice(node.loc.end.column).trim(),
+ isPreambleEmpty = !preamble,
+ isPostambleEmpty = !postamble;
- const preamble = startLine.slice(0, node.loc.start.column).trim();
+ // Nothing on both sides
+ if (isPreambleEmpty && isPostambleEmpty) {
+ return;
+ }
- // Also check after the comment
- const postamble = endLine.slice(node.loc.end.column).trim();
+ // JSX Exception
+ if (
+ (isPreambleEmpty || preamble === "{") &&
+ (isPostambleEmpty || postamble === "}")
+ ) {
+ const enclosingNode = sourceCode.getNodeByRangeIndex(node.range[0]);
- // Check that this comment isn't an ESLint directive
- const isDirective = astUtils.isDirectiveComment(node);
+ if (enclosingNode && enclosingNode.type === "JSXEmptyExpression") {
+ return;
+ }
+ }
- // Should be empty if there was only whitespace around the comment
- if (!isDirective && (preamble || postamble)) {
- context.report({ node, message: "Unexpected comment inline with code." });
+ // Don't report ESLint directive comments
+ if (astUtils.isDirectiveComment(node)) {
+ return;
}
+
+ context.report({ node, message: "Unexpected comment inline with code." });
}
//--------------------------------------------------------------------------