]> git.proxmox.com Git - pve-eslint.git/blame - 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
CommitLineData
eb39fafa
DC
1/**
2 * @fileoverview Rule which modifies AST.
3 * @author Toru Nagashima
4 */
5
6"use strict";
7
8//------------------------------------------------------------------------------
9// Rule Definition
10//------------------------------------------------------------------------------
11
8f9d1d4d
DC
12module.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 }
eb39fafa 33 }
8f9d1d4d
DC
34 });
35 },
eb39fafa 36
8f9d1d4d
DC
37 "Identifier": function(node) {
38 if (node.name === "bar") {
39 context.report({message: "error", node: node});
40 }
eb39fafa 41 }
8f9d1d4d
DC
42 };
43 },
eb39fafa 44};