Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #8869: Add innerHTML lint check #8870

Merged
merged 10 commits into from
Mar 28, 2020
Prev Previous commit
Next Next commit
fix lint issues
  • Loading branch information
Kevin Thomas committed Mar 18, 2020
commit a06c445ad2908e4b39f3c2268b2616ee00222858
28 changes: 13 additions & 15 deletions scripts/pre_commit_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
# TODO in core/tests/protractor_desktop/embedding.js pointing to the
# same issue. The following was placed due to a necessary sleep as
# a temporary measure to keep the embedding tests from failing.
'core/tests/protractor_desktop/embedding.js'
'core/tests/protractor_desktop/embedding.js',
),
'excluded_dirs': ()
},
Expand Down Expand Up @@ -215,7 +215,7 @@
'message': 'The directives must be directly referenced.',
'excluded_files': (
'core/templates/pages/exploration-player-page/'
'FeedbackPopupDirective.js'
'FeedbackPopupDirective.js',
),
'excluded_dirs': (
'extensions/answer_summarizers/',
Expand Down Expand Up @@ -318,7 +318,7 @@
{
'regexp': re.compile(r'\sprint\('),
'message': 'Please use python_utils.PRINT().',
'excluded_files': ('python_utils.py'),
'excluded_files': ('python_utils.py',),
'excluded_dirs': ()
},
{
Expand All @@ -341,7 +341,7 @@
{
'regexp': re.compile(r'with open\(|= open\('),
'message': 'Please use python_utils.open_file() instead of open().',
'excluded_files': ('python_utils.py'),
'excluded_files': ('python_utils.py',),
'excluded_dirs': ()
},
{
Expand Down Expand Up @@ -384,37 +384,37 @@
{
'regexp': re.compile(r'urlsplit'),
'message': 'Please use python_utils.url_split().',
'excluded_files': ('python_utils.py'),
'excluded_files': ('python_utils.py',),
'excluded_dirs': ()
},
{
'regexp': re.compile(r'urlparse'),
'message': 'Please use python_utils.url_parse().',
'excluded_files': ('python_utils.py'),
'excluded_files': ('python_utils.py',),
'excluded_dirs': ()
},
{
'regexp': re.compile(r'urlunsplit'),
'message': 'Please use python_utils.url_unsplit().',
'excluded_files': ('python_utils.py'),
'excluded_files': ('python_utils.py',),
'excluded_dirs': ()
},
{
'regexp': re.compile(r'parse_qs'),
'message': 'Please use python_utils.parse_query_string().',
'excluded_files': ('python_utils.py'),
'excluded_files': ('python_utils.py',),
'excluded_dirs': ()
},
{
'regexp': re.compile(r'\Wunquote\('),
'message': 'Please use python_utils.urllib_unquote().',
'excluded_files': ('python_utils.py'),
'excluded_files': ('python_utils.py',),
'excluded_dirs': ()
},
{
'regexp': re.compile(r'urljoin'),
'message': 'Please use python_utils.url_join().',
'excluded_files': ('python_utils.py'),
'excluded_files': ('python_utils.py',),
'excluded_dirs': ()
},
{
Expand Down Expand Up @@ -1024,10 +1024,9 @@ def _check_bad_pattern_in_file(filepath, file_content, pattern):
bool. True if there is bad pattern else false.
"""
regexp = pattern['regexp']
if not (any(filepath.startswith(os.path.join(os.getcwd(), excluded_dir))
if not (any(filepath.startswith(excluded_dir)
for excluded_dir in pattern['excluded_dirs'])
or filepath in [os.path.join(os.getcwd(), excluded_path)
for excluded_path in pattern['excluded_files']]):
or filepath in pattern['excluded_files']):
bad_pattern_count = 0
for line_num, line in enumerate(file_content.split('\n'), 1):
if line.endswith('disable-bad-pattern-check'):
Expand Down Expand Up @@ -1872,8 +1871,7 @@ def _check_for_mandatory_pattern_in_file(
regexp_to_check['included_types'])]) and (
not any([
filepath.endswith(
os.path.join(os.getcwd(), pattern))
for pattern in (
pattern) for pattern in (
regexp_to_check[
'excluded_files'] +
regexp_to_check[
Expand Down