2 * @fileoverview Test enforcement of lines around comments.
3 * @author Jamund Ferguson
7 //------------------------------------------------------------------------------
9 //------------------------------------------------------------------------------
11 const rule
= require("../../../lib/rules/lines-around-comment"),
12 { RuleTester
} = require("../../../lib/rule-tester"),
13 { unIndent
} = require("../../_utils");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
19 const ruleTester
= new RuleTester();
21 ruleTester
.run("lines-around-comment", rule
, {
26 "bar()\n\n/** block block block\n * block \n */\n\nvar a = 1;",
27 "bar()\n\n/** block block block\n * block \n */\nvar a = 1;",
28 "bar()\n// line line line \nvar a = 1;",
29 "bar()\n\n// line line line\nvar a = 1;",
30 "bar()\n// line line line\n\nvar a = 1;",
34 code
: "bar()\n// line line line\n\nvar a = 1;",
35 options
: [{ afterLineComment
: true }]
38 code
: "foo()\n\n// line line line\nvar a = 1;",
39 options
: [{ beforeLineComment
: true }]
42 code
: "foo()\n\n// line line line\n\nvar a = 1;",
43 options
: [{ beforeLineComment
: true, afterLineComment
: true }]
46 code
: "foo()\n\n// line line line\n// line line\n\nvar a = 1;",
47 options
: [{ beforeLineComment
: true, afterLineComment
: true }]
50 code
: "// line line line\n// line line",
51 options
: [{ beforeLineComment
: true, afterLineComment
: true }]
56 code
: "bar()\n\n/** A Block comment with a an empty line after\n *\n */\nvar a = 1;",
57 options
: [{ afterBlockComment
: false, beforeBlockComment
: true }]
60 code
: "bar()\n\n/** block block block\n * block \n */\nvar a = 1;",
61 options
: [{ afterBlockComment
: false }]
64 code
: "/** \nblock \nblock block\n */\n/* block \n block \n */",
65 options
: [{ afterBlockComment
: true, beforeBlockComment
: true }]
68 code
: "bar()\n\n/** block block block\n * block \n */\n\nvar a = 1;",
69 options
: [{ afterBlockComment
: true, beforeBlockComment
: true }]
72 // inline comments (should not ever warn)
74 code
: "foo() // An inline comment with a an empty line after\nvar a = 1;",
75 options
: [{ afterLineComment
: true, beforeLineComment
: true }]
78 code
: "foo();\nbar() /* An inline block comment with a an empty line after\n *\n */\nvar a = 1;",
79 options
: [{ beforeBlockComment
: true }]
82 // mixed comment (some block & some line)
84 code
: "bar()\n\n/** block block block\n * block \n */\n//line line line\nvar a = 1;",
85 options
: [{ afterBlockComment
: true }]
88 code
: "bar()\n\n/** block block block\n * block \n */\n//line line line\nvar a = 1;",
89 options
: [{ beforeLineComment
: true }]
92 // check for block start comments
94 code
: "var a,\n\n// line\nb;",
96 beforeLineComment
: true,
101 code
: "function foo(){ \n// line at block start\nvar g = 1;\n}",
103 beforeLineComment
: true,
104 allowBlockStart
: true
108 code
: "function foo(){// line at block start\nvar g = 1;\n}",
110 beforeLineComment
: true,
111 allowBlockStart
: true
115 code
: "var foo = function(){\n// line at block start\nvar g = 1;\n}",
117 beforeLineComment
: true,
118 allowBlockStart
: true
122 code
: "var foo = function(){\n// line at block start\n}",
124 beforeLineComment
: true,
125 allowBlockStart
: true
129 code
: "if(true){\n// line at block start\nvar g = 1;\n}",
131 beforeLineComment
: true,
132 allowBlockStart
: true
136 code
: "if(true){\n\n// line at block start\nvar g = 1;\n}",
138 beforeLineComment
: true,
139 allowBlockStart
: true
143 code
: "if(true){\n// line at block start\n}",
145 beforeLineComment
: true,
146 allowBlockStart
: true
150 code
: "if(true){ bar(); } else {\n// line at block start\n}",
152 beforeLineComment
: true,
153 allowBlockStart
: true
157 code
: "switch ('foo'){\ncase 'foo':\n// line at switch case start\nbreak;\n}",
159 beforeLineComment
: true,
160 allowBlockStart
: true
164 code
: "switch ('foo'){\ncase 'foo':\n\n// line at switch case start\nbreak;\n}",
166 beforeLineComment
: true,
167 allowBlockStart
: true
171 code
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\n// line at switch case start\nbreak;\n}",
173 beforeLineComment
: true,
174 allowBlockStart
: true
178 code
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\n\n// line at switch case start\nbreak;\n}",
180 beforeLineComment
: true,
181 allowBlockStart
: true
185 code
: "function foo(){ \n/* block comment at block start */\nvar g = 1;\n}",
187 allowBlockStart
: true
191 code
: "function foo(){/* block comment at block start */\nvar g = 1;\n}",
193 allowBlockStart
: true
197 code
: "var foo = function(){\n/* block comment at block start */\nvar g = 1;\n}",
199 allowBlockStart
: true
203 code
: "if(true){\n/* block comment at block start */\nvar g = 1;\n}",
205 allowBlockStart
: true
209 code
: "if(true){\n\n/* block comment at block start */\nvar g = 1;\n}",
211 allowBlockStart
: true
215 code
: "while(true){\n\n/* \nblock comment at block start\n */\nvar g = 1;\n}",
217 allowBlockStart
: true
221 code
: "class A {\n/**\n* hi\n */\nconstructor() {}\n}",
223 allowBlockStart
: true
225 parserOptions
: { ecmaVersion
: 6 }
228 code
: "class A {\n/**\n* hi\n */\nconstructor() {}\n}",
230 allowClassStart
: true
232 parserOptions
: { ecmaVersion
: 6 }
235 code
: "class A {\n/**\n* hi\n */\nconstructor() {}\n}",
237 allowBlockStart
: false,
238 allowClassStart
: true
240 parserOptions
: { ecmaVersion
: 6 }
243 code
: "switch ('foo'){\ncase 'foo':\n/* block comment at switch case start */\nbreak;\n}",
245 allowBlockStart
: true
249 code
: "switch ('foo'){\ncase 'foo':\n\n/* block comment at switch case start */\nbreak;\n}",
251 allowBlockStart
: true
255 code
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\n/* block comment at switch case start */\nbreak;\n}",
257 allowBlockStart
: true
261 code
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\n\n/* block comment at switch case start */\nbreak;\n}",
263 allowBlockStart
: true
279 beforeLineComment
: true,
280 allowBlockStart
: true
282 parserOptions
: { ecmaVersion
: 2022 }
299 beforeLineComment
: true,
300 allowBlockStart
: true
302 parserOptions
: { ecmaVersion
: 2022 }
328 beforeBlockComment
: true,
329 allowBlockStart
: true
331 parserOptions
: { ecmaVersion
: 2022 }
361 beforeBlockComment
: true,
362 allowBlockStart
: true
364 parserOptions
: { ecmaVersion
: 2022 }
367 // https://github.com/eslint/eslint/issues/16131
371 // this comment is allowed by allowBlockStart: true
377 // this comment is allowed by allowBlockEnd: true
381 allowBlockStart
: true,
382 beforeLineComment
: true,
383 afterLineComment
: true,
391 // this comment is allowed by allowBlockStart: true
399 allowBlockStart
: true,
400 beforeLineComment
: true,
401 afterLineComment
: true
410 // this comment is allowed by allowBlockStart: true
416 allowBlockStart
: true,
417 beforeLineComment
: true
421 // check for block end comments
423 code
: "var a,\n// line\n\nb;",
425 afterLineComment
: true,
430 code
: "function foo(){\nvar g = 91;\n// line at block end\n}",
432 afterLineComment
: true,
437 code
: "function foo(){\nvar g = 61;\n\n\n// line at block end\n}",
439 afterLineComment
: true,
444 code
: "var foo = function(){\nvar g = 1;\n\n\n// line at block end\n}",
446 afterLineComment
: true,
451 code
: "if(true){\nvar g = 1;\n// line at block end\n}",
453 afterLineComment
: true,
458 code
: "if(true){\nvar g = 1;\n\n// line at block end\n}",
460 afterLineComment
: true,
465 code
: "switch ('foo'){\ncase 'foo':\nvar g = 1;\n\n// line at switch case end\n}",
467 afterLineComment
: true,
472 code
: "switch ('foo'){\ncase 'foo':\nvar g = 1;\n\n// line at switch case end\n\n}",
474 afterLineComment
: true,
479 code
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\nvar g = 1;\n\n// line at switch case end\n}",
481 afterLineComment
: true,
486 code
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\nvar g = 1;\n\n// line at switch case end\n\n}",
488 afterLineComment
: true,
493 code
: "while(true){\n// line at block start and end\n}",
495 afterLineComment
: true,
500 code
: "while(true){\n// line at block start and end\n}",
502 afterLineComment
: true,
503 allowBlockStart
: true,
508 code
: "while(true){\n// line at block start and end\n}",
510 beforeLineComment
: true,
511 allowBlockStart
: true,
516 code
: "while(true){\n// line at block start and end\n}",
518 afterLineComment
: true,
519 beforeLineComment
: true,
520 allowBlockStart
: true,
525 code
: "while(true){\n// line at block start and end\n}",
527 beforeLineComment
: true,
528 allowBlockStart
: true
532 code
: "function foo(){ \nvar g = 1;\n/* block comment at block end */\n}",
534 beforeBlockComment
: false,
535 afterBlockComment
: true,
540 code
: "function foo(){\nvar g = 1;\n/* block comment at block end */}",
542 beforeBlockComment
: false,
543 afterBlockComment
: true,
548 code
: "var foo = function(){\nvar g = 1;\n/* block comment at block end */\n}",
550 beforeBlockComment
: false,
551 afterBlockComment
: true,
556 code
: "if(true){\nvar g = 1;\n/* block comment at block end */\n}",
558 beforeBlockComment
: false,
559 afterBlockComment
: true,
564 code
: "if(true){\nvar g = 1;\n\n/* block comment at block end */\n}",
566 afterBlockComment
: true,
571 code
: "while(true){\n\nvar g = 1;\n\n/* \nblock comment at block end\n */}",
573 afterBlockComment
: true,
578 code
: "class B {\nconstructor() {}\n\n/**\n* hi\n */\n}",
580 afterBlockComment
: true,
583 parserOptions
: { ecmaVersion
: 6 }
586 code
: "class B {\nconstructor() {}\n\n/**\n* hi\n */\n}",
588 afterBlockComment
: true,
591 parserOptions
: { ecmaVersion
: 6 }
594 code
: "class B {\nconstructor() {}\n\n/**\n* hi\n */\n}",
596 afterBlockComment
: true,
597 allowBlockEnd
: false,
600 parserOptions
: { ecmaVersion
: 6 }
603 code
: "switch ('foo'){\ncase 'foo':\nvar g = 1;\n\n/* block comment at switch case end */\n}",
605 afterBlockComment
: true,
610 code
: "switch ('foo'){\ncase 'foo':\nvar g = 1;\n\n/* block comment at switch case end */\n\n}",
612 afterBlockComment
: true,
617 code
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\nvar g = 1;\n\n/* block comment at switch case end */\n}",
619 afterBlockComment
: true,
624 code
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\nvar g = 1;\n\n/* block comment at switch case end */\n\n}",
626 afterBlockComment
: true,
643 afterLineComment
: true,
646 parserOptions
: { ecmaVersion
: 2022 }
672 beforeBlockComment
: false, // default is `true`
673 afterBlockComment
: true,
676 parserOptions
: { ecmaVersion
: 2022 }
679 // check for object start comments
686 beforeLineComment
: true,
687 allowObjectStart
: true
693 " // line at object start\n" +
697 beforeLineComment
: true,
698 allowObjectStart
: true
703 "function hi() {\n" +
706 " test: function() {\n" +
711 beforeLineComment
: true,
712 allowObjectStart
: true
718 " /* block comment at object start*/\n" +
722 beforeBlockComment
: true,
723 allowObjectStart
: true
728 "function hi() {\n" +
733 " test: function() {\n" +
738 beforeLineComment
: true,
739 allowObjectStart
: true
745 " // line at object start\n" +
749 beforeLineComment
: true,
750 allowObjectStart
: true
752 parserOptions
: { ecmaVersion
: 6 }
757 " // line at object start\n" +
761 beforeLineComment
: true,
762 allowObjectStart
: true
764 parserOptions
: { ecmaVersion
: 6 }
769 " /* block comment at object-like start*/\n" +
773 beforeBlockComment
: true,
774 allowObjectStart
: true
776 parserOptions
: { ecmaVersion
: 6 }
781 " /* block comment at object-like start*/\n" +
785 beforeBlockComment
: true,
786 allowObjectStart
: true
788 parserOptions
: { ecmaVersion
: 6 }
791 // check for object end comments
798 afterLineComment
: true,
806 " // line at object end\n" +
809 afterLineComment
: true,
815 "function hi() {\n" +
817 " test: function() {\n" +
823 afterLineComment
: true,
832 " /* block comment at object end*/\n" +
835 afterBlockComment
: true,
841 "function hi() {\n" +
843 " test: function() {\n" +
852 afterBlockComment
: true,
860 " // line at object end\n" +
863 afterLineComment
: true,
866 parserOptions
: { ecmaVersion
: 6 }
872 " // line at object end\n" +
875 afterLineComment
: true,
878 parserOptions
: { ecmaVersion
: 6 }
885 " /* block comment at object-like end*/\n" +
888 afterBlockComment
: true,
891 parserOptions
: { ecmaVersion
: 6 }
898 " /* block comment at object-like end*/\n" +
901 afterBlockComment
: true,
904 parserOptions
: { ecmaVersion
: 6 }
907 // check for array start comments
914 beforeLineComment
: true,
915 allowArrayStart
: true
921 " // line at array start\n" +
925 beforeLineComment
: true,
926 allowArrayStart
: true
932 " /* block comment at array start*/\n" +
936 beforeBlockComment
: true,
937 allowArrayStart
: true
943 " // line at array start\n" +
947 beforeLineComment
: true,
948 allowArrayStart
: true
950 parserOptions
: { ecmaVersion
: 6 }
955 " /* block comment at array start*/\n" +
959 beforeBlockComment
: true,
960 allowArrayStart
: true
962 parserOptions
: { ecmaVersion
: 6 }
965 // check for array end comments
972 afterLineComment
: true,
980 " // line at array end\n" +
983 afterLineComment
: true,
992 " /* block comment at array end*/\n" +
995 afterBlockComment
: true,
1003 " // line at array end\n" +
1006 afterLineComment
: true,
1009 parserOptions
: { ecmaVersion
: 6 }
1016 " /* block comment at array end*/\n" +
1019 afterBlockComment
: true,
1022 parserOptions
: { ecmaVersion
: 6 }
1029 "/* eslint-disable no-underscore-dangle */\n\n" +
1030 "this._values = values;\n" +
1031 "this._values2 = true;\n" +
1032 "/* eslint-enable no-underscore-dangle */\n" +
1035 beforeBlockComment
: true,
1036 afterBlockComment
: true
1039 "foo;\n/* eslint */",
1040 "foo;\n/* jshint */",
1041 "foo;\n/* jslint */",
1042 "foo;\n/* istanbul */",
1043 "foo;\n/* global */",
1044 "foo;\n/* globals */",
1045 "foo;\n/* exported */",
1048 code
: "foo\n/* this is pragmatic */",
1049 options
: [{ ignorePattern
: "pragma" }]
1052 code
: "foo\n/* this is pragmatic */",
1053 options
: [{ applyDefaultIgnorePatterns
: false, ignorePattern
: "pragma" }]
1058 code
: "#!comment\n\nvar a = 1;",
1059 options
: [{ afterHashbangComment
: true }]
1061 "#!comment\nvar a = 1;",
1063 code
: "#!comment\nvar a = 1;",
1067 code
: "#!comment\nvar a = 1;",
1068 options
: [{ afterHashbangComment
: false }]
1071 code
: "#!comment\nvar a = 1;",
1072 options
: [{ afterLineComment
: true, afterBlockComment
: true }]
1080 code
: "bar()\n/** block block block\n * block \n */\nvar a = 1;",
1081 output
: "bar()\n\n/** block block block\n * block \n */\nvar a = 1;",
1082 errors
: [{ messageId
: "before", type
: "Block" }]
1087 code
: "baz()\n// A line comment with no empty line after\nvar a = 1;",
1088 output
: "baz()\n// A line comment with no empty line after\n\nvar a = 1;",
1089 options
: [{ afterLineComment
: true }],
1090 errors
: [{ messageId
: "after", type
: "Line" }]
1093 code
: "baz()\n// A line comment with no empty line after\nvar a = 1;",
1094 output
: "baz()\n\n// A line comment with no empty line after\nvar a = 1;",
1095 options
: [{ beforeLineComment
: true, afterLineComment
: false }],
1096 errors
: [{ messageId
: "before", type
: "Line" }]
1099 code
: "// A line comment with no empty line after\nvar a = 1;",
1100 output
: "// A line comment with no empty line after\n\nvar a = 1;",
1101 options
: [{ beforeLineComment
: true, afterLineComment
: true }],
1102 errors
: [{ messageId
: "after", type
: "Line", line
: 1, column
: 1 }]
1105 code
: "baz()\n// A line comment with no empty line after\nvar a = 1;",
1106 output
: "baz()\n\n// A line comment with no empty line after\n\nvar a = 1;",
1107 options
: [{ beforeLineComment
: true, afterLineComment
: true }],
1108 errors
: [{ messageId
: "before", type
: "Line", line
: 2 }, { messageId
: "after", type
: "Line", line
: 2 }]
1113 code
: "bar()\n/**\n * block block block\n */\nvar a = 1;",
1114 output
: "bar()\n\n/**\n * block block block\n */\n\nvar a = 1;",
1115 options
: [{ afterBlockComment
: true, beforeBlockComment
: true }],
1116 errors
: [{ messageId
: "before", type
: "Block", line
: 2 }, { messageId
: "after", type
: "Block", line
: 2 }]
1119 code
: "bar()\n/* first block comment */ /* second block comment */\nvar a = 1;",
1120 output
: "bar()\n\n/* first block comment */ /* second block comment */\n\nvar a = 1;",
1121 options
: [{ afterBlockComment
: true, beforeBlockComment
: true }],
1123 { messageId
: "before", type
: "Block", line
: 2 },
1124 { messageId
: "after", type
: "Block", line
: 2 }
1128 code
: "bar()\n/* first block comment */ /* second block\n comment */\nvar a = 1;",
1129 output
: "bar()\n\n/* first block comment */ /* second block\n comment */\n\nvar a = 1;",
1130 options
: [{ afterBlockComment
: true, beforeBlockComment
: true }],
1132 { messageId
: "before", type
: "Block", line
: 2 },
1133 { messageId
: "after", type
: "Block", line
: 2 }
1137 code
: "bar()\n/**\n * block block block\n */\nvar a = 1;",
1138 output
: "bar()\n/**\n * block block block\n */\n\nvar a = 1;",
1139 options
: [{ afterBlockComment
: true, beforeBlockComment
: false }],
1140 errors
: [{ messageId
: "after", type
: "Block", line
: 2 }]
1143 code
: "bar()\n/**\n * block block block\n */\nvar a = 1;",
1144 output
: "bar()\n\n/**\n * block block block\n */\nvar a = 1;",
1145 options
: [{ afterBlockComment
: false, beforeBlockComment
: true }],
1146 errors
: [{ messageId
: "before", type
: "Block", line
: 2 }]
1149 code
: "var a,\n// line\nb;",
1150 output
: "var a,\n\n// line\nb;",
1152 beforeLineComment
: true,
1153 allowBlockStart
: true
1155 errors
: [{ messageId
: "before", type
: "Line", line
: 2 }]
1158 code
: "function foo(){\nvar a = 1;\n// line at block start\nvar g = 1;\n}",
1159 output
: "function foo(){\nvar a = 1;\n\n// line at block start\nvar g = 1;\n}",
1161 beforeLineComment
: true,
1162 allowBlockStart
: true
1164 errors
: [{ messageId
: "before", type
: "Line", line
: 3 }]
1167 code
: "var a,\n// line\nb;",
1168 output
: "var a,\n// line\n\nb;",
1170 afterLineComment
: true,
1173 errors
: [{ messageId
: "after", type
: "Line", line
: 2 }]
1176 code
: "function foo(){\nvar a = 1;\n\n// line at block start\nvar g = 1;\n}",
1177 output
: "function foo(){\nvar a = 1;\n\n// line at block start\n\nvar g = 1;\n}",
1179 afterLineComment
: true,
1182 errors
: [{ messageId
: "after", type
: "Line", line
: 4 }]
1185 code
: "switch ('foo'){\ncase 'foo':\n// line at switch case start\nbreak;\n}",
1186 output
: "switch ('foo'){\ncase 'foo':\n\n// line at switch case start\nbreak;\n}",
1188 beforeLineComment
: true
1190 errors
: [{ messageId
: "before", type
: "Line", line
: 3 }]
1193 code
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\n// line at switch case start\nbreak;\n}",
1194 output
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\n\n// line at switch case start\nbreak;\n}",
1196 beforeLineComment
: true
1198 errors
: [{ messageId
: "before", type
: "Line", line
: 6 }]
1201 code
: "while(true){\n// line at block start and end\n}",
1202 output
: "while(true){\n// line at block start and end\n\n}",
1204 afterLineComment
: true,
1205 allowBlockStart
: true
1207 errors
: [{ messageId
: "after", type
: "Line", line
: 2 }]
1210 code
: "while(true){\n// line at block start and end\n}",
1211 output
: "while(true){\n\n// line at block start and end\n}",
1213 beforeLineComment
: true,
1216 errors
: [{ messageId
: "before", type
: "Line", line
: 2 }]
1219 code
: "class A {\n// line at class start\nconstructor() {}\n}",
1220 output
: "class A {\n\n// line at class start\nconstructor() {}\n}",
1222 beforeLineComment
: true
1224 parserOptions
: { ecmaVersion
: 6 },
1225 errors
: [{ messageId
: "before", type
: "Line", line
: 2 }]
1228 code
: "class A {\n// line at class start\nconstructor() {}\n}",
1229 output
: "class A {\n\n// line at class start\nconstructor() {}\n}",
1231 allowBlockStart
: true,
1232 allowClassStart
: false,
1233 beforeLineComment
: true
1235 parserOptions
: { ecmaVersion
: 6 },
1236 errors
: [{ messageId
: "before", type
: "Line", line
: 2 }]
1239 code
: "class B {\nconstructor() {}\n\n// line at class end\n}",
1240 output
: "class B {\nconstructor() {}\n\n// line at class end\n\n}",
1242 afterLineComment
: true
1244 parserOptions
: { ecmaVersion
: 6 },
1245 errors
: [{ messageId
: "after", type
: "Line", line
: 4 }]
1248 code
: "class B {\nconstructor() {}\n\n// line at class end\n}",
1249 output
: "class B {\nconstructor() {}\n\n// line at class end\n\n}",
1251 afterLineComment
: true,
1252 allowBlockEnd
: true,
1253 allowClassEnd
: false
1255 parserOptions
: { ecmaVersion
: 6 },
1256 errors
: [{ messageId
: "after", type
: "Line", line
: 4 }]
1259 code
: "switch ('foo'){\ncase 'foo':\nvar g = 1;\n\n// line at switch case end\n}",
1260 output
: "switch ('foo'){\ncase 'foo':\nvar g = 1;\n\n// line at switch case end\n\n}",
1262 afterLineComment
: true
1264 errors
: [{ messageId
: "after", type
: "Line", line
: 5 }]
1267 code
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\nvar g = 1;\n\n// line at switch case end\n}",
1268 output
: "switch ('foo'){\ncase 'foo':\nbreak;\n\ndefault:\nvar g = 1;\n\n// line at switch case end\n\n}",
1270 afterLineComment
: true
1272 errors
: [{ messageId
: "after", type
: "Line", line
: 8 }]
1287 beforeLineComment
: true,
1288 afterLineComment
: true,
1289 allowBlockStart
: true,
1290 allowBlockEnd
: true,
1291 allowClassStart
: true,
1294 parserOptions
: { ecmaVersion
: 2022 },
1296 { messageId
: "after", type
: "Line", line
: 2 }
1314 beforeBlockComment
: true,
1315 afterBlockComment
: true,
1316 allowBlockStart
: true,
1317 allowBlockEnd
: true,
1318 allowClassStart
: true,
1321 parserOptions
: { ecmaVersion
: 2022 },
1323 { messageId
: "after", type
: "Block", line
: 2 }
1342 beforeLineComment
: true,
1343 afterLineComment
: true,
1344 allowBlockStart
: true,
1345 allowBlockEnd
: true,
1346 allowClassStart
: true,
1349 parserOptions
: { ecmaVersion
: 2022 },
1351 { messageId
: "before", type
: "Line", line
: 3 },
1352 { messageId
: "after", type
: "Line", line
: 3 }
1373 beforeBlockComment
: true,
1374 afterBlockComment
: true,
1375 allowBlockStart
: true,
1376 allowBlockEnd
: true,
1377 allowClassStart
: true,
1380 parserOptions
: { ecmaVersion
: 2022 },
1382 { messageId
: "before", type
: "Block", line
: 3 },
1383 { messageId
: "after", type
: "Block", line
: 3 }
1403 beforeLineComment
: true,
1404 afterLineComment
: true,
1405 allowBlockStart
: true,
1408 parserOptions
: { ecmaVersion
: 2022 },
1410 { messageId
: "after", type
: "Line", line
: 3 }
1432 beforeBlockComment
: true,
1433 afterBlockComment
: true,
1434 allowBlockStart
: true,
1437 parserOptions
: { ecmaVersion
: 2022 },
1439 { messageId
: "after", type
: "Block", line
: 3 }
1459 beforeLineComment
: true,
1460 afterLineComment
: true,
1461 allowBlockStart
: true,
1464 parserOptions
: { ecmaVersion
: 2022 },
1466 { messageId
: "before", type
: "Line", line
: 4 }
1488 beforeBlockComment
: true,
1489 afterBlockComment
: true,
1490 allowBlockStart
: true,
1493 parserOptions
: { ecmaVersion
: 2022 },
1495 { messageId
: "before", type
: "Block", line
: 4 }
1518 beforeLineComment
: true,
1519 afterLineComment
: true,
1520 allowBlockStart
: true,
1523 parserOptions
: { ecmaVersion
: 2022 },
1525 { messageId
: "before", type
: "Line", line
: 4 },
1526 { messageId
: "after", type
: "Line", line
: 4 }
1551 beforeBlockComment
: true,
1552 afterBlockComment
: true,
1553 allowBlockStart
: true,
1556 parserOptions
: { ecmaVersion
: 2022 },
1558 { messageId
: "before", type
: "Block", line
: 4 },
1559 { messageId
: "after", type
: "Block", line
: 4 }
1575 beforeLineComment
: true,
1576 afterLineComment
: true,
1577 allowBlockStart
: true,
1578 allowBlockEnd
: true,
1579 allowClassStart
: true,
1582 parserOptions
: { ecmaVersion
: 2022 },
1584 { messageId
: "before", type
: "Line", line
: 3 }
1602 beforeBlockComment
: true,
1603 afterBlockComment
: true,
1604 allowBlockStart
: true,
1605 allowBlockEnd
: true,
1606 allowClassStart
: true,
1609 parserOptions
: { ecmaVersion
: 2022 },
1611 { messageId
: "before", type
: "Block", line
: 3 }
1615 // object start comments
1619 " // line at object start\n" +
1625 " // line at object start\n" +
1629 beforeLineComment
: true
1631 errors
: [{ messageId
: "before", type
: "Line", line
: 2 }]
1635 "function hi() {\n" +
1638 " test: function() {\n" +
1643 "function hi() {\n" +
1647 " test: function() {\n" +
1652 beforeLineComment
: true
1654 errors
: [{ messageId
: "before", type
: "Line", line
: 3 }]
1659 " /* block comment at object start*/\n" +
1665 " /* block comment at object start*/\n" +
1669 beforeBlockComment
: true
1671 errors
: [{ messageId
: "before", type
: "Block", line
: 2 }]
1675 "function hi() {\n" +
1680 " test: function() {\n" +
1685 "function hi() {\n" +
1691 " test: function() {\n" +
1696 beforeLineComment
: true
1698 errors
: [{ messageId
: "before", type
: "Block", line
: 3 }]
1703 " // line at object start\n" +
1709 " // line at object start\n" +
1713 beforeLineComment
: true
1715 parserOptions
: { ecmaVersion
: 6 },
1716 errors
: [{ messageId
: "before", type
: "Line", line
: 2 }]
1721 " // line at object start\n" +
1727 " // line at object start\n" +
1731 beforeLineComment
: true
1733 parserOptions
: { ecmaVersion
: 6 },
1734 errors
: [{ messageId
: "before", type
: "Line", line
: 2 }]
1739 " /* block comment at object-like start*/\n" +
1745 " /* block comment at object-like start*/\n" +
1749 beforeBlockComment
: true
1751 parserOptions
: { ecmaVersion
: 6 },
1752 errors
: [{ messageId
: "before", type
: "Block", line
: 2 }]
1757 " /* block comment at object-like start*/\n" +
1763 " /* block comment at object-like start*/\n" +
1767 beforeBlockComment
: true
1769 parserOptions
: { ecmaVersion
: 6 },
1770 errors
: [{ messageId
: "before", type
: "Block", line
: 2 }]
1773 // object end comments
1778 " // line at object end\n" +
1783 " // line at object end\n" +
1787 afterLineComment
: true
1789 errors
: [{ messageId
: "after", type
: "Line", line
: 3 }]
1793 "function hi() {\n" +
1795 " test: function() {\n" +
1801 "function hi() {\n" +
1803 " test: function() {\n" +
1810 afterLineComment
: true
1812 errors
: [{ messageId
: "after", type
: "Line", line
: 5 }]
1819 " /* block comment at object end*/\n" +
1825 " /* block comment at object end*/\n" +
1829 afterBlockComment
: true
1831 errors
: [{ messageId
: "after", type
: "Block", line
: 4 }]
1835 "function hi() {\n" +
1837 " test: function() {\n" +
1846 "function hi() {\n" +
1848 " test: function() {\n" +
1858 afterBlockComment
: true
1860 errors
: [{ messageId
: "after", type
: "Block", line
: 6 }]
1866 " // line at object end\n" +
1871 " // line at object end\n" +
1875 afterLineComment
: true
1877 parserOptions
: { ecmaVersion
: 6 },
1878 errors
: [{ messageId
: "after", type
: "Line", line
: 3 }]
1884 " // line at object end\n" +
1889 " // line at object end\n" +
1893 afterLineComment
: true
1895 parserOptions
: { ecmaVersion
: 6 },
1896 errors
: [{ messageId
: "after", type
: "Line", line
: 3 }]
1903 " /* block comment at object-like end*/\n" +
1909 " /* block comment at object-like end*/\n" +
1913 afterBlockComment
: true
1915 parserOptions
: { ecmaVersion
: 6 },
1916 errors
: [{ messageId
: "after", type
: "Block", line
: 4 }]
1923 " /* block comment at object-like end*/\n" +
1929 " /* block comment at object-like end*/\n" +
1933 afterBlockComment
: true
1935 parserOptions
: { ecmaVersion
: 6 },
1936 errors
: [{ messageId
: "after", type
: "Block", line
: 4 }]
1939 // array start comments
1943 " // line at array start\n" +
1949 " // line at array start\n" +
1953 beforeLineComment
: true
1955 errors
: [{ messageId
: "before", type
: "Line", line
: 2 }]
1960 " /* block comment at array start*/\n" +
1966 " /* block comment at array start*/\n" +
1970 beforeBlockComment
: true
1972 errors
: [{ messageId
: "before", type
: "Block", line
: 2 }]
1977 " // line at array start\n" +
1983 " // line at array start\n" +
1987 beforeLineComment
: true
1989 parserOptions
: { ecmaVersion
: 6 },
1990 errors
: [{ messageId
: "before", type
: "Line", line
: 2 }]
1995 " /* block comment at array start*/\n" +
2001 " /* block comment at array start*/\n" +
2005 beforeBlockComment
: true
2007 parserOptions
: { ecmaVersion
: 6 },
2008 errors
: [{ messageId
: "before", type
: "Block", line
: 2 }]
2011 // array end comments
2016 " // line at array end\n" +
2021 " // line at array end\n" +
2025 afterLineComment
: true
2027 errors
: [{ messageId
: "after", type
: "Line", line
: 3 }]
2034 " /* block comment at array end*/\n" +
2040 " /* block comment at array end*/\n" +
2044 afterBlockComment
: true
2046 errors
: [{ messageId
: "after", type
: "Block", line
: 4 }]
2052 " // line at array end\n" +
2057 " // line at array end\n" +
2061 afterLineComment
: true
2063 parserOptions
: { ecmaVersion
: 6 },
2064 errors
: [{ messageId
: "after", type
: "Line", line
: 3 }]
2071 " /* block comment at array end*/\n" +
2077 " /* block comment at array end*/\n" +
2081 afterBlockComment
: true
2083 parserOptions
: { ecmaVersion
: 6 },
2084 errors
: [{ messageId
: "after", type
: "Block", line
: 4 }]
2091 "/* eslint-disable no-underscore-dangle */\n\n" +
2092 "this._values = values;\n" +
2093 "this._values2 = true;\n" +
2094 "/* eslint-enable no-underscore-dangle */\n" +
2098 "/* eslint-disable no-underscore-dangle */\n\n" +
2099 "this._values = values;\n" +
2100 "this._values2 = true;\n" +
2102 "/* eslint-enable no-underscore-dangle */\n" +
2106 beforeBlockComment
: true,
2107 afterBlockComment
: true,
2108 applyDefaultIgnorePatterns
: false
2111 { messageId
: "before", type
: "Block", line
: 7 },
2112 { messageId
: "after", type
: "Block", line
: 7 }
2116 code
: "foo;\n/* eslint */",
2117 output
: "foo;\n\n/* eslint */",
2118 options
: [{ applyDefaultIgnorePatterns
: false }],
2119 errors
: [{ messageId
: "before", type
: "Block" }]
2122 code
: "foo;\n/* jshint */",
2123 output
: "foo;\n\n/* jshint */",
2124 options
: [{ applyDefaultIgnorePatterns
: false }],
2125 errors
: [{ messageId
: "before", type
: "Block" }]
2128 code
: "foo;\n/* jslint */",
2129 output
: "foo;\n\n/* jslint */",
2130 options
: [{ applyDefaultIgnorePatterns
: false }],
2131 errors
: [{ messageId
: "before", type
: "Block" }]
2134 code
: "foo;\n/* istanbul */",
2135 output
: "foo;\n\n/* istanbul */",
2136 options
: [{ applyDefaultIgnorePatterns
: false }],
2137 errors
: [{ messageId
: "before", type
: "Block" }]
2140 code
: "foo;\n/* global */",
2141 output
: "foo;\n\n/* global */",
2142 options
: [{ applyDefaultIgnorePatterns
: false }],
2143 errors
: [{ messageId
: "before", type
: "Block" }]
2146 code
: "foo;\n/* globals */",
2147 output
: "foo;\n\n/* globals */",
2148 options
: [{ applyDefaultIgnorePatterns
: false }],
2149 errors
: [{ messageId
: "before", type
: "Block" }]
2152 code
: "foo;\n/* exported */",
2153 output
: "foo;\n\n/* exported */",
2154 options
: [{ applyDefaultIgnorePatterns
: false }],
2155 errors
: [{ messageId
: "before", type
: "Block" }]
2158 code
: "foo;\n/* jscs */",
2159 output
: "foo;\n\n/* jscs */",
2160 options
: [{ applyDefaultIgnorePatterns
: false }],
2161 errors
: [{ messageId
: "before", type
: "Block" }]
2164 code
: "foo\n/* something else */",
2165 output
: "foo\n\n/* something else */",
2166 options
: [{ ignorePattern
: "pragma" }],
2167 errors
: [{ messageId
: "before", type
: "Block" }]
2170 code
: "foo\n/* eslint */",
2171 output
: "foo\n\n/* eslint */",
2172 options
: [{ applyDefaultIgnorePatterns
: false }],
2173 errors
: [{ messageId
: "before", type
: "Block" }]
2176 // "fallthrough" patterns are not ignored by default
2178 code
: "foo;\n/* fallthrough */",
2179 output
: "foo;\n\n/* fallthrough */",
2181 errors
: [{ messageId
: "before", type
: "Block" }]
2186 // this comment is not allowed by allowBlockStart: true
2199 // this comment is not allowed by allowBlockStart: true
2210 allowBlockStart
: true,
2211 beforeLineComment
: true,
2212 afterLineComment
: true
2214 errors
: [{ messageId
: "before", type
: "Line" }]
2219 code
: "#!foo\nvar a = 1;",
2220 output
: "#!foo\n\nvar a = 1;",
2221 options
: [{ afterHashbangComment
: true }],
2222 errors
: [{ messageId
: "after", type
: "Shebang" }]