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

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: 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
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.LocalPath() for f in input_api.AffectedFiles() if f.Action( ) != "D"]
42
43 devtools_front_end = input_api.os_path.join("devtools", "front_end")
44 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")]
45 affected_front_end_files = [input_api.os_path.join("front_end", file_name.sp lit(devtools_front_end).pop()[1:]) for file_name in affected_front_end_files]
46 if len(affected_front_end_files) > 0:
47 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(),
48 "scripts", "lint_javascript.py")
49 out, _ = input_api.subprocess.Popen(
50 [input_api.python_executable, lint_path] + affected_front_end_files,
51 stdout=input_api.subprocess.PIPE,
52 stderr=input_api.subprocess.STDOUT).communicate()
53 if "error" in out or "warning" in out:
paulirish 2016/05/20 20:26:22 You should use the exit code instead. Generally,
lushnikov 2016/05/20 20:54:56 Done.
54 return [output_api.PresubmitError(out)]
55 if "NOTE" in out:
56 return [output_api.PresubmitPromptWarning(out)]
57 return []
58
59
39 def _CompileDevtoolsFrontend(input_api, output_api): 60 def _CompileDevtoolsFrontend(input_api, output_api):
40 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] 61 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()]
41 62
42 # FIXME: The compilation does not actually run if injected script-related fi les 63 # 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 64 # have changed, as they reside in core/inspector, which is not affected
44 # by this presubmit. 65 # by this presubmit.
45 # Once this is fixed, injected_script_externs.js 66 # Once this is fixed, injected_script_externs.js
46 # should be added to the list of triggers. 67 # should be added to the list of triggers.
47 devtools_front_end = input_api.os_path.join("devtools", "front_end") 68 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 69 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(): 143 for line_number, line in f.ChangedContents():
123 if "/deep/" in line: 144 if "/deep/" in line:
124 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel ector") % (f.LocalPath(), line_number))) 145 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel ector") % (f.LocalPath(), line_number)))
125 if "::shadow" in line: 146 if "::shadow" in line:
126 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s elector") % (f.LocalPath(), line_number))) 147 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s elector") % (f.LocalPath(), line_number)))
127 return results 148 return results
128 149
129 150
130 def CheckChangeOnUpload(input_api, output_api): 151 def CheckChangeOnUpload(input_api, output_api):
131 results = [] 152 results = []
153 results.extend(_CheckDevtoolsStyle(input_api, output_api))
132 results.extend(_CompileDevtoolsFrontend(input_api, output_api)) 154 results.extend(_CompileDevtoolsFrontend(input_api, output_api))
133 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api)) 155 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api))
134 results.extend(_CheckOptimizePNGHashes(input_api, output_api)) 156 results.extend(_CheckOptimizePNGHashes(input_api, output_api))
135 results.extend(_CheckCSSViolations(input_api, output_api)) 157 results.extend(_CheckCSSViolations(input_api, output_api))
136 return results 158 return results
137 159
138 160
139 def CheckChangeOnCommit(input_api, output_api): 161 def CheckChangeOnCommit(input_api, output_api):
140 return [] 162 return []
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698