Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: chrome/browser/web_dev_style/js_checker.py

Issue 2860903002: web_dev_style: tweak varNamesLikeThis check to detect endsWithUnder_ (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/web_dev_style/js_checker_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Presubmit script for Chromium JS resources. 5 """Presubmit script for Chromium JS resources.
6 6
7 See chrome/browser/PRESUBMIT.py 7 See chrome/browser/PRESUBMIT.py
8 """ 8 """
9 9
10 import regex_check 10 import regex_check
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 "Please only use this.$.localId, not element.$.localId") 69 "Please only use this.$.localId, not element.$.localId")
70 70
71 def WrapperTypeCheck(self, i, line): 71 def WrapperTypeCheck(self, i, line):
72 """Check for wrappers (new String()) instead of builtins (string).""" 72 """Check for wrappers (new String()) instead of builtins (string)."""
73 return self.RegexCheck(i, line, 73 return self.RegexCheck(i, line,
74 r"(?:/\*)?\*.*?@(?:param|return|type) ?" # /** @param/@return/@type 74 r"(?:/\*)?\*.*?@(?:param|return|type) ?" # /** @param/@return/@type
75 r"{[^}]*\b(String|Boolean|Number)\b[^}]*}", # {(Boolean|Number|String)} 75 r"{[^}]*\b(String|Boolean|Number)\b[^}]*}", # {(Boolean|Number|String)}
76 "Don't use wrapper types (i.e. new String() or @type {String})") 76 "Don't use wrapper types (i.e. new String() or @type {String})")
77 77
78 def VarNameCheck(self, i, line): 78 def VarNameCheck(self, i, line):
79 """See the style guide. http://goo.gl/uKir6""" 79 """See the style guide. http://goo.gl/eQiXVW"""
80 return self.RegexCheck(i, line, 80 return self.RegexCheck(i, line,
81 r"var (?!g_\w+)([a-z]*[_$][\w_$]*)(?<! \$)", 81 r"var (?!g_\w+)(_?[a-z][a-zA-Z]*[_$][\w_$]*)(?<! \$)",
82 "Please use var namesLikeThis <http://goo.gl/uKir6>") 82 "Please use var namesLikeThis <https://goo.gl/eQiXVW>")
83 83
84 def _GetErrorHighlight(self, start, length): 84 def _GetErrorHighlight(self, start, length):
85 """Takes a start position and a length, and produces a row of '^'s to 85 """Takes a start position and a length, and produces a row of '^'s to
86 highlight the corresponding part of a string. 86 highlight the corresponding part of a string.
87 """ 87 """
88 return start * ' ' + length * '^' 88 return start * ' ' + length * '^'
89 89
90 def RunChecks(self): 90 def RunChecks(self):
91 """Check for violations of the Chromium JavaScript style guide. See 91 """Check for violations of the Chromium JavaScript style guide. See
92 http://chromium.org/developers/web-development-style-guide#TOC-JavaScript 92 http://chromium.org/developers/web-development-style-guide#TOC-JavaScript
(...skipping 28 matching lines...) Expand all
121 f.LocalPath()] + error_lines 121 f.LocalPath()] + error_lines
122 results.append(self.output_api.PresubmitError('\n'.join(error_lines))) 122 results.append(self.output_api.PresubmitError('\n'.join(error_lines)))
123 123
124 if results: 124 if results:
125 results.append(self.output_api.PresubmitNotifyResult( 125 results.append(self.output_api.PresubmitNotifyResult(
126 'See the JavaScript style guide at ' 126 'See the JavaScript style guide at '
127 'http://www.chromium.org/developers/web-development-style-guide' 127 'http://www.chromium.org/developers/web-development-style-guide'
128 '#TOC-JavaScript')) 128 '#TOC-JavaScript'))
129 129
130 return results 130 return results
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/web_dev_style/js_checker_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698