summaryrefslogtreecommitdiff
path: root/tools/eslint/lib/rules/no-script-url.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/lib/rules/no-script-url.js')
-rw-r--r--tools/eslint/lib/rules/no-script-url.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/eslint/lib/rules/no-script-url.js b/tools/eslint/lib/rules/no-script-url.js
new file mode 100644
index 0000000000..9ae9ba1a3a
--- /dev/null
+++ b/tools/eslint/lib/rules/no-script-url.js
@@ -0,0 +1,32 @@
+/**
+ * @fileoverview Rule to flag when using javascript: urls
+ * @author Ilya Volodin
+ */
+/*jshint scripturl: true */
+/*eslint no-script-url: 0*/
+
+"use strict";
+
+//------------------------------------------------------------------------------
+// Rule Definition
+//------------------------------------------------------------------------------
+
+module.exports = function(context) {
+
+ return {
+
+ "Literal": function(node) {
+
+ var value;
+
+ if (node.value && typeof node.value === "string") {
+ value = node.value.toLowerCase();
+
+ if (value.indexOf("javascript:") === 0) {
+ context.report(node, "Script URL is a form of eval.");
+ }
+ }
+ }
+ };
+
+};