@tony.ganchev/eslint-plugin-header 3.1.11 → 3.2.0
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 +1 -1
- package/README.md +488 -186
- package/lib/comment-parser.js +3 -3
- package/lib/rules/eslint-utils.js +42 -0
- package/lib/rules/header.js +261 -107
- package/lib/rules/header.schema.js +91 -13
- package/package.json +14 -12
|
@@ -46,22 +46,31 @@ const schema = Object.freeze({
|
|
|
46
46
|
definitions: {
|
|
47
47
|
commentType: {
|
|
48
48
|
type: "string",
|
|
49
|
-
enum: [commentTypeOptions.block, commentTypeOptions.line]
|
|
49
|
+
enum: [commentTypeOptions.block, commentTypeOptions.line],
|
|
50
|
+
description: "Type of comment to expect as the header."
|
|
51
|
+
},
|
|
52
|
+
regExp: {
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: {
|
|
55
|
+
source: { type: "string" }
|
|
56
|
+
},
|
|
57
|
+
required: ["source"],
|
|
58
|
+
additionalProperties: true,
|
|
50
59
|
},
|
|
51
60
|
line: {
|
|
52
61
|
anyOf: [
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
},
|
|
62
|
+
{ type: "string" },
|
|
63
|
+
{ $ref: "#/definitions/regExp" },
|
|
56
64
|
{
|
|
57
65
|
type: "object",
|
|
58
66
|
properties: {
|
|
59
67
|
pattern: {
|
|
60
|
-
|
|
68
|
+
anyOf: [
|
|
69
|
+
{ type: "string" },
|
|
70
|
+
{ $ref: "#/definitions/regExp" },
|
|
71
|
+
]
|
|
61
72
|
},
|
|
62
|
-
template: {
|
|
63
|
-
type: "string"
|
|
64
|
-
}
|
|
73
|
+
template: { type: "string" }
|
|
65
74
|
},
|
|
66
75
|
required: ["pattern"],
|
|
67
76
|
additionalProperties: false
|
|
@@ -70,9 +79,7 @@ const schema = Object.freeze({
|
|
|
70
79
|
},
|
|
71
80
|
headerLines: {
|
|
72
81
|
anyOf: [
|
|
73
|
-
{
|
|
74
|
-
$ref: "#/definitions/line"
|
|
75
|
-
},
|
|
82
|
+
{ $ref: "#/definitions/line" },
|
|
76
83
|
{
|
|
77
84
|
type: "array",
|
|
78
85
|
items: {
|
|
@@ -85,18 +92,89 @@ const schema = Object.freeze({
|
|
|
85
92
|
type: "integer",
|
|
86
93
|
minimum: 0
|
|
87
94
|
},
|
|
95
|
+
lineEndings: {
|
|
96
|
+
type: "string",
|
|
97
|
+
enum: [lineEndingOptions.unix, lineEndingOptions.windows, lineEndingOptions.os],
|
|
98
|
+
description: "Line endings to use when aut-fixing the violations. Defaults to 'os' which means 'same as " +
|
|
99
|
+
"system'."
|
|
100
|
+
},
|
|
88
101
|
settings: {
|
|
89
102
|
type: "object",
|
|
90
103
|
properties: {
|
|
91
|
-
lineEndings: {
|
|
104
|
+
lineEndings: { $ref: "#/definitions/lineEndings" },
|
|
105
|
+
},
|
|
106
|
+
additionalProperties: false
|
|
107
|
+
},
|
|
108
|
+
fileBasedHeader: {
|
|
109
|
+
type: "object",
|
|
110
|
+
properties: {
|
|
111
|
+
file: {
|
|
92
112
|
type: "string",
|
|
93
|
-
|
|
113
|
+
description: "Name of a file relative to the current directory (no back-tracking) that contains " +
|
|
114
|
+
"the header template. It should contain a single block comment or a contiguous number of " +
|
|
115
|
+
"line comments."
|
|
116
|
+
},
|
|
117
|
+
encoding: {
|
|
118
|
+
type: "string",
|
|
119
|
+
description: "Character encoding to use when parsing the file. Valid values are all encodings " +
|
|
120
|
+
"that can be passed to `fs.readFileSync()`. If not specified, 'utf8' would be used."
|
|
121
|
+
// NOTE: default value not supported by the ajv schema
|
|
122
|
+
// validator and there is no way to fix it through the
|
|
123
|
+
// plugin's `meta.defaultOptions`.
|
|
94
124
|
}
|
|
95
125
|
},
|
|
126
|
+
required: ["file"],
|
|
96
127
|
additionalProperties: false
|
|
97
128
|
},
|
|
129
|
+
inlineHeader: {
|
|
130
|
+
type: "object",
|
|
131
|
+
properties: {
|
|
132
|
+
commentType: { $ref: "#/definitions/commentType" },
|
|
133
|
+
lines: {
|
|
134
|
+
type: "array",
|
|
135
|
+
items: { $ref: "#/definitions/line" },
|
|
136
|
+
description: "List of each line of the header - each being a string to match exactly or a " +
|
|
137
|
+
"combination of a regex pattern to match and an optional template string as the fix."
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
required: ["commentType", "lines"],
|
|
141
|
+
additionalProperties: false
|
|
142
|
+
},
|
|
143
|
+
trailingEmptyLines: {
|
|
144
|
+
type: "object",
|
|
145
|
+
properties: {
|
|
146
|
+
minimum: {
|
|
147
|
+
type: "number",
|
|
148
|
+
description: "Number of empty lines required after the header. Defaults to 1.",
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
additionalProperties: false,
|
|
152
|
+
description: "Configuration for how to validate and fix the set of empty lines after the header."
|
|
153
|
+
},
|
|
154
|
+
newOptions: {
|
|
155
|
+
type: "object",
|
|
156
|
+
properties: {
|
|
157
|
+
header: {
|
|
158
|
+
anyOf: [
|
|
159
|
+
{ $ref: "#/definitions/fileBasedHeader" },
|
|
160
|
+
{ $ref: "#/definitions/inlineHeader" }
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
lineEndings: { $ref: "#/definitions/lineEndings" },
|
|
164
|
+
trailingEmptyLines: { $ref: "#/definitions/trailingEmptyLines" }
|
|
165
|
+
},
|
|
166
|
+
required: ["header"],
|
|
167
|
+
additionalProperties: false,
|
|
168
|
+
description: "Object-based extensible configuration format to use with the `header` rule."
|
|
169
|
+
},
|
|
98
170
|
options: {
|
|
99
171
|
anyOf: [
|
|
172
|
+
{
|
|
173
|
+
type: "array",
|
|
174
|
+
minItems: 1,
|
|
175
|
+
maxItems: 1,
|
|
176
|
+
items: { $ref: "#/definitions/newOptions" }
|
|
177
|
+
},
|
|
100
178
|
{
|
|
101
179
|
type: "array",
|
|
102
180
|
minItems: 1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tony.ganchev/eslint-plugin-header",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "ESLint plugin to ensure files begin with a given comment, usually a copyright or license notice.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -11,19 +11,21 @@
|
|
|
11
11
|
"eslint": "npx eslint .",
|
|
12
12
|
"lint": "npm run eslint && npm run markdownlint",
|
|
13
13
|
"markdownlint": "npx markdownlint-cli *.md",
|
|
14
|
-
"test": "npm run lint && npm run unit",
|
|
15
|
-
"unit": "npx nyc --reporter=html --reporter=text --reporter=text-summary --reporter=lcov --check-coverage=true --statements=100 --branches=100 --lines=100 --functions=100 mocha tests/lib/*.js tests/lib/**/*.js"
|
|
14
|
+
"test": "npm run lint && npm run unit && npm run e2e",
|
|
15
|
+
"unit": "npx nyc --reporter=html --reporter=text --reporter=text-summary --reporter=lcov --check-coverage=true --statements=100 --branches=100 --lines=100 --functions=100 mocha tests/lib/*.js tests/lib/**/*.js",
|
|
16
|
+
"e2e": "npx mocha --timeout 60000 tests/e2e/*.js"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"@eslint/eslintrc": "^3.3.
|
|
19
|
-
"@eslint/js": "^9.39.
|
|
19
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
20
|
+
"@eslint/js": "^9.39.2",
|
|
20
21
|
"@eslint/markdown": "^7.5.1",
|
|
21
|
-
"@stylistic/eslint-plugin": "^5.
|
|
22
|
-
"eslint": "^9.39.
|
|
23
|
-
"eslint-plugin-eslint-plugin": "^7.
|
|
24
|
-
"eslint-plugin-jsdoc": "^
|
|
25
|
-
"eslint-plugin-n": "^17.23.
|
|
26
|
-
"
|
|
22
|
+
"@stylistic/eslint-plugin": "^5.7.0",
|
|
23
|
+
"eslint": "^9.39.2",
|
|
24
|
+
"eslint-plugin-eslint-plugin": "^7.3.0",
|
|
25
|
+
"eslint-plugin-jsdoc": "^62.1.0",
|
|
26
|
+
"eslint-plugin-n": "^17.23.2",
|
|
27
|
+
"markdownlint-cli": "^0.47.0",
|
|
28
|
+
"mocha": "^12.0.0-beta-5",
|
|
27
29
|
"nyc": "^17.1.0",
|
|
28
30
|
"testdouble": "^3.20.2"
|
|
29
31
|
},
|
|
@@ -40,7 +42,7 @@
|
|
|
40
42
|
},
|
|
41
43
|
"author": "Stuart Knightley",
|
|
42
44
|
"license": "MIT",
|
|
43
|
-
"
|
|
45
|
+
"maintainers": [
|
|
44
46
|
"Tony Ganchev"
|
|
45
47
|
]
|
|
46
48
|
}
|