]> git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/fixtures/testers/rule-tester/modify-ast-at-first.js
import 8.23.1 source
[pve-eslint.git] / eslint / tests / fixtures / testers / rule-tester / modify-ast-at-first.js
1 /**
2 * @fileoverview Rule which modifies AST.
3 * @author Toru Nagashima
4 */
5
6 "use strict";
7
8 //------------------------------------------------------------------------------
9 // Rule Definition
10 //------------------------------------------------------------------------------
11
12 module.exports = {
13 meta: {
14 type: "problem",
15 schema: []
16 },
17 create(context) {
18 return {
19 "Program": function(node) {
20 node.body.push({
21 "type": "Identifier",
22 "name": "modified",
23 "range": [0, 8],
24 "loc": {
25 "start": {
26 "line": 1,
27 "column": 0
28 },
29 "end": {
30 "line": 1,
31 "column": 8
32 }
33 }
34 });
35 },
36
37 "Identifier": function(node) {
38 if (node.name === "bar") {
39 context.report({message: "error", node: node});
40 }
41 }
42 };
43 },
44 };