main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[d565449] | 1 | /**
|
---|
| 2 | * @fileoverview Rule to disallow use of new operator with the `require` function
|
---|
| 3 | * @author Wil Moore III
|
---|
| 4 | * @deprecated in ESLint v7.0.0
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | "use strict";
|
---|
| 8 |
|
---|
| 9 | //------------------------------------------------------------------------------
|
---|
| 10 | // Rule Definition
|
---|
| 11 | //------------------------------------------------------------------------------
|
---|
| 12 |
|
---|
| 13 | /** @type {import('../shared/types').Rule} */
|
---|
| 14 | module.exports = {
|
---|
| 15 | meta: {
|
---|
| 16 | deprecated: true,
|
---|
| 17 |
|
---|
| 18 | replacedBy: [],
|
---|
| 19 |
|
---|
| 20 | type: "suggestion",
|
---|
| 21 |
|
---|
| 22 | docs: {
|
---|
| 23 | description: "Disallow `new` operators with calls to `require`",
|
---|
| 24 | recommended: false,
|
---|
| 25 | url: "https://eslint.org/docs/latest/rules/no-new-require"
|
---|
| 26 | },
|
---|
| 27 |
|
---|
| 28 | schema: [],
|
---|
| 29 |
|
---|
| 30 | messages: {
|
---|
| 31 | noNewRequire: "Unexpected use of new with require."
|
---|
| 32 | }
|
---|
| 33 | },
|
---|
| 34 |
|
---|
| 35 | create(context) {
|
---|
| 36 |
|
---|
| 37 | return {
|
---|
| 38 |
|
---|
| 39 | NewExpression(node) {
|
---|
| 40 | if (node.callee.type === "Identifier" && node.callee.name === "require") {
|
---|
| 41 | context.report({
|
---|
| 42 | node,
|
---|
| 43 | messageId: "noNewRequire"
|
---|
| 44 | });
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 | };
|
---|
| 48 |
|
---|
| 49 | }
|
---|
| 50 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.