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.4 KB
|
Line | |
---|
1 | /**
|
---|
2 | * @fileoverview disallow use of the Buffer() constructor
|
---|
3 | * @author Teddy Katz
|
---|
4 | * @deprecated in ESLint v7.0.0
|
---|
5 | */
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | //------------------------------------------------------------------------------
|
---|
9 | // Rule Definition
|
---|
10 | //------------------------------------------------------------------------------
|
---|
11 |
|
---|
12 | /** @type {import('../shared/types').Rule} */
|
---|
13 | module.exports = {
|
---|
14 | meta: {
|
---|
15 | deprecated: true,
|
---|
16 |
|
---|
17 | replacedBy: [],
|
---|
18 |
|
---|
19 | type: "problem",
|
---|
20 |
|
---|
21 | docs: {
|
---|
22 | description: "Disallow use of the `Buffer()` constructor",
|
---|
23 | recommended: false,
|
---|
24 | url: "https://eslint.org/docs/latest/rules/no-buffer-constructor"
|
---|
25 | },
|
---|
26 |
|
---|
27 | schema: [],
|
---|
28 |
|
---|
29 | messages: {
|
---|
30 | deprecated: "{{expr}} is deprecated. Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead."
|
---|
31 | }
|
---|
32 | },
|
---|
33 |
|
---|
34 | create(context) {
|
---|
35 |
|
---|
36 | //----------------------------------------------------------------------
|
---|
37 | // Public
|
---|
38 | //----------------------------------------------------------------------
|
---|
39 |
|
---|
40 | return {
|
---|
41 | "CallExpression[callee.name='Buffer'], NewExpression[callee.name='Buffer']"(node) {
|
---|
42 | context.report({
|
---|
43 | node,
|
---|
44 | messageId: "deprecated",
|
---|
45 | data: { expr: node.type === "CallExpression" ? "Buffer()" : "new Buffer()" }
|
---|
46 | });
|
---|
47 | }
|
---|
48 | };
|
---|
49 | }
|
---|
50 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.