blob: 40e9bfe8b275442f33c52af0d300ed3afe551332 [file] [log] [blame]
Yang Guo4fd355c2019-09-19 10:59:03 +02001/**
2 * @fileoverview Rule to flag when using javascript: urls
3 * @author Ilya Volodin
4 */
5/* jshint scripturl: true */
6/* eslint no-script-url: 0 */
7
8"use strict";
9
10//------------------------------------------------------------------------------
11// Rule Definition
12//------------------------------------------------------------------------------
13
14module.exports = {
15 meta: {
16 type: "suggestion",
17
18 docs: {
19 description: "disallow `javascript:` urls",
20 category: "Best Practices",
21 recommended: false,
22 url: "https://eslint.org/docs/rules/no-script-url"
23 },
24
25 schema: []
26 },
27
28 create(context) {
29
30 return {
31
32 Literal(node) {
33 if (node.value && typeof node.value === "string") {
34 const value = node.value.toLowerCase();
35
36 if (value.indexOf("javascript:") === 0) {
37 context.report({ node, message: "Script URL is a form of eval." });
38 }
39 }
40 }
41 };
42
43 }
44};