]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/no-warning-comments.js
2 * @fileoverview Tests for no-warning-comments rule.
3 * @author Alexander Schmidt <https://github.com/lxanders>
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/no-warning-comments"),
13 { RuleTester
} = require("../../../lib/rule-tester");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
19 const ruleTester
= new RuleTester();
21 ruleTester
.run("no-warning-comments", rule
, {
23 { code
: "// any comment", options
: [{ terms
: ["fixme"] }] },
24 { code
: "// any comment", options
: [{ terms
: ["fixme", "todo"] }] },
26 { code
: "// any comment", options
: [{ location
: "anywhere" }] },
27 { code
: "// any comment with TODO, FIXME or XXX", options
: [{ location
: "start" }] },
28 "// any comment with TODO, FIXME or XXX",
29 { code
: "/* any block comment */", options
: [{ terms
: ["fixme"] }] },
30 { code
: "/* any block comment */", options
: [{ terms
: ["fixme", "todo"] }] },
31 "/* any block comment */",
32 { code
: "/* any block comment */", options
: [{ location
: "anywhere" }] },
33 { code
: "/* any block comment with TODO, FIXME or XXX */", options
: [{ location
: "start" }] },
34 "/* any block comment with TODO, FIXME or XXX */",
35 "/* any block comment with (TODO, FIXME's or XXX!) */",
36 { code
: "// comments containing terms as substrings like TodoMVC", options
: [{ terms
: ["todo"], location
: "anywhere" }] },
37 { code
: "// special regex characters don't cause a problem", options
: [{ terms
: ["[aeiou]"], location
: "anywhere" }] },
38 "/*eslint no-warning-comments: [2, { \"terms\": [\"todo\", \"fixme\", \"any other term\"], \"location\": \"anywhere\" }]*/\n\nvar x = 10;\n",
39 { code
: "/*eslint no-warning-comments: [2, { \"terms\": [\"todo\", \"fixme\", \"any other term\"], \"location\": \"anywhere\" }]*/\n\nvar x = 10;\n", options
: [{ location
: "anywhere" }] },
40 { code
: "// foo", options
: [{ terms
: ["foo-bar"] }] },
41 "/** multi-line block comment with lines starting with\nTODO\nFIXME or\nXXX\n*/",
42 { code
: "//!TODO ", options
: [{ decoration
: ["*"] }] }
48 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "fixme" } }
53 options
: [{ location
: "anywhere" }],
55 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any fixme" } }
60 options
: [{ terms
: ["fixme"], location
: "anywhere" }],
62 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any fixme" } }
67 options
: [{ terms
: ["fixme"], location
: "anywhere" }],
69 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any FIXME" } }
74 options
: [{ terms
: ["fixme"], location
: "anywhere" }],
76 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any fIxMe" } }
80 code
: "/* any fixme */",
81 options
: [{ terms
: ["FIXME"], location
: "anywhere" }],
83 { messageId
: "unexpectedComment", data
: { matchedTerm
: "FIXME", comment
: "any fixme" } }
87 code
: "/* any FIXME */",
88 options
: [{ terms
: ["FIXME"], location
: "anywhere" }],
90 { messageId
: "unexpectedComment", data
: { matchedTerm
: "FIXME", comment
: "any FIXME" } }
94 code
: "/* any fIxMe */",
95 options
: [{ terms
: ["FIXME"], location
: "anywhere" }],
97 { messageId
: "unexpectedComment", data
: { matchedTerm
: "FIXME", comment
: "any fIxMe" } }
101 code
: "// any fixme or todo",
102 options
: [{ terms
: ["fixme", "todo"], location
: "anywhere" }],
104 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any fixme or todo" } },
105 { messageId
: "unexpectedComment", data
: { matchedTerm
: "todo", comment
: "any fixme or todo" } }
109 code
: "/* any fixme or todo */",
110 options
: [{ terms
: ["fixme", "todo"], location
: "anywhere" }],
112 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any fixme or todo" } },
113 { messageId
: "unexpectedComment", data
: { matchedTerm
: "todo", comment
: "any fixme or todo" } }
117 code
: "/* any fixme or todo */",
118 options
: [{ location
: "anywhere" }],
120 { messageId
: "unexpectedComment", data
: { matchedTerm
: "todo", comment
: "any fixme or todo" } },
121 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any fixme or todo" } }
125 code
: "/* fixme and todo */",
127 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "fixme and todo" } }
131 code
: "/* fixme and todo */",
132 options
: [{ location
: "anywhere" }],
134 { messageId
: "unexpectedComment", data
: { matchedTerm
: "todo", comment
: "fixme and todo" } },
135 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "fixme and todo" } }
139 code
: "/* any fixme */",
140 options
: [{ location
: "anywhere" }],
142 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any fixme" } }
146 code
: "/* fixme! */",
147 options
: [{ terms
: ["fixme"] }],
149 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "fixme!" } }
153 code
: "// regex [litera|$]",
154 options
: [{ terms
: ["[litera|$]"], location
: "anywhere" }],
156 { messageId
: "unexpectedComment", data
: { matchedTerm
: "[litera|$]", comment
: "regex [litera|$]" } }
160 code
: "/* eslint one-var: 2 */",
161 options
: [{ terms
: ["eslint"] }],
163 { messageId
: "unexpectedComment", data
: { matchedTerm
: "eslint", comment
: "eslint one-var: 2" } }
167 code
: "/* eslint one-var: 2 */",
168 options
: [{ terms
: ["one"], location
: "anywhere" }],
170 { messageId
: "unexpectedComment", data
: { matchedTerm
: "one", comment
: "eslint one-var: 2" } }
174 code
: "/* any block comment with TODO, FIXME or XXX */",
175 options
: [{ location
: "anywhere" }],
177 { messageId
: "unexpectedComment", data
: { matchedTerm
: "todo", comment
: "any block comment with TODO, FIXME or..." } },
178 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any block comment with TODO, FIXME or..." } },
179 { messageId
: "unexpectedComment", data
: { matchedTerm
: "xxx", comment
: "any block comment with TODO, FIXME or..." } }
183 code
: "/* any block comment with (TODO, FIXME's or XXX!) */",
184 options
: [{ location
: "anywhere" }],
186 { messageId
: "unexpectedComment", data
: { matchedTerm
: "todo", comment
: "any block comment with (TODO, FIXME's or..." } },
187 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any block comment with (TODO, FIXME's or..." } },
188 { messageId
: "unexpectedComment", data
: { matchedTerm
: "xxx", comment
: "any block comment with (TODO, FIXME's or..." } }
192 code
: "/** \n *any block comment \n*with (TODO, FIXME's or XXX!) **/",
193 options
: [{ location
: "anywhere" }],
195 { messageId
: "unexpectedComment", data
: { matchedTerm
: "todo", comment
: "* *any block comment *with (TODO,..." } },
196 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "* *any block comment *with (TODO,..." } },
197 { messageId
: "unexpectedComment", data
: { matchedTerm
: "xxx", comment
: "* *any block comment *with (TODO,..." } }
201 code
: "// any comment with TODO, FIXME or XXX",
202 options
: [{ location
: "anywhere" }],
204 { messageId
: "unexpectedComment", data
: { matchedTerm
: "todo", comment
: "any comment with TODO, FIXME or XXX" } },
205 { messageId
: "unexpectedComment", data
: { matchedTerm
: "fixme", comment
: "any comment with TODO, FIXME or XXX" } },
206 { messageId
: "unexpectedComment", data
: { matchedTerm
: "xxx", comment
: "any comment with TODO, FIXME or XXX" } }
210 code
: "// TODO: something small",
211 options
: [{ location
: "anywhere" }],
213 { messageId
: "unexpectedComment", data
: { matchedTerm
: "todo", comment
: "TODO: something small" } }
217 code
: "// TODO: something really longer than 40 characters",
218 options
: [{ location
: "anywhere" }],
220 { messageId
: "unexpectedComment", data
: { matchedTerm
: "todo", comment
: "TODO: something really longer than 40..." } }
225 "/* TODO: something \n really longer than 40 characters \n and also a new line */",
226 options
: [{ location
: "anywhere" }],
229 messageId
: "unexpectedComment",
232 comment
: "TODO: something really longer than 40..."
238 code
: "// TODO: small",
239 options
: [{ location
: "anywhere" }],
242 messageId
: "unexpectedComment",
245 comment
: "TODO: small"
251 code
: "// https://github.com/eslint/eslint/pull/13522#discussion_r470293411 TODO",
252 options
: [{ location
: "anywhere" }],
255 messageId
: "unexpectedComment",
264 code
: "// Comment ending with term followed by punctuation TODO!",
265 options
: [{ terms
: ["todo"], location
: "anywhere" }],
268 messageId
: "unexpectedComment",
271 comment
: "Comment ending with term followed by..."
277 code
: "// Comment ending with term including punctuation TODO!",
278 options
: [{ terms
: ["todo!"], location
: "anywhere" }],
281 messageId
: "unexpectedComment",
283 matchedTerm
: "todo!",
284 comment
: "Comment ending with term including..."
290 code
: "// Comment ending with term including punctuation followed by more TODO!!!",
291 options
: [{ terms
: ["todo!"], location
: "anywhere" }],
294 messageId
: "unexpectedComment",
296 matchedTerm
: "todo!",
297 comment
: "Comment ending with term including..."
303 code
: "// !TODO comment starting with term preceded by punctuation",
304 options
: [{ terms
: ["todo"], location
: "anywhere" }],
307 messageId
: "unexpectedComment",
310 comment
: "!TODO comment starting with term..."
316 code
: "// !TODO comment starting with term including punctuation",
317 options
: [{ terms
: ["!todo"], location
: "anywhere" }],
320 messageId
: "unexpectedComment",
322 matchedTerm
: "!todo",
323 comment
: "!TODO comment starting with term..."
329 code
: "// !!!TODO comment starting with term including punctuation preceded by more",
330 options
: [{ terms
: ["!todo"], location
: "anywhere" }],
333 messageId
: "unexpectedComment",
335 matchedTerm
: "!todo",
336 comment
: "!!!TODO comment starting with term..."
342 code
: "// FIX!term ending with punctuation followed word character",
343 options
: [{ terms
: ["FIX!"], location
: "anywhere" }],
346 messageId
: "unexpectedComment",
349 comment
: "FIX!term ending with punctuation..."
355 code
: "// Term starting with punctuation preceded word character!FIX",
356 options
: [{ terms
: ["!FIX"], location
: "anywhere" }],
359 messageId
: "unexpectedComment",
362 comment
: "Term starting with punctuation preceded..."
368 code
: "//!XXX comment starting with no spaces (anywhere)",
369 options
: [{ terms
: ["!xxx"], location
: "anywhere" }],
372 messageId
: "unexpectedComment",
375 comment
: "!XXX comment starting with no spaces..."
381 code
: "//!XXX comment starting with no spaces (start)",
382 options
: [{ terms
: ["!xxx"], location
: "start" }],
385 messageId
: "unexpectedComment",
388 comment
: "!XXX comment starting with no spaces..."
394 code
: "/*\nTODO undecorated multi-line block comment (start)\n*/",
395 options
: [{ terms
: ["todo"], location
: "start" }],
398 messageId
: "unexpectedComment",
401 comment
: "TODO undecorated multi-line block..."
407 code
: "///// TODO decorated single-line comment with decoration array \n /////",
408 options
: [{ terms
: ["todo"], location
: "start", decoration
: ["*", "/"] }],
411 messageId
: "unexpectedComment",
414 comment
: "/// TODO decorated single-line comment..."
420 code
: "///*/*/ TODO decorated single-line comment with multiple decoration characters (start) \n /////",
421 options
: [{ terms
: ["todo"], location
: "start", decoration
: ["*", "/"] }],
424 messageId
: "unexpectedComment",
427 comment
: "/*/*/ TODO decorated single-line comment..."
433 code
: "//**TODO term starts with a decoration character",
434 options
: [{ terms
: ["*todo"], location
: "start", decoration
: ["*"] }],
437 messageId
: "unexpectedComment",
439 matchedTerm
: "*todo",
440 comment
: "**TODO term starts with a decoration..."