]> git.proxmox.com Git - pve-eslint.git/blame - eslint/tests/tools/internal-rules/consistent-docs-url.js
import 7.12.1 upstream release
[pve-eslint.git] / eslint / tests / tools / internal-rules / consistent-docs-url.js
CommitLineData
eb39fafa
DC
1/**
2 * @fileoverview Tests for internal-consistent-docs-url rule.
3 * @author Patrick McElhaney
4 */
5
6"use strict";
7
8//------------------------------------------------------------------------------
9// Requirements
10//------------------------------------------------------------------------------
11
12const rule = require("../../../tools/internal-rules/consistent-docs-url"),
13 { RuleTester } = require("../../../lib/rule-tester");
14
15//------------------------------------------------------------------------------
16// Tests
17//------------------------------------------------------------------------------
18
19const ruleTester = new RuleTester();
20
21ruleTester.run("consistent-docs-url", rule, {
22 valid: [
23
24 // wrong exports format: "internal-no-invalid-meta" reports this already
25 [
26 "module.exports = function(context) {",
27 " return {",
28 " Program: function(node) {}",
29 " };",
30 "};"
31 ].join("\n"),
32 [
33 "module.exports = {",
34 " meta: {",
35 " docs: {",
36 " url: 'https://eslint.org/docs/rules/<input>'",
37 " }",
38 " },",
39 " create: function(context) {",
40 " return {};",
41 " }",
42 "};"
43 ].join("\n")
44 ],
45 invalid: [
46 {
47 code: [
48 "module.exports = {",
49 " meta: {",
50 " },",
51
52 " create: function(context) {",
53 " return {};",
54 " }",
55 "};"
56 ].join("\n"),
57 errors: [{
6f036462 58 messageId: "missingMetaDocs",
eb39fafa
DC
59 line: 2,
60 column: 5
61 }]
62 },
63 {
64 code: [
65 "module.exports = {",
66 " meta: {",
67 " docs: {}",
68 " },",
69
70 " create: function(context) {",
71 " return {};",
72 " }",
73 "};"
74 ].join("\n"),
75 errors: [{
6f036462 76 messageId: "missingMetaDocsUrl",
eb39fafa
DC
77 line: 3,
78 column: 9
79 }]
80 },
81 {
82 code: [
83 "module.exports = {",
84 " meta: {",
85 " docs: {",
86 " url: 'http://example.com/wrong-url'",
87 " }",
88 " },",
89 " create: function(context) {",
90 " return {};",
91 " }",
92 "};"
93 ].join("\n"),
94 errors: [{
6f036462
TL
95 messageId: "incorrectUrl",
96 data: {
97 expected: "https://eslint.org/docs/rules/<input>",
98 url: "http://example.com/wrong-url"
99 },
eb39fafa
DC
100 line: 4,
101 column: 18
102 }]
103 }
104 ]
105});