mirror of
https://github.com/nodejs/node.git
synced 2025-05-14 21:36:02 +00:00

This is required because we need to add the babel-eslint dependency and it has to be able to resolve "eslint". babel-eslint is required to support future ES features such as async iterators and import.meta. Refs: https://github.com/nodejs/node/pull/17755 PR-URL: https://github.com/nodejs/node/pull/17820 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
42 lines
987 B
JavaScript
42 lines
987 B
JavaScript
/**
|
|
* @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 = {
|
|
meta: {
|
|
docs: {
|
|
description: "disallow `javascript:` urls",
|
|
category: "Best Practices",
|
|
recommended: false
|
|
},
|
|
|
|
schema: []
|
|
},
|
|
|
|
create(context) {
|
|
|
|
return {
|
|
|
|
Literal(node) {
|
|
if (node.value && typeof node.value === "string") {
|
|
const value = node.value.toLowerCase();
|
|
|
|
if (value.indexOf("javascript:") === 0) {
|
|
context.report({ node, message: "Script URL is a form of eval." });
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
}
|
|
};
|