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.)
This commit is contained in:
Priyank Patel
2021-06-12 16:24:12 +00:00
committed by Tim Abbott
parent 43da43701b
commit ec2ab1eb8d

View File

@@ -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": ['<p style="color: blue;">Foo</p>', 'style = "color: blue;"'],
},
{