1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 def EscapeJSIfNeeded(js):
6 return js.replace("</script>", "<\/script>")
8 def ValidateUsesStrictMode(module_name, stripped_text):
9 """Check that the first non-empty line is 'use strict';.
12 stripped_text: Javascript source code with comments stripped out.
15 DepsException: This file doesn't use strict mode.
17 lines = stripped_text.split('\n')
20 if len(line.strip()) == 0:
22 if """'use strict';""" in line.strip():
24 raise module.DepsException('%s must use strict mode' % module_name)