@tony.ganchev/eslint-plugin-header 3.1.3 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +24 -0
- package/lib/comment-parser.js +34 -5
- package/lib/rules/header.js +167 -17
- package/package.json +14 -5
- package/.eslintrc.yml +0 -94
- package/.github/workflows/npm-publish.yml +0 -33
- package/.github/workflows/test.yml +0 -22
- package/CHANGELOG.md +0 -39
- package/tests/lib/comment-parser-test.js +0 -23
- package/tests/lib/rules/header.js +0 -285
- package/tests/support/block.js +0 -4
- package/tests/support/line.js +0 -2
package/index.js
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015-present Stuart Knightley and contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the “Software”), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
1
25
|
"use strict";
|
|
2
26
|
|
|
3
27
|
module.exports = {
|
package/lib/comment-parser.js
CHANGED
|
@@ -1,10 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015-present Stuart Knightley and contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the “Software”), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
2
24
|
|
|
3
|
-
|
|
4
|
-
// single kind of comment. It won't detect multiple block comments.
|
|
25
|
+
"use strict";
|
|
5
26
|
|
|
6
|
-
|
|
7
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Parses a line or block comment and returns the type of comment and an array of content lines.
|
|
29
|
+
*
|
|
30
|
+
* This is a really simple and dumb parser, that looks just for a
|
|
31
|
+
* single kind of comment. It won't detect multiple block comments.
|
|
32
|
+
* @param {string} commentText comment text.
|
|
33
|
+
* @returns {['block' | 'line', string[]]} comment type and comment content broken into lines.
|
|
34
|
+
*/
|
|
35
|
+
module.exports = function commentParser(commentText) {
|
|
36
|
+
const text = commentText.trim();
|
|
8
37
|
|
|
9
38
|
if (text.substr(0, 2) === "//") {
|
|
10
39
|
return [
|
package/lib/rules/header.js
CHANGED
|
@@ -1,13 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015-present Stuart Knightley and contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the “Software”), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
1
25
|
"use strict";
|
|
2
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Import type definitions.
|
|
29
|
+
* @typedef {import('estree').Comment} Comment
|
|
30
|
+
* @typedef {import('estree').Program} Program
|
|
31
|
+
* @typedef {import('eslint').Rule.Fix} Fix
|
|
32
|
+
* @typedef {import('eslint').Rule.NodeListener} NodeListener
|
|
33
|
+
* @typedef {import('eslint').Rule.ReportFixer} ReportFixer
|
|
34
|
+
* @typedef {import('eslint').Rule.RuleFixer} RuleFixer
|
|
35
|
+
* @typedef {import('eslint').Rule.RuleTextEdit} RuleTextEdit
|
|
36
|
+
* @typedef {import('eslint').Rule.RuleTextEditor} RuleTextEditor
|
|
37
|
+
* @typedef {import('eslint').Rule.RuleContext} RuleContext
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @enum {string}
|
|
42
|
+
*/
|
|
43
|
+
const lineEndingOptions = Object.freeze({
|
|
44
|
+
unix: "unix", // \n
|
|
45
|
+
windows: "windows", // \n
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @enum {string}
|
|
50
|
+
*/
|
|
51
|
+
const commentTypeOptions = Object.freeze({
|
|
52
|
+
block: "block",
|
|
53
|
+
line: "line"
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Local type defintions.
|
|
58
|
+
* @typedef {string | { pattern: string, template?: string }} HeaderLine
|
|
59
|
+
* @typedef {(HeaderLine | HeaderLine[])} HeaderLines
|
|
60
|
+
* @typedef {{ lineEndings: ('unix' | 'windows') }} HeaderSettings
|
|
61
|
+
* @typedef {([string] | [string, HeaderSettings] | [('block' | 'line') | HeaderLines ] | [('block' | 'line') | HeaderLines | HeaderSettings] | [('block' | 'line') | HeaderLines | number ] | [('block' | 'line') | HeaderLines | number | HeaderSettings])} HeaderOptions
|
|
62
|
+
*/
|
|
63
|
+
|
|
3
64
|
var fs = require("fs");
|
|
4
65
|
var commentParser = require("../comment-parser");
|
|
5
66
|
var os = require("os");
|
|
6
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Tests if the passed line configuration string or object is a pattern definition.
|
|
70
|
+
* @param {HeaderLine} object line configuration object or string
|
|
71
|
+
* @returns {boolean} `true` if the line configuration is a pattern-dfining object or `false` otherwise.
|
|
72
|
+
*/
|
|
7
73
|
function isPattern(object) {
|
|
8
74
|
return typeof object === "object" && Object.prototype.hasOwnProperty.call(object, "pattern");
|
|
9
75
|
}
|
|
10
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Utility over a line config argument to match an expected string either against a regex or for full match against a string.
|
|
79
|
+
* @param {HeaderLine} actual the string to test.
|
|
80
|
+
* @param {string} expected The string or regex to test again.
|
|
81
|
+
* @returns {boolean} `true` if the passed string matches the expected line config or `false` otherwise.
|
|
82
|
+
*/
|
|
11
83
|
function match(actual, expected) {
|
|
12
84
|
if (expected.test) {
|
|
13
85
|
return expected.test(actual);
|
|
@@ -16,19 +88,29 @@ function match(actual, expected) {
|
|
|
16
88
|
}
|
|
17
89
|
}
|
|
18
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Remove Unix she-bangs from the list of comments.
|
|
93
|
+
* @param {Comment[]} comments the list of comment lines.
|
|
94
|
+
* @returns {Comment[]} the list of comments with containing all incomming comments from `comments` with the shebang comments omitted.
|
|
95
|
+
*/
|
|
19
96
|
function excludeShebangs(comments) {
|
|
20
97
|
return comments.filter(function(comment) {
|
|
21
98
|
return comment.type !== "Shebang";
|
|
22
99
|
});
|
|
23
100
|
}
|
|
24
101
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Returns either the first block comment or the first set of line comments that
|
|
104
|
+
* are ONLY separated by a single newline. Note that this does not actually
|
|
105
|
+
* check if they are at the start of the file since that is already checked by
|
|
106
|
+
* `hasHeader()`.
|
|
107
|
+
* @param {RuleContext} context ESLint execution environment.
|
|
108
|
+
* @param {Program} node ESLint AST treee node being processed.
|
|
109
|
+
* @returns {Comment[]} lines that constitute the leading comment.
|
|
110
|
+
*/
|
|
29
111
|
function getLeadingComments(context, node) {
|
|
30
112
|
var all = excludeShebangs(context.getSourceCode().getAllComments(node.body.length ? node.body[0] : node));
|
|
31
|
-
if (all[0].type.toLowerCase() ===
|
|
113
|
+
if (all[0].type.toLowerCase() === commentTypeOptions.block) {
|
|
32
114
|
return [all[0]];
|
|
33
115
|
}
|
|
34
116
|
for (var i = 1; i < all.length; ++i) {
|
|
@@ -40,24 +122,50 @@ function getLeadingComments(context, node) {
|
|
|
40
122
|
return all.slice(0, i);
|
|
41
123
|
}
|
|
42
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Generate a comment including trailing spaces out of a number of comment body lines.
|
|
127
|
+
* @param {'block' | 'line'} commentType the type of comment to generate.
|
|
128
|
+
* @param {string[]} textArray list of lines of the comment content.
|
|
129
|
+
* @param {'\n' | '\r\n'} eol end-of-line characters.
|
|
130
|
+
* @param {number} numNewlines number of trailing lines after the comment.
|
|
131
|
+
* @returns {string} resulting comment.
|
|
132
|
+
*/
|
|
43
133
|
function genCommentBody(commentType, textArray, eol, numNewlines) {
|
|
44
134
|
var eols = eol.repeat(numNewlines);
|
|
45
|
-
if (commentType ===
|
|
135
|
+
if (commentType === commentTypeOptions.block) {
|
|
46
136
|
return "/*" + textArray.join(eol) + "*/" + eols;
|
|
47
137
|
} else {
|
|
48
138
|
return "//" + textArray.join(eol + "//") + eols;
|
|
49
139
|
}
|
|
50
140
|
}
|
|
51
141
|
|
|
142
|
+
/**
|
|
143
|
+
* ...
|
|
144
|
+
* @param {RuleContext} context ESLint rule execution context.
|
|
145
|
+
* @param {string[]} comments list of comments.
|
|
146
|
+
* @param {'\n' | '\r\n'} eol end-of-line characters
|
|
147
|
+
* @returns {[number, number]} resulting range.
|
|
148
|
+
*/
|
|
52
149
|
function genCommentsRange(context, comments, eol) {
|
|
53
150
|
var start = comments[0].range[0];
|
|
54
151
|
var end = comments.slice(-1)[0].range[1];
|
|
55
|
-
|
|
152
|
+
const sourceCode = context.getSourceCode().text;
|
|
153
|
+
const headerTrailingChars = sourceCode.substring(end, end + eol.length);
|
|
154
|
+
if (headerTrailingChars === eol) {
|
|
56
155
|
end += eol.length;
|
|
57
156
|
}
|
|
58
157
|
return [start, end];
|
|
59
158
|
}
|
|
60
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Factory for fixer that adds a missing header.
|
|
162
|
+
* @param {'block' | 'line'} commentType type of comment to use.
|
|
163
|
+
* @param {Program} node ESLint AST program node.
|
|
164
|
+
* @param {string[]} headerLines lines of the header comment.
|
|
165
|
+
* @param {'\n' | '\r\n'} eol end-of-line characters
|
|
166
|
+
* @param {number} numNewlines number of trailing lines after the comment.
|
|
167
|
+
* @returns {ReportFixer} the fixer.
|
|
168
|
+
*/
|
|
61
169
|
function genPrependFixer(commentType, node, headerLines, eol, numNewlines) {
|
|
62
170
|
return function(fixer) {
|
|
63
171
|
return fixer.insertTextBefore(
|
|
@@ -67,6 +175,16 @@ function genPrependFixer(commentType, node, headerLines, eol, numNewlines) {
|
|
|
67
175
|
};
|
|
68
176
|
}
|
|
69
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Factory for fixer that replaces an incorrect header.
|
|
180
|
+
* @param {'block' | 'line'} commentType type of comment to use.
|
|
181
|
+
* @param {RuleContext} context ESLint rule execution context.
|
|
182
|
+
* @param {Comment[]} leadingComments comment elements to replace.
|
|
183
|
+
* @param {string[]} headerLines lines of the header comment.
|
|
184
|
+
* @param {'\n' | '\r\n'} eol end-of-line characters
|
|
185
|
+
* @param {number} numNewlines number of trailing lines after the comment.
|
|
186
|
+
* @returns {(fixer: RuleTextEditor) => RuleTextEdit | RuleTextEdit[] | null} the fixer.
|
|
187
|
+
*/
|
|
70
188
|
function genReplaceFixer(commentType, context, leadingComments, headerLines, eol, numNewlines) {
|
|
71
189
|
return function(fixer) {
|
|
72
190
|
return fixer.replaceTextRange(
|
|
@@ -76,6 +194,11 @@ function genReplaceFixer(commentType, context, leadingComments, headerLines, eol
|
|
|
76
194
|
};
|
|
77
195
|
}
|
|
78
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Finds the option parameter within the list of rule config options.
|
|
199
|
+
* @param {HeaderOptions} options the config options passed to the rule.
|
|
200
|
+
* @returns {HeaderSettings | null} the settings parameter or `null` if no such is defined.
|
|
201
|
+
*/
|
|
79
202
|
function findSettings(options) {
|
|
80
203
|
var lastOption = options.length > 0 ? options[options.length - 1] : null;
|
|
81
204
|
if (typeof lastOption === "object" && !Array.isArray(lastOption) && lastOption !== null
|
|
@@ -85,17 +208,30 @@ function findSettings(options) {
|
|
|
85
208
|
return null;
|
|
86
209
|
}
|
|
87
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Returns the used line-termination characters per the rule's config if any or else based on the runtime environments.
|
|
213
|
+
* @param {HeaderOptions} options rule configuration.
|
|
214
|
+
* @returns {'\n' | '\r\n'} the correct line ending characters for the environment.
|
|
215
|
+
*/
|
|
88
216
|
function getEOL(options) {
|
|
89
217
|
var settings = findSettings(options);
|
|
90
|
-
if (settings
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
218
|
+
if (settings) {
|
|
219
|
+
if (settings.lineEndings === lineEndingOptions.unix) {
|
|
220
|
+
return "\n";
|
|
221
|
+
}
|
|
222
|
+
if (settings.lineEndings === lineEndingOptions.windows) {
|
|
223
|
+
return "\r\n";
|
|
224
|
+
}
|
|
95
225
|
}
|
|
96
226
|
return os.EOL;
|
|
97
227
|
}
|
|
98
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Tests if the first line in the source code (after a Unix she-bang) is a comment. Does not tolerate empty lines before the first match.
|
|
231
|
+
* @param {string} src source code to test.
|
|
232
|
+
* @returns {boolean} `true` if there is a comment or `false` otherwise.
|
|
233
|
+
*/
|
|
234
|
+
// TODO: check if it is valid to have the copyright notice separated by an empty line from the shebang.
|
|
99
235
|
function hasHeader(src) {
|
|
100
236
|
if (src.substr(0, 2) === "#!") {
|
|
101
237
|
var m = src.match(/(\r\n|\r|\n)/);
|
|
@@ -106,6 +242,12 @@ function hasHeader(src) {
|
|
|
106
242
|
return src.substr(0, 2) === "/*" || src.substr(0, 2) === "//";
|
|
107
243
|
}
|
|
108
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Ensures that the right amount of empty lines trail the header.
|
|
247
|
+
* @param {string} src source to validate.
|
|
248
|
+
* @param {number} num expected number of trailing empty lines.
|
|
249
|
+
* @returns {boolean} `true` if the `num` number of empty lines are appended at the end or `false` otherwise.
|
|
250
|
+
*/
|
|
109
251
|
function matchesLineEndings(src, num) {
|
|
110
252
|
for (var j = 0; j < num; ++j) {
|
|
111
253
|
var m = src.match(/^(\r\n|\r|\n)/);
|
|
@@ -127,7 +269,7 @@ module.exports = {
|
|
|
127
269
|
definitions: {
|
|
128
270
|
commentType: {
|
|
129
271
|
type: "string",
|
|
130
|
-
enum: [
|
|
272
|
+
enum: [commentTypeOptions.block, commentTypeOptions.line]
|
|
131
273
|
},
|
|
132
274
|
line: {
|
|
133
275
|
anyOf: [
|
|
@@ -171,7 +313,7 @@ module.exports = {
|
|
|
171
313
|
properties: {
|
|
172
314
|
lineEndings: {
|
|
173
315
|
type: "string",
|
|
174
|
-
enum: [
|
|
316
|
+
enum: [lineEndingOptions.unix, lineEndingOptions.windows]
|
|
175
317
|
}
|
|
176
318
|
},
|
|
177
319
|
additionalProperties: false
|
|
@@ -213,9 +355,14 @@ module.exports = {
|
|
|
213
355
|
}
|
|
214
356
|
}
|
|
215
357
|
},
|
|
358
|
+
/**
|
|
359
|
+
* Rule creation function.
|
|
360
|
+
* @param {RuleContext} context ESLint rule execution context.
|
|
361
|
+
* @returns {NodeListener} the rule definition.
|
|
362
|
+
*/
|
|
216
363
|
create: function(context) {
|
|
217
364
|
var options = context.options;
|
|
218
|
-
var numNewlines = options.length > 2 ? options[2] : 1;
|
|
365
|
+
var numNewlines = options.length > 2 && typeof options[2] === "number" ? options[2] : 1;
|
|
219
366
|
var eol = getEOL(options);
|
|
220
367
|
|
|
221
368
|
// If just one option then read comment from file
|
|
@@ -280,7 +427,7 @@ module.exports = {
|
|
|
280
427
|
fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
|
|
281
428
|
});
|
|
282
429
|
} else {
|
|
283
|
-
if (commentType ===
|
|
430
|
+
if (commentType === commentTypeOptions.line) {
|
|
284
431
|
if (leadingComments.length < headerLines.length) {
|
|
285
432
|
context.report({
|
|
286
433
|
loc: node.loc,
|
|
@@ -321,8 +468,11 @@ module.exports = {
|
|
|
321
468
|
hasError = true;
|
|
322
469
|
}
|
|
323
470
|
for (i = 0; !hasError && i < headerLines.length; i++) {
|
|
324
|
-
|
|
471
|
+
const leadingLine = leadingLines[i];
|
|
472
|
+
const headerLine = headerLines[i];
|
|
473
|
+
if (!match(leadingLine, headerLine)) {
|
|
325
474
|
hasError = true;
|
|
475
|
+
break;
|
|
326
476
|
}
|
|
327
477
|
}
|
|
328
478
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tony.ganchev/eslint-plugin-header",
|
|
3
|
-
"version": "3.1.
|
|
4
|
-
"description": "ESLint plugin to ensure
|
|
3
|
+
"version": "3.1.5",
|
|
4
|
+
"description": "ESLint plugin to ensure files begin with a given comment, usually a copyright or license notice.",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"/lib/**/*.js",
|
|
8
|
+
"!/lib/rules/test-utils.js"
|
|
9
|
+
],
|
|
6
10
|
"scripts": {
|
|
7
11
|
"test": "npm run lint && npm run unit",
|
|
8
|
-
"unit": "mocha tests/lib
|
|
12
|
+
"unit": "nyc --reporter=html --reporter=text --reporter=text-summary mocha tests/lib/**/*.js",
|
|
9
13
|
"lint": "eslint ."
|
|
10
14
|
},
|
|
11
15
|
"devDependencies": {
|
|
12
|
-
"eslint": "^
|
|
13
|
-
"
|
|
16
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
17
|
+
"@eslint/js": "^9.32.0",
|
|
18
|
+
"eslint": "^9.32.0",
|
|
19
|
+
"eslint-plugin-jsdoc": "^52.0.4",
|
|
20
|
+
"mocha": "^11.7.1",
|
|
21
|
+
"nyc": "^17.1.0",
|
|
22
|
+
"testdouble": "^3.20.2"
|
|
14
23
|
},
|
|
15
24
|
"peerDependencies": {
|
|
16
25
|
"eslint": ">=7.7.0"
|
package/.eslintrc.yml
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
root: true
|
|
2
|
-
|
|
3
|
-
env:
|
|
4
|
-
node: true
|
|
5
|
-
|
|
6
|
-
extends:
|
|
7
|
-
"eslint:recommended"
|
|
8
|
-
|
|
9
|
-
rules:
|
|
10
|
-
indent: [2, 4, {SwitchCase: 1}]
|
|
11
|
-
brace-style: [2, "1tbs"]
|
|
12
|
-
camelcase: [2, { properties: "never" }]
|
|
13
|
-
callback-return: [2, ["cb", "callback", "next"]]
|
|
14
|
-
comma-spacing: 2
|
|
15
|
-
comma-style: [2, "last"]
|
|
16
|
-
consistent-return: 2
|
|
17
|
-
curly: [2, "all"]
|
|
18
|
-
default-case: 2
|
|
19
|
-
dot-notation: [2, { allowKeywords: true }]
|
|
20
|
-
eol-last: 2
|
|
21
|
-
eqeqeq: 2
|
|
22
|
-
func-style: [2, "declaration"]
|
|
23
|
-
guard-for-in: 2
|
|
24
|
-
key-spacing: [2, { beforeColon: false, afterColon: true }]
|
|
25
|
-
new-cap: 2
|
|
26
|
-
new-parens: 2
|
|
27
|
-
no-alert: 2
|
|
28
|
-
no-array-constructor: 2
|
|
29
|
-
no-caller: 2
|
|
30
|
-
no-console: 0
|
|
31
|
-
no-delete-var: 2
|
|
32
|
-
no-eval: 2
|
|
33
|
-
no-extend-native: 2
|
|
34
|
-
no-extra-bind: 2
|
|
35
|
-
no-fallthrough: 2
|
|
36
|
-
no-floating-decimal: 2
|
|
37
|
-
no-implied-eval: 2
|
|
38
|
-
no-invalid-this: 2
|
|
39
|
-
no-iterator: 2
|
|
40
|
-
no-label-var: 2
|
|
41
|
-
no-labels: 2
|
|
42
|
-
no-lone-blocks: 2
|
|
43
|
-
no-loop-func: 2
|
|
44
|
-
no-mixed-spaces-and-tabs: [2, false]
|
|
45
|
-
no-multi-spaces: 2
|
|
46
|
-
no-multi-str: 2
|
|
47
|
-
no-native-reassign: 2
|
|
48
|
-
no-nested-ternary: 2
|
|
49
|
-
no-new: 2
|
|
50
|
-
no-new-func: 2
|
|
51
|
-
no-new-object: 2
|
|
52
|
-
no-new-wrappers: 2
|
|
53
|
-
no-octal: 2
|
|
54
|
-
no-octal-escape: 2
|
|
55
|
-
no-process-exit: 2
|
|
56
|
-
no-proto: 2
|
|
57
|
-
no-redeclare: 2
|
|
58
|
-
no-return-assign: 2
|
|
59
|
-
no-script-url: 2
|
|
60
|
-
no-sequences: 2
|
|
61
|
-
no-shadow: 2
|
|
62
|
-
no-shadow-restricted-names: 2
|
|
63
|
-
no-spaced-func: 2
|
|
64
|
-
no-trailing-spaces: 2
|
|
65
|
-
no-undef: 2
|
|
66
|
-
no-undef-init: 2
|
|
67
|
-
no-undefined: 2
|
|
68
|
-
no-underscore-dangle: 2
|
|
69
|
-
no-unused-expressions: 2
|
|
70
|
-
no-unused-vars: [2, {vars: "all", args: "after-used"}]
|
|
71
|
-
no-use-before-define: 2
|
|
72
|
-
no-with: 2
|
|
73
|
-
quotes: [2, "double"]
|
|
74
|
-
radix: 2
|
|
75
|
-
semi: 2
|
|
76
|
-
semi-spacing: [2, {before: false, after: true}]
|
|
77
|
-
keyword-spacing: [2, {"after": true }]
|
|
78
|
-
space-before-blocks: 2
|
|
79
|
-
space-before-function-paren: [2, "never"]
|
|
80
|
-
space-infix-ops: 2
|
|
81
|
-
space-unary-ops: [2, {words: true, nonwords: false}]
|
|
82
|
-
spaced-comment: [2, "always", { exceptions: ["-"]}]
|
|
83
|
-
strict: [2, "global"]
|
|
84
|
-
valid-jsdoc: [2, { prefer: { "return": "returns"}}]
|
|
85
|
-
wrap-iife: 2
|
|
86
|
-
yoda: [2, "never"]
|
|
87
|
-
|
|
88
|
-
# Previously on by default in node environment
|
|
89
|
-
no-catch-shadow: 0
|
|
90
|
-
no-mixed-requires: 2
|
|
91
|
-
no-new-require: 2
|
|
92
|
-
no-path-concat: 2
|
|
93
|
-
global-strict: [0, "always"]
|
|
94
|
-
handle-callback-err: [2, "err"]
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: Node.js Package
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
release:
|
|
8
|
-
types: [created]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
build:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v4
|
|
15
|
-
- uses: actions/setup-node@v4
|
|
16
|
-
with:
|
|
17
|
-
node-version: 10
|
|
18
|
-
- run: npm ci
|
|
19
|
-
- run: npm test
|
|
20
|
-
|
|
21
|
-
publish-npm:
|
|
22
|
-
needs: build
|
|
23
|
-
runs-on: ubuntu-latest
|
|
24
|
-
steps:
|
|
25
|
-
- uses: actions/checkout@v4
|
|
26
|
-
- uses: actions/setup-node@v4
|
|
27
|
-
with:
|
|
28
|
-
node-version: 20
|
|
29
|
-
registry-url: https://registry.npmjs.org/
|
|
30
|
-
- run: npm ci
|
|
31
|
-
- run: npm publish
|
|
32
|
-
env:
|
|
33
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
name: Test
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ main ]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [ main ]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v2
|
|
16
|
-
- name: Use Node.js
|
|
17
|
-
uses: actions/setup-node@v1
|
|
18
|
-
with:
|
|
19
|
-
node-version: '14.x'
|
|
20
|
-
- name: Install dependencies
|
|
21
|
-
run: npm ci
|
|
22
|
-
- run: npm test
|
package/CHANGELOG.md
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# 3.1.1
|
|
2
|
-
|
|
3
|
-
* Fix detecting header below shebang comment with Windows EOL (#30)
|
|
4
|
-
|
|
5
|
-
# 3.1.0
|
|
6
|
-
|
|
7
|
-
* Update to eslint 7.7.0
|
|
8
|
-
* Add a third option to specify number of linebreaks after the header. (#29)
|
|
9
|
-
|
|
10
|
-
# 3.0.0
|
|
11
|
-
|
|
12
|
-
* Allow regexp in multiline arrays (#23)
|
|
13
|
-
* Add `template` option for regexps, for `eslint --fix` (#23)
|
|
14
|
-
* Update eslint to v5.12.0 (#19)
|
|
15
|
-
|
|
16
|
-
# 2.0.0
|
|
17
|
-
|
|
18
|
-
* Use the OS's line endings (`\n` on *nix, `\r\n` on Windows) when parsing and fixing comments. This can be configured with the `lineEndings` option. Major version bump as this could be a breaking change for projects.
|
|
19
|
-
|
|
20
|
-
# 1.2.0
|
|
21
|
-
|
|
22
|
-
* Add auto fix functionality (eslint `--fix` option) (#12)
|
|
23
|
-
|
|
24
|
-
# 1.1.0
|
|
25
|
-
|
|
26
|
-
* Ignore shebangs above header comments to support ESLint 4+ (#11)
|
|
27
|
-
|
|
28
|
-
# 1.0.0
|
|
29
|
-
|
|
30
|
-
* Allow RegExp patterns in addition to strings (#2, #4)
|
|
31
|
-
* Fix line comment length mismatch issue (#3)
|
|
32
|
-
|
|
33
|
-
# 0.1.0
|
|
34
|
-
|
|
35
|
-
* Add config option to read header from file
|
|
36
|
-
|
|
37
|
-
# 0.0.2
|
|
38
|
-
|
|
39
|
-
* Initial release
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var assert = require("assert");
|
|
5
|
-
var commentParser = require("../../lib/comment-parser");
|
|
6
|
-
|
|
7
|
-
describe("comment parser", function() {
|
|
8
|
-
it("parses block comments", function() {
|
|
9
|
-
var result = commentParser("/* pass1\n pass2 */ ");
|
|
10
|
-
assert.deepEqual(result, ["block", " pass1\n pass2 "]);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("throws an error when a block comment isn't ended", function() {
|
|
14
|
-
assert.throws(function() {
|
|
15
|
-
commentParser("/* fail");
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("parses line comments", function() {
|
|
20
|
-
var result = commentParser("// pass1\n// pass2\n ");
|
|
21
|
-
assert.deepEqual(result, ["line", [" pass1", " pass2"]]);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var rule = require("../../../lib/rules/header");
|
|
4
|
-
var RuleTester = require("eslint").RuleTester;
|
|
5
|
-
|
|
6
|
-
var ruleTester = new RuleTester();
|
|
7
|
-
ruleTester.run("header", rule, {
|
|
8
|
-
valid: [
|
|
9
|
-
{
|
|
10
|
-
code: "/*Copyright 2015, My Company*/\nconsole.log(1);",
|
|
11
|
-
options: ["block", "Copyright 2015, My Company"]
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
code: "//Copyright 2015, My Company\nconsole.log(1);",
|
|
15
|
-
options: ["line", "Copyright 2015, My Company"]
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
code: "/*Copyright 2015, My Company*/",
|
|
19
|
-
options: ["block", "Copyright 2015, My Company", 0]
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
code: "//Copyright 2015\n//My Company\nconsole.log(1)",
|
|
23
|
-
options: ["line", "Copyright 2015\nMy Company"]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
code: "//Copyright 2015\n//My Company\nconsole.log(1)",
|
|
27
|
-
options: ["line", ["Copyright 2015", "My Company"]]
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
code: "/*Copyright 2015\nMy Company*/\nconsole.log(1)",
|
|
31
|
-
options: ["block", ["Copyright 2015", "My Company"]]
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
code: "/*************************\n * Copyright 2015\n * My Company\n *************************/\nconsole.log(1)",
|
|
35
|
-
options: ["block", [
|
|
36
|
-
"************************",
|
|
37
|
-
" * Copyright 2015",
|
|
38
|
-
" * My Company",
|
|
39
|
-
" ************************"
|
|
40
|
-
]]
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
code: "/*\nCopyright 2015\nMy Company\n*/\nconsole.log(1)",
|
|
44
|
-
options: ["tests/support/block.js"]
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
code: "// Copyright 2015\n// My Company\nconsole.log(1)",
|
|
48
|
-
options: ["tests/support/line.js"]
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
code: "//Copyright 2015\n//My Company\n/* DOCS */",
|
|
52
|
-
options: ["line", "Copyright 2015\nMy Company"]
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
code: "// Copyright 2017",
|
|
56
|
-
options: ["line", {pattern: "^ Copyright \\d+$"}, 0]
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
code: "// Copyright 2017\n// Author: abc@example.com",
|
|
60
|
-
options: ["line", [{pattern: "^ Copyright \\d+$"}, {pattern: "^ Author: \\w+@\\w+\\.\\w+$"}], 0]
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
code: "/* Copyright 2017\n Author: abc@example.com */",
|
|
64
|
-
options: ["block", {pattern: "^ Copyright \\d{4}\\n Author: \\w+@\\w+\\.\\w+ $"}, 0]
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
code: "#!/usr/bin/env node\n/**\n * Copyright\n */",
|
|
68
|
-
options: ["block", [
|
|
69
|
-
"*",
|
|
70
|
-
" * Copyright",
|
|
71
|
-
" "
|
|
72
|
-
], 0]
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
code: "// Copyright 2015\r\n// My Company\r\nconsole.log(1)",
|
|
76
|
-
options: ["tests/support/line.js"]
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
code: "//Copyright 2018\r\n//My Company\r\n/* DOCS */",
|
|
80
|
-
options: ["line", ["Copyright 2018", "My Company"]]
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
code: "/*Copyright 2018\r\nMy Company*/\r\nconsole.log(1)",
|
|
84
|
-
options: ["block", ["Copyright 2018", "My Company"], {"lineEndings": "windows"}]
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
code: "/*Copyright 2018\nMy Company*/\nconsole.log(1)",
|
|
88
|
-
options: ["block", ["Copyright 2018", "My Company"], {"lineEndings": "unix"}]
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
code: "/*************************\n * Copyright 2015\n * My Company\n *************************/\nconsole.log(1)",
|
|
92
|
-
options: ["block", [
|
|
93
|
-
"************************",
|
|
94
|
-
{ pattern: " \\* Copyright \\d{4}" },
|
|
95
|
-
" * My Company",
|
|
96
|
-
" ************************"
|
|
97
|
-
]]
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
code: "/*Copyright 2020, My Company*/\nconsole.log(1);",
|
|
101
|
-
options: ["block", "Copyright 2020, My Company", 1],
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
code: "/*Copyright 2020, My Company*/\n\nconsole.log(1);",
|
|
105
|
-
options: ["block", "Copyright 2020, My Company", 2],
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
code: "/*Copyright 2020, My Company*/\n\n// Log number one\nconsole.log(1);",
|
|
109
|
-
options: ["block", "Copyright 2020, My Company", 2],
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
code: "/*Copyright 2020, My Company*/\n\n/*Log number one*/\nconsole.log(1);",
|
|
113
|
-
options: ["block", "Copyright 2020, My Company", 2],
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
code: "/**\n * Copyright 2020\n * My Company\n **/\n\n/*Log number one*/\nconsole.log(1);",
|
|
117
|
-
options: ["block", "*\n * Copyright 2020\n * My Company\n *", 2],
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
code: "#!/usr/bin/env node\r\n/**\r\n * Copyright\r\n */",
|
|
121
|
-
options: ["block", [
|
|
122
|
-
"*",
|
|
123
|
-
" * Copyright",
|
|
124
|
-
" "
|
|
125
|
-
], 0]
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
invalid: [
|
|
129
|
-
{
|
|
130
|
-
code: "console.log(1);",
|
|
131
|
-
options: ["block", "Copyright 2015, My Company"],
|
|
132
|
-
errors: [
|
|
133
|
-
{message: "missing header"}
|
|
134
|
-
],
|
|
135
|
-
output: "/*Copyright 2015, My Company*/\nconsole.log(1);"
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
code: "//Copyright 2014, My Company\nconsole.log(1);",
|
|
139
|
-
options: ["block", "Copyright 2015, My Company"],
|
|
140
|
-
errors: [
|
|
141
|
-
{message: "header should be a block comment"}
|
|
142
|
-
],
|
|
143
|
-
output: "/*Copyright 2015, My Company*/\nconsole.log(1);"
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
code: "/*Copyright 2014, My Company*/\nconsole.log(1);",
|
|
147
|
-
options: ["line", "Copyright 2015, My Company"],
|
|
148
|
-
errors: [
|
|
149
|
-
{message: "header should be a line comment"}
|
|
150
|
-
],
|
|
151
|
-
output: "//Copyright 2015, My Company\nconsole.log(1);"
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
code: "/*Copyright 2014, My Company*/\nconsole.log(1);",
|
|
155
|
-
options: ["block", "Copyright 2015, My Company"],
|
|
156
|
-
errors: [
|
|
157
|
-
{message: "incorrect header"}
|
|
158
|
-
],
|
|
159
|
-
output: "/*Copyright 2015, My Company*/\nconsole.log(1);"
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
// Test extra line in comment
|
|
163
|
-
code: "/*Copyright 2015\nMy Company\nExtra*/\nconsole.log(1);",
|
|
164
|
-
options: ["block", ["Copyright 2015", "My Company"]],
|
|
165
|
-
errors: [
|
|
166
|
-
{message: "incorrect header"}
|
|
167
|
-
],
|
|
168
|
-
output: "/*Copyright 2015\nMy Company*/\nconsole.log(1);"
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
code: "/*Copyright 2015\n*/\nconsole.log(1);",
|
|
172
|
-
options: ["block", ["Copyright 2015", "My Company"]],
|
|
173
|
-
errors: [
|
|
174
|
-
{message: "incorrect header"}
|
|
175
|
-
],
|
|
176
|
-
output: "/*Copyright 2015\nMy Company*/\nconsole.log(1);"
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
code: "//Copyright 2014\n//My Company\nconsole.log(1)",
|
|
180
|
-
options: ["line", "Copyright 2015\nMy Company"],
|
|
181
|
-
errors: [
|
|
182
|
-
{message: "incorrect header"}
|
|
183
|
-
],
|
|
184
|
-
output: "//Copyright 2015\n//My Company\nconsole.log(1)"
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
code: "//Copyright 2015",
|
|
188
|
-
options: ["line", "Copyright 2015\nMy Company"],
|
|
189
|
-
errors: [
|
|
190
|
-
{message: "incorrect header"}
|
|
191
|
-
],
|
|
192
|
-
output: "//Copyright 2015\n//My Company\n"
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
code: "// Copyright 2017 trailing",
|
|
196
|
-
options: ["line", {pattern: "^ Copyright \\d+$"}],
|
|
197
|
-
errors: [
|
|
198
|
-
{message: "incorrect header"}
|
|
199
|
-
]
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
code: "// Copyright 2017 trailing",
|
|
203
|
-
options: ["line", {pattern: "^ Copyright \\d+$", template: " Copyright 2018"}],
|
|
204
|
-
errors: [
|
|
205
|
-
{message: "incorrect header"}
|
|
206
|
-
],
|
|
207
|
-
output: "// Copyright 2018\n"
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
code: "// Copyright 2017 trailing\n// Someone",
|
|
211
|
-
options: ["line", [{pattern: "^ Copyright \\d+$", template: " Copyright 2018"}, " My Company"]],
|
|
212
|
-
errors: [
|
|
213
|
-
{message: "incorrect header"}
|
|
214
|
-
],
|
|
215
|
-
output: "// Copyright 2018\n// My Company\n"
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
code: "// Copyright 2017\n// Author: ab-c@example.com",
|
|
219
|
-
options: ["line", [{pattern: "Copyright \\d+"}, {pattern: "^ Author: \\w+@\\w+\\.\\w+$"}]],
|
|
220
|
-
errors: [
|
|
221
|
-
{message: "incorrect header"}
|
|
222
|
-
]
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
code: "/* Copyright 2017-01-02\n Author: abc@example.com */",
|
|
226
|
-
options: ["block", {pattern: "^ Copyright \\d+\\n Author: \\w+@\\w+\\.\\w+ $"}],
|
|
227
|
-
errors: [
|
|
228
|
-
{message: "incorrect header"}
|
|
229
|
-
]
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
code: "/*************************\n * Copyright 2015\n * All your base are belong to us!\n *************************/\nconsole.log(1)",
|
|
233
|
-
options: ["block", [
|
|
234
|
-
"************************",
|
|
235
|
-
{ pattern: " \\* Copyright \\d{4}", template: " * Copyright 2019" },
|
|
236
|
-
" * My Company",
|
|
237
|
-
" ************************"
|
|
238
|
-
]],
|
|
239
|
-
errors: [
|
|
240
|
-
{message: "incorrect header"}
|
|
241
|
-
],
|
|
242
|
-
output: "/*************************\n * Copyright 2019\n * My Company\n *************************/\nconsole.log(1)"
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
code: "/*Copyright 2020, My Company*/console.log(1);",
|
|
246
|
-
options: ["block", "Copyright 2020, My Company", 2],
|
|
247
|
-
errors: [
|
|
248
|
-
{message: "no newline after header"}
|
|
249
|
-
],
|
|
250
|
-
output: "/*Copyright 2020, My Company*/\n\nconsole.log(1);"
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
code: "/*Copyright 2020, My Company*/console.log(1);",
|
|
254
|
-
options: ["block", "Copyright 2020, My Company", 1],
|
|
255
|
-
errors: [
|
|
256
|
-
{message: "no newline after header"}
|
|
257
|
-
],
|
|
258
|
-
output: "/*Copyright 2020, My Company*/\nconsole.log(1);"
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
code: "//Copyright 2020\n//My Company\nconsole.log(1);",
|
|
262
|
-
options: ["line", ["Copyright 2020", "My Company"], 2],
|
|
263
|
-
errors: [
|
|
264
|
-
{message: "no newline after header"}
|
|
265
|
-
],
|
|
266
|
-
output: "//Copyright 2020\n//My Company\n\nconsole.log(1);"
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
code: "/*Copyright 2020, My Company*/\nconsole.log(1);\n//Comment\nconsole.log(2);\n//Comment",
|
|
270
|
-
options: ["block", "Copyright 2020, My Company", 2],
|
|
271
|
-
errors: [
|
|
272
|
-
{message: "no newline after header"}
|
|
273
|
-
],
|
|
274
|
-
output: "/*Copyright 2020, My Company*/\n\nconsole.log(1);\n//Comment\nconsole.log(2);\n//Comment"
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
code: "//Copyright 2020\n//My Company\nconsole.log(1);\n//Comment\nconsole.log(2);\n//Comment",
|
|
278
|
-
options: ["line", ["Copyright 2020", "My Company"], 2],
|
|
279
|
-
errors: [
|
|
280
|
-
{message: "no newline after header"}
|
|
281
|
-
],
|
|
282
|
-
output: "//Copyright 2020\n//My Company\n\nconsole.log(1);\n//Comment\nconsole.log(2);\n//Comment"
|
|
283
|
-
}
|
|
284
|
-
]
|
|
285
|
-
});
|
package/tests/support/block.js
DELETED
package/tests/support/line.js
DELETED