From ec2ab1eb8dc7bfbe164c3e04b97ff5db7a3a0ea5 Mon Sep 17 00:00:00 2001 From: Priyank Patel Date: Sat, 12 Jun 2021 16:24:12 +0000 Subject: [PATCH] lint: Correctly detect the use of style attribute. We add a exclude pattern that makes sure we don't catch two edge cases: a variable declaration `const style =` and setting a variable ending in style such as `require_cmd_style =`. We don't add and exclude pattern for let declaration because it will catch lines that modify it later in the code. (Removed other files from exclude list that no longer needed to be excluded from this lint rule.) --- tools/linter_lib/custom_check.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index 8f6a8798f5..4c9a970e6a 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -202,14 +202,12 @@ js_rules = RuleList( }, { "pattern": "style ?=", + "exclude_pattern": r"(const |\S)style ?=", "description": "Avoid using the `style=` attribute; we prefer styling in CSS files", "exclude": { "frontend_tests/node_tests/copy_and_paste.js", - "frontend_tests/node_tests/upload.js", - "static/js/upload.js", - "static/js/stream_color.js", }, - "good_lines": ["#my-style {color: blue;}"], + "good_lines": ["#my-style {color: blue;}", "const style =", 'some_style = "test"'], "bad_lines": ['

Foo

', 'style = "color: blue;"'], }, {