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

Side by Side Diff: third_party/WebKit/Source/devtools/PRESUBMIT.py

Issue 1992383002: DevTools: add eslint as presubmit hook (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 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 | third_party/WebKit/Source/devtools/front_end/.eslintignore » ('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) 2014 Google Inc. All rights reserved. 1 # Copyright (C) 2014 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 18 matching lines...) Expand all
29 """DevTools JSDoc validator presubmit script 29 """DevTools JSDoc validator presubmit script
30 30
31 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 31 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
32 for more details about the presubmit API built into gcl. 32 for more details about the presubmit API built into gcl.
33 """ 33 """
34 34
35 import sys 35 import sys
36 36
37 compile_note = "Be sure to run your patch by the compile_frontend.py script prio r to committing!" 37 compile_note = "Be sure to run your patch by the compile_frontend.py script prio r to committing!"
38 38
39
40 def _CheckDevtoolsStyle(input_api, output_api):
41 local_paths = [f.AbsoluteLocalPath() for f in input_api.AffectedFiles() if f .Action() != "D"]
42
43 devtools_root = input_api.PresubmitLocalPath()
44 devtools_front_end = input_api.os_path.join(devtools_root, "front_end")
45 affected_front_end_files = [file_name for file_name in local_paths if devtoo ls_front_end in file_name and file_name.endswith(".js")]
46 affected_front_end_files = [input_api.os_path.relpath(file_name, devtools_ro ot) for file_name in affected_front_end_files]
47 if len(affected_front_end_files) > 0:
48 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(),
49 "scripts", "lint_javascript.py")
50 process = input_api.subprocess.Popen(
51 [input_api.python_executable, lint_path] + affected_front_end_files,
52 stdout=input_api.subprocess.PIPE,
53 stderr=input_api.subprocess.STDOUT)
54 out, _ = process.communicate()
55 if process.returncode != 0:
56 return [output_api.PresubmitError(out)]
57 if "NOTE" in out:
58 return [output_api.PresubmitPromptWarning(out)]
59 return []
60
61
39 def _CompileDevtoolsFrontend(input_api, output_api): 62 def _CompileDevtoolsFrontend(input_api, output_api):
40 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] 63 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()]
41 64
42 # FIXME: The compilation does not actually run if injected script-related fi les 65 # FIXME: The compilation does not actually run if injected script-related fi les
43 # have changed, as they reside in core/inspector, which is not affected 66 # have changed, as they reside in core/inspector, which is not affected
44 # by this presubmit. 67 # by this presubmit.
45 # Once this is fixed, injected_script_externs.js 68 # Once this is fixed, injected_script_externs.js
46 # should be added to the list of triggers. 69 # should be added to the list of triggers.
47 devtools_front_end = input_api.os_path.join("devtools", "front_end") 70 devtools_front_end = input_api.os_path.join("devtools", "front_end")
48 if (any(devtools_front_end in path for path in local_paths) or 71 if (any(devtools_front_end in path for path in local_paths) or
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 for line_number, line in f.ChangedContents(): 145 for line_number, line in f.ChangedContents():
123 if "/deep/" in line: 146 if "/deep/" in line:
124 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel ector") % (f.LocalPath(), line_number))) 147 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel ector") % (f.LocalPath(), line_number)))
125 if "::shadow" in line: 148 if "::shadow" in line:
126 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s elector") % (f.LocalPath(), line_number))) 149 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s elector") % (f.LocalPath(), line_number)))
127 return results 150 return results
128 151
129 152
130 def CheckChangeOnUpload(input_api, output_api): 153 def CheckChangeOnUpload(input_api, output_api):
131 results = [] 154 results = []
155 results.extend(_CheckDevtoolsStyle(input_api, output_api))
132 results.extend(_CompileDevtoolsFrontend(input_api, output_api)) 156 results.extend(_CompileDevtoolsFrontend(input_api, output_api))
133 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api)) 157 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api))
134 results.extend(_CheckOptimizePNGHashes(input_api, output_api)) 158 results.extend(_CheckOptimizePNGHashes(input_api, output_api))
135 results.extend(_CheckCSSViolations(input_api, output_api)) 159 results.extend(_CheckCSSViolations(input_api, output_api))
136 return results 160 return results
137 161
138 162
139 def CheckChangeOnCommit(input_api, output_api): 163 def CheckChangeOnCommit(input_api, output_api):
140 return [] 164 return []
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/.eslintignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698