@tony.ganchev/eslint-plugin-header 3.1.8 → 3.1.10
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/LICENSE.md +3 -1
- package/README.md +154 -78
- package/index.js +3 -3
- package/lib/comment-parser.js +16 -14
- package/lib/rules/header.docs.js +40 -0
- package/lib/rules/header.js +256 -277
- package/lib/rules/header.schema.js +135 -0
- package/package.json +9 -3
package/LICENSE.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
1
3
|
Copyright (c) 2015-present Stuart Knightley, Tony Ganchev and contributors
|
|
2
4
|
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
@@ -15,4 +17,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
15
17
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
16
18
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
19
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
# eslint-plugin-header
|
|
2
|
+
|
|
3
|
+
ESLint plugin / rule to ensure that files begin with a given comment - usually a
|
|
4
|
+
copyright notice.
|
|
5
|
+
|
|
6
|
+
Often you will want to have a copyright notice at the top of every file. This
|
|
7
|
+
ESLint plugin checks that the first comment in every file has the contents
|
|
8
|
+
defined in the rule settings.
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
1. [Scope and Acknowledgements](#scope-and-acknowledgements)
|
|
13
|
+
2. [Usage](#usage)
|
|
14
|
+
1. [File-based Configuration](#file-based-configuration)
|
|
15
|
+
2. [Inline Configuration](#inline-configuration)
|
|
16
|
+
1. [Header Contents Configuration](#header-contents-configuration)
|
|
17
|
+
2. [Trailing Empty Lines Configuration](#trailing-empty-lines-configuration)
|
|
18
|
+
3. [Line Endings](#line-endings)
|
|
19
|
+
3. [Examples](#examples)
|
|
20
|
+
4. [Versioning](#versioning)
|
|
21
|
+
1. [What is a Feature?](#what-is-a-feature)
|
|
22
|
+
2. [What is Backward-compatibility?](#what-is-backward-compatibility)
|
|
23
|
+
5. [License](#license)
|
|
24
|
+
|
|
25
|
+
## Scope and Acknowledgements
|
|
26
|
+
|
|
27
|
+
This is a fork of <https://github.com/Stuk/eslint-plugin-header>.
|
|
2
28
|
|
|
3
29
|
It addresses the following issus:
|
|
4
30
|
|
|
@@ -13,36 +39,27 @@ It addresses the following issus:
|
|
|
13
39
|
forward. This would come at the expense of plugin compatibility and the
|
|
14
40
|
portability of fixes to the upstream repository.
|
|
15
41
|
|
|
16
|
-
eslint-plugin-header
|
|
17
|
-
====================
|
|
18
|
-
|
|
19
|
-
ESLint plugin to ensure that files begin with given comment.
|
|
20
|
-
|
|
21
|
-
Often you will want to have a copyright notice at the top of every file. This
|
|
22
|
-
ESLint plugin checks that the first comment in every file has the contents
|
|
23
|
-
defined in the rule settings.
|
|
24
|
-
|
|
25
42
|
## Usage
|
|
26
43
|
|
|
27
44
|
This rule takes between 1 and 4 arguments after the rule validation severity.
|
|
28
45
|
|
|
29
46
|
The configuration can take any of the following forms:
|
|
30
47
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
- File-based Configuration
|
|
49
|
+
- `[<severity>, "<file>"]` - read the header template from a file.
|
|
50
|
+
- `[<severity>, "<file>", {<settings>}]` - read the header template from a
|
|
34
51
|
file with additional settings.
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
- Inline Configuration
|
|
53
|
+
- `"<severity>", "<comment-type>", <header-contents>` - define the header
|
|
37
54
|
contents inline.
|
|
38
|
-
|
|
55
|
+
- `[<severity>, "<comment-type>", <header-contents>, {<settings>}]` - define
|
|
39
56
|
the header contents inline and pass additional settings.
|
|
40
|
-
|
|
57
|
+
- `[<severity>, "<comment-type>", <header-contents>, <n-empty-lines>]` -
|
|
41
58
|
define the header contents inline and an expected number of empty lines
|
|
42
59
|
after the header.
|
|
43
|
-
|
|
44
|
-
define the header contents inline and an expected number of
|
|
45
|
-
after the header and pass additional settings.
|
|
60
|
+
- `[<severity>, "<comment-type>", <header-contents>, <n-empty-lines>,
|
|
61
|
+
{<settings>}]` - define the header contents inline and an expected number of
|
|
62
|
+
empty lines after the header and pass additional settings.
|
|
46
63
|
|
|
47
64
|
### File-based Configuration
|
|
48
65
|
|
|
@@ -78,6 +95,7 @@ tree then the header file will not be found.
|
|
|
78
95
|
### Inline Configuration
|
|
79
96
|
|
|
80
97
|
The inline configuration expects at least two arguments to be given:
|
|
98
|
+
|
|
81
99
|
- _comment-type_ which is either `"block"` or `"line"` to indicate what style
|
|
82
100
|
of comment should be used.
|
|
83
101
|
- _header-contents_ which defines the lines of the header. It can be either a
|
|
@@ -88,19 +106,20 @@ The inline configuration expects at least two arguments to be given:
|
|
|
88
106
|
#### Header Contents Configuration
|
|
89
107
|
|
|
90
108
|
Suppose we want our header to look like this:
|
|
109
|
+
|
|
91
110
|
```js
|
|
92
111
|
/*
|
|
93
112
|
* Copyright (c) 2015
|
|
94
113
|
* My Company
|
|
95
114
|
*/
|
|
96
|
-
...
|
|
97
115
|
```
|
|
98
116
|
|
|
99
117
|
All of the following configurations will match the header:
|
|
100
|
-
|
|
118
|
+
|
|
119
|
+
- **Single string**:
|
|
120
|
+
|
|
101
121
|
```json
|
|
102
122
|
{
|
|
103
|
-
...
|
|
104
123
|
"rules": {
|
|
105
124
|
"header/header": [
|
|
106
125
|
2,
|
|
@@ -110,23 +129,30 @@ All of the following configurations will match the header:
|
|
|
110
129
|
}
|
|
111
130
|
}
|
|
112
131
|
```
|
|
132
|
+
|
|
113
133
|
Note that the above would work for both Windows and POSIX systems even
|
|
114
134
|
though the EOL in the header content was specified as `\n`.
|
|
115
135
|
|
|
116
136
|
Also, notice how we have an empty space before each line. This is because
|
|
117
|
-
the plugin only strips the leading `//` characters from a line comment
|
|
118
|
-
|
|
119
|
-
preserved.
|
|
137
|
+
the plugin only strips the leading `//` characters from a line comment.
|
|
138
|
+
Similarly, for a block comment, only the opening `/*` and closing `*/` will
|
|
139
|
+
be preserved with all new lines and whitespace preserved. Keep this in mind
|
|
140
|
+
as this can lead to poorly configured header matching rules that never
|
|
141
|
+
pass. In a future release error messages would be more detailed and show
|
|
142
|
+
exactly where header validation failed.
|
|
143
|
+
|
|
144
|
+
- **Single regular expression**:
|
|
120
145
|
|
|
121
|
-
* **Single regular expression**:
|
|
122
146
|
```json
|
|
123
147
|
{
|
|
124
|
-
...
|
|
125
148
|
"rules": {
|
|
126
149
|
"header/header": [
|
|
127
150
|
2,
|
|
128
151
|
"block",
|
|
129
|
-
{
|
|
152
|
+
{
|
|
153
|
+
"pattern":
|
|
154
|
+
"\\n \\* Copyright \\(c\\) 2015\\n \\* My Company\\n "
|
|
155
|
+
}
|
|
130
156
|
]
|
|
131
157
|
}
|
|
132
158
|
}
|
|
@@ -136,75 +162,71 @@ All of the following configurations will match the header:
|
|
|
136
162
|
`RegExp` objects, the backslashes need to be present in the string instead
|
|
137
163
|
of disappear as escape characters.
|
|
138
164
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
[
|
|
154
|
-
"",
|
|
155
|
-
" * Copyright (c) 2015",
|
|
156
|
-
" * My Company",
|
|
157
|
-
" "
|
|
165
|
+
- **Array of strings**:
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"rules": {
|
|
170
|
+
"header/header": [
|
|
171
|
+
2,
|
|
172
|
+
"block",
|
|
173
|
+
[
|
|
174
|
+
"",
|
|
175
|
+
" * Copyright (c) 2015",
|
|
176
|
+
" * My Company",
|
|
177
|
+
" "
|
|
178
|
+
]
|
|
158
179
|
]
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
- **Array of strings and/or patterns**:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"rules": {
|
|
189
|
+
"header/header": [
|
|
190
|
+
2,
|
|
191
|
+
"block",
|
|
192
|
+
[
|
|
193
|
+
"",
|
|
194
|
+
{ "pattern": " \\* Copyright \\(c\\) 2015" },
|
|
195
|
+
" * My Company",
|
|
196
|
+
" "
|
|
197
|
+
]
|
|
176
198
|
]
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
```
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
181
202
|
|
|
182
203
|
Regular expressions allow for a number of improvements in the maintainability
|
|
183
204
|
of the headers. Given the example above, what is clear is that new sources may
|
|
184
205
|
have been created later than 2015 and a comment with a different year should be
|
|
185
|
-
perfectly valid such as:
|
|
206
|
+
perfectly valid, such as:
|
|
186
207
|
|
|
187
208
|
```js
|
|
188
209
|
/*
|
|
189
210
|
* Copyright 2020
|
|
190
211
|
* My company
|
|
191
212
|
*/
|
|
192
|
-
...
|
|
193
213
|
```
|
|
194
|
-
|
|
195
|
-
|
|
214
|
+
|
|
215
|
+
Moreover, suppose your legal department expects that the year of first and last
|
|
216
|
+
change be added except if all changes happen in the same year, we also need to
|
|
217
|
+
support:
|
|
218
|
+
|
|
196
219
|
```js
|
|
197
220
|
/*
|
|
198
221
|
* Copyright 2017-2022
|
|
199
222
|
* My company
|
|
200
223
|
*/
|
|
201
|
-
...
|
|
202
224
|
```
|
|
225
|
+
|
|
203
226
|
We can use a regular expression to support all of these cases for your header:
|
|
204
227
|
|
|
205
228
|
```json
|
|
206
229
|
{
|
|
207
|
-
...
|
|
208
230
|
"rules": {
|
|
209
231
|
"header/header": [
|
|
210
232
|
2,
|
|
@@ -224,11 +246,10 @@ Note on auto-fixes i.e. `eslint --fix`: whenever strings are used to define the
|
|
|
224
246
|
header - counting in file-based configuration - the same strings would be used
|
|
225
247
|
to replace a header comment that did not pass validation. This is not possible
|
|
226
248
|
with regular expressions. For regular expression pattern-objects, a second
|
|
227
|
-
property `template` adds a replacement string.
|
|
249
|
+
property `template` adds a replacement string.
|
|
228
250
|
|
|
229
251
|
```json
|
|
230
252
|
{
|
|
231
|
-
...
|
|
232
253
|
"rules": {
|
|
233
254
|
"header/header": [
|
|
234
255
|
2,
|
|
@@ -244,7 +265,9 @@ property `template` adds a replacement string.
|
|
|
244
265
|
}
|
|
245
266
|
}
|
|
246
267
|
```
|
|
268
|
+
|
|
247
269
|
There are a number of things to consider:
|
|
270
|
+
|
|
248
271
|
- Templates need to be matched by the regular expression pattern or otherwise
|
|
249
272
|
an auto-fixed source would again fail linting. This needs to be validated
|
|
250
273
|
manually today as the plugin does not do it for you.
|
|
@@ -257,6 +280,7 @@ The third argument of the rule configuration which defaults to 1 specifies the
|
|
|
257
280
|
number of newlines that are enforced after the header.
|
|
258
281
|
|
|
259
282
|
Zero newlines:
|
|
283
|
+
|
|
260
284
|
```json
|
|
261
285
|
{
|
|
262
286
|
"plugins": [
|
|
@@ -275,12 +299,14 @@ Zero newlines:
|
|
|
275
299
|
}
|
|
276
300
|
}
|
|
277
301
|
```
|
|
302
|
+
|
|
278
303
|
```js
|
|
279
304
|
/* Copyright now
|
|
280
305
|
My Company */ console.log(1)
|
|
281
306
|
```
|
|
282
307
|
|
|
283
308
|
One newline (default):
|
|
309
|
+
|
|
284
310
|
```json
|
|
285
311
|
{
|
|
286
312
|
"plugins": [
|
|
@@ -299,6 +325,7 @@ One newline (default):
|
|
|
299
325
|
}
|
|
300
326
|
}
|
|
301
327
|
```
|
|
328
|
+
|
|
302
329
|
```js
|
|
303
330
|
/* Copyright now
|
|
304
331
|
My Company */
|
|
@@ -306,6 +333,7 @@ console.log(1)
|
|
|
306
333
|
```
|
|
307
334
|
|
|
308
335
|
Two newlines:
|
|
336
|
+
|
|
309
337
|
```json
|
|
310
338
|
{
|
|
311
339
|
"plugins": [
|
|
@@ -324,6 +352,7 @@ Two newlines:
|
|
|
324
352
|
}
|
|
325
353
|
}
|
|
326
354
|
```
|
|
355
|
+
|
|
327
356
|
```js
|
|
328
357
|
/* Copyright now
|
|
329
358
|
My Company */
|
|
@@ -336,6 +365,7 @@ console.log(1)
|
|
|
336
365
|
The rule works with both Unix/POSIX and Windows line endings. For ESLint
|
|
337
366
|
`--fix`, the rule will use the line ending format of the current operating
|
|
338
367
|
system (via Node's `os` package). This setting can be overwritten as follows:
|
|
368
|
+
|
|
339
369
|
```json
|
|
340
370
|
"rules": {
|
|
341
371
|
"header/header": [
|
|
@@ -351,6 +381,7 @@ system (via Node's `os` package). This setting can be overwritten as follows:
|
|
|
351
381
|
]
|
|
352
382
|
}
|
|
353
383
|
```
|
|
384
|
+
|
|
354
385
|
Possible values are `"unix"` for `\n` and `"windows"` for `\r\n` line endings.
|
|
355
386
|
|
|
356
387
|
## Examples
|
|
@@ -380,7 +411,7 @@ console.log(1)
|
|
|
380
411
|
console.log(1)
|
|
381
412
|
```
|
|
382
413
|
|
|
383
|
-
|
|
414
|
+
With more decoration:
|
|
384
415
|
|
|
385
416
|
```json
|
|
386
417
|
"header/header": [2, "block", [
|
|
@@ -399,6 +430,51 @@ console.log(1)
|
|
|
399
430
|
console.log(1);
|
|
400
431
|
```
|
|
401
432
|
|
|
433
|
+
## Versioning
|
|
434
|
+
|
|
435
|
+
The project follows standard [NPM semantic versioning policy](
|
|
436
|
+
https://docs.npmjs.com/about-semantic-versioning).
|
|
437
|
+
|
|
438
|
+
The following guidelines apply:
|
|
439
|
+
|
|
440
|
+
- **major versions** - new functionality that breaks compatibility.
|
|
441
|
+
- **minor versions** - new features that do not break compatibility. For the
|
|
442
|
+
most part we would aim to continue releasing new versions in the 3.x product
|
|
443
|
+
line and have opt-in flags for changes in behavior of existign features.
|
|
444
|
+
- **revisions** - bugfixes and minor non-feature improvements that do not break
|
|
445
|
+
compatibility. Note that bug-fixes are allowed to break compatibility with
|
|
446
|
+
previous version if the older version regressed previous expected behavior.
|
|
447
|
+
|
|
448
|
+
Two concepts are important when going over the above guidelines and we will go
|
|
449
|
+
over them in the next sections.
|
|
450
|
+
|
|
451
|
+
### What is a Feature?
|
|
452
|
+
|
|
453
|
+
We keep the distinction between a feature and a non-feature improvement / bug
|
|
454
|
+
fix as simple as possible:
|
|
455
|
+
|
|
456
|
+
- If configuration changes, it's a **feature**.
|
|
457
|
+
- If it doesn't, then you have two cases:
|
|
458
|
+
- If it changes behavior back to what is expected, it is a bug.
|
|
459
|
+
- If it changes the expected behavior, it is an improvement.
|
|
460
|
+
|
|
461
|
+
### What is Backward-compatibility?
|
|
462
|
+
|
|
463
|
+
Backward compatibility in the context of this plugin relates to how the plugin
|
|
464
|
+
consistently passes or fails one and the same code in between upgrades to newer
|
|
465
|
+
backward-compatible versions. This guarantees that plugin updates can be done
|
|
466
|
+
without breaking CI/CD pipeline linting.
|
|
467
|
+
|
|
468
|
+
Backward-compatibility does not cover the following functional aspects:
|
|
469
|
+
|
|
470
|
+
- Rule violation messages are not kept stable between backward-compatible
|
|
471
|
+
versions. This allows us to improve error reporting in addition to bug fixes.
|
|
472
|
+
- Auto-fix behavior is not stable between backward-compatible versions. As auto-
|
|
473
|
+
fixes are not part of CI/CD processes results of them may vary.
|
|
474
|
+
- Bugs to released functionality. Bugs are considered regression to expected
|
|
475
|
+
functionality regardless of whether they went into a release or not. We fix
|
|
476
|
+
bugs without maintaining bug-compatibility.
|
|
477
|
+
|
|
402
478
|
## License
|
|
403
479
|
|
|
404
480
|
MIT
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* MIT License
|
|
3
3
|
*
|
|
4
|
-
* Copyright (c) 2015-present Stuart Knightley and contributors
|
|
4
|
+
* Copyright (c) 2015-present Stuart Knightley, Tony Ganchev and contributors
|
|
5
5
|
*
|
|
6
6
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
* of this software and associated documentation files (the “Software”), to deal
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* copies of the Software, and to permit persons to whom the Software is
|
|
11
11
|
* furnished to do so, subject to the following conditions:
|
|
12
12
|
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
|
14
|
+
* all copies or substantial portions of the Software.
|
|
15
15
|
*
|
|
16
16
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
17
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
package/lib/comment-parser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* MIT License
|
|
3
3
|
*
|
|
4
|
-
* Copyright (c) 2015-present Stuart Knightley and contributors
|
|
4
|
+
* Copyright (c) 2015-present Stuart Knightley, Tony Ganchev and contributors
|
|
5
5
|
*
|
|
6
6
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
* of this software and associated documentation files (the “Software”), to deal
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* copies of the Software, and to permit persons to whom the Software is
|
|
11
11
|
* furnished to do so, subject to the following conditions:
|
|
12
12
|
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
|
14
|
+
* all copies or substantial portions of the Software.
|
|
15
15
|
*
|
|
16
16
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
17
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
@@ -24,30 +24,32 @@
|
|
|
24
24
|
|
|
25
25
|
"use strict";
|
|
26
26
|
|
|
27
|
+
const assert = require("assert");
|
|
28
|
+
|
|
27
29
|
/**
|
|
28
|
-
* Parses a line or block comment and returns the type of comment and an array
|
|
30
|
+
* Parses a line or block comment and returns the type of comment and an array
|
|
31
|
+
* of content lines.
|
|
29
32
|
*
|
|
30
33
|
* This is a really simple and dumb parser, that looks just for a
|
|
31
34
|
* single kind of comment. It won't detect multiple block comments.
|
|
32
35
|
* @param {string} commentText comment text.
|
|
33
|
-
* @returns {['block' | 'line', string[]]} comment type and comment
|
|
36
|
+
* @returns {['block' | 'line', string | string[]]} comment type and comment
|
|
37
|
+
* content broken into lines.
|
|
34
38
|
*/
|
|
35
39
|
module.exports = function commentParser(commentText) {
|
|
40
|
+
assert.strictEqual(typeof commentText, "string");
|
|
36
41
|
const text = commentText.trim();
|
|
37
42
|
|
|
38
|
-
if (text.
|
|
43
|
+
if (text.startsWith("//")) {
|
|
39
44
|
return [
|
|
40
45
|
"line",
|
|
41
|
-
text.split(/\r?\n/).map(
|
|
42
|
-
return line.substr(2);
|
|
43
|
-
})
|
|
46
|
+
text.split(/\r?\n/).map((line) => line.substring(2))
|
|
44
47
|
];
|
|
45
|
-
} else if (
|
|
46
|
-
text.substr(0, 2) === "/*" &&
|
|
47
|
-
text.substr(-2) === "*/"
|
|
48
|
-
) {
|
|
48
|
+
} else if (text.startsWith("/*") && text.endsWith("*/")) {
|
|
49
49
|
return ["block", text.substring(2, text.length - 2)];
|
|
50
50
|
} else {
|
|
51
|
-
throw new Error(
|
|
51
|
+
throw new Error(
|
|
52
|
+
"Could not parse comment file: the file must contain either just line comments (//) or a single block " +
|
|
53
|
+
"comment (/* ... */)");
|
|
52
54
|
}
|
|
53
55
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025-present Tony Ganchev 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
|
|
14
|
+
* all 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
|
+
|
|
25
|
+
|
|
26
|
+
"use strict";
|
|
27
|
+
|
|
28
|
+
const assert = require("node:assert");
|
|
29
|
+
const fs = require("node:fs");
|
|
30
|
+
const path = require("node:path");
|
|
31
|
+
|
|
32
|
+
const packageJsonContent = fs.readFileSync(path.resolve(__dirname, "../../package.json"));
|
|
33
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
34
|
+
assert.equal(Object.prototype.hasOwnProperty.call(packageJson, "version"), true,
|
|
35
|
+
"The plugin's package.json should be available two directories above the rule.");
|
|
36
|
+
const pluginVersion = packageJsonContent.version;
|
|
37
|
+
|
|
38
|
+
exports.description = "";
|
|
39
|
+
exports.recommended = true;
|
|
40
|
+
exports.url = "https://www.npmjs.com/package/@tony.ganchev/eslint-plugin-header/v/" + pluginVersion;
|