@tony.ganchev/eslint-plugin-header 3.1.2 → 3.1.4
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/.github/workflows/npm-publish.yml +33 -0
- package/.github/workflows/test.yml +1 -1
- package/CHANGELOG.md +8 -0
- package/eslint.config.mjs +168 -0
- package/lib/rules/header.js +91 -2
- package/package.json +7 -4
- package/.eslintrc.yml +0 -94
|
@@ -0,0 +1,33 @@
|
|
|
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: 24
|
|
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: 24
|
|
29
|
+
registry-url: https://registry.npmjs.org/
|
|
30
|
+
- run: npm ci
|
|
31
|
+
- run: npm publish
|
|
32
|
+
env:
|
|
33
|
+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import js from "@eslint/js";
|
|
6
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
7
|
+
import jsdoc from "eslint-plugin-jsdoc";
|
|
8
|
+
|
|
9
|
+
const filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const dirname = path.dirname(filename);
|
|
11
|
+
const compat = new FlatCompat({
|
|
12
|
+
baseDirectory: dirname,
|
|
13
|
+
recommendedConfig: js.configs.recommended,
|
|
14
|
+
allConfig: js.configs.all
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const jsRules = {
|
|
18
|
+
extends: [
|
|
19
|
+
...compat.extends("eslint:recommended"),
|
|
20
|
+
],
|
|
21
|
+
rules: {
|
|
22
|
+
indent: [2, 4, {
|
|
23
|
+
SwitchCase: 1,
|
|
24
|
+
}],
|
|
25
|
+
|
|
26
|
+
"brace-style": [2, "1tbs"],
|
|
27
|
+
|
|
28
|
+
camelcase: [2, {
|
|
29
|
+
properties: "never",
|
|
30
|
+
}],
|
|
31
|
+
|
|
32
|
+
"callback-return": [2, ["cb", "callback", "next"]],
|
|
33
|
+
"comma-spacing": 2,
|
|
34
|
+
"comma-style": [2, "last"],
|
|
35
|
+
"consistent-return": 2,
|
|
36
|
+
curly: [2, "all"],
|
|
37
|
+
"default-case": 2,
|
|
38
|
+
|
|
39
|
+
"dot-notation": [2, {
|
|
40
|
+
allowKeywords: true,
|
|
41
|
+
}],
|
|
42
|
+
|
|
43
|
+
"eol-last": 2,
|
|
44
|
+
eqeqeq: 2,
|
|
45
|
+
"func-style": [2, "declaration"],
|
|
46
|
+
"guard-for-in": 2,
|
|
47
|
+
|
|
48
|
+
"key-spacing": [2, {
|
|
49
|
+
beforeColon: false,
|
|
50
|
+
afterColon: true,
|
|
51
|
+
}],
|
|
52
|
+
|
|
53
|
+
"new-cap": 2,
|
|
54
|
+
"new-parens": 2,
|
|
55
|
+
"no-alert": 2,
|
|
56
|
+
"no-array-constructor": 2,
|
|
57
|
+
"no-caller": 2,
|
|
58
|
+
"no-console": 0,
|
|
59
|
+
"no-delete-var": 2,
|
|
60
|
+
"no-eval": 2,
|
|
61
|
+
"no-extend-native": 2,
|
|
62
|
+
"no-extra-bind": 2,
|
|
63
|
+
"no-fallthrough": 2,
|
|
64
|
+
"no-floating-decimal": 2,
|
|
65
|
+
"no-implied-eval": 2,
|
|
66
|
+
"no-invalid-this": 2,
|
|
67
|
+
"no-iterator": 2,
|
|
68
|
+
"no-label-var": 2,
|
|
69
|
+
"no-labels": 2,
|
|
70
|
+
"no-lone-blocks": 2,
|
|
71
|
+
"no-loop-func": 2,
|
|
72
|
+
"no-mixed-spaces-and-tabs": [2, false],
|
|
73
|
+
"no-multi-spaces": 2,
|
|
74
|
+
"no-multi-str": 2,
|
|
75
|
+
"no-native-reassign": 2,
|
|
76
|
+
"no-nested-ternary": 2,
|
|
77
|
+
"no-new": 2,
|
|
78
|
+
"no-new-func": 2,
|
|
79
|
+
"no-new-object": 2,
|
|
80
|
+
"no-new-wrappers": 2,
|
|
81
|
+
"no-octal": 2,
|
|
82
|
+
"no-octal-escape": 2,
|
|
83
|
+
"no-process-exit": 2,
|
|
84
|
+
"no-proto": 2,
|
|
85
|
+
"no-redeclare": 2,
|
|
86
|
+
"no-return-assign": 2,
|
|
87
|
+
"no-script-url": 2,
|
|
88
|
+
"no-sequences": 2,
|
|
89
|
+
"no-shadow": 2,
|
|
90
|
+
"no-shadow-restricted-names": 2,
|
|
91
|
+
"no-spaced-func": 2,
|
|
92
|
+
"no-trailing-spaces": 2,
|
|
93
|
+
"no-undef": 2,
|
|
94
|
+
"no-undef-init": 2,
|
|
95
|
+
"no-undefined": 2,
|
|
96
|
+
"no-underscore-dangle": 2,
|
|
97
|
+
"no-unused-expressions": 2,
|
|
98
|
+
|
|
99
|
+
"no-unused-vars": [2, {
|
|
100
|
+
vars: "all",
|
|
101
|
+
args: "after-used",
|
|
102
|
+
}],
|
|
103
|
+
|
|
104
|
+
"no-use-before-define": 2,
|
|
105
|
+
"no-with": 2,
|
|
106
|
+
quotes: [2, "double"],
|
|
107
|
+
radix: 2,
|
|
108
|
+
semi: 2,
|
|
109
|
+
|
|
110
|
+
"semi-spacing": [2, {
|
|
111
|
+
before: false,
|
|
112
|
+
after: true,
|
|
113
|
+
}],
|
|
114
|
+
|
|
115
|
+
"keyword-spacing": [2, {
|
|
116
|
+
after: true,
|
|
117
|
+
}],
|
|
118
|
+
|
|
119
|
+
"space-before-blocks": 2,
|
|
120
|
+
"space-before-function-paren": [2, "never"],
|
|
121
|
+
"space-infix-ops": 2,
|
|
122
|
+
|
|
123
|
+
"space-unary-ops": [2, {
|
|
124
|
+
words: true,
|
|
125
|
+
nonwords: false,
|
|
126
|
+
}],
|
|
127
|
+
|
|
128
|
+
"spaced-comment": [2, "always", {
|
|
129
|
+
exceptions: ["-"],
|
|
130
|
+
}],
|
|
131
|
+
|
|
132
|
+
strict: [2, "global"],
|
|
133
|
+
|
|
134
|
+
"wrap-iife": 2,
|
|
135
|
+
yoda: [2, "never"],
|
|
136
|
+
"no-catch-shadow": 0,
|
|
137
|
+
"no-mixed-requires": 2,
|
|
138
|
+
"no-new-require": 2,
|
|
139
|
+
"no-path-concat": 2,
|
|
140
|
+
"global-strict": [0, "always"],
|
|
141
|
+
"handle-callback-err": [2, "err"],
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export default defineConfig([
|
|
146
|
+
jsdoc.configs["flat/recommended"],
|
|
147
|
+
{
|
|
148
|
+
files: ["lib/**/*.js"],
|
|
149
|
+
languageOptions: {
|
|
150
|
+
sourceType: "commonjs",
|
|
151
|
+
globals: {
|
|
152
|
+
...globals.node,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
...jsRules,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
files: ["tests/**/*.js"],
|
|
159
|
+
languageOptions: {
|
|
160
|
+
sourceType: "script",
|
|
161
|
+
globals: {
|
|
162
|
+
...globals.node,
|
|
163
|
+
...globals.mocha,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
...jsRules,
|
|
167
|
+
},
|
|
168
|
+
]);
|
package/lib/rules/header.js
CHANGED
|
@@ -122,11 +122,100 @@ module.exports = {
|
|
|
122
122
|
meta: {
|
|
123
123
|
type: "layout",
|
|
124
124
|
fixable: "whitespace",
|
|
125
|
-
schema:
|
|
125
|
+
schema: {
|
|
126
|
+
$ref: "#/definitions/options",
|
|
127
|
+
definitions: {
|
|
128
|
+
commentType: {
|
|
129
|
+
type: "string",
|
|
130
|
+
enum: ["block", "line"]
|
|
131
|
+
},
|
|
132
|
+
line: {
|
|
133
|
+
anyOf: [
|
|
134
|
+
{
|
|
135
|
+
type: "string"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: {
|
|
140
|
+
pattern: {
|
|
141
|
+
type: "string"
|
|
142
|
+
},
|
|
143
|
+
template: {
|
|
144
|
+
type: "string"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
required: ["pattern"],
|
|
148
|
+
additionalProperties: false
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
headerLines: {
|
|
153
|
+
anyOf: [
|
|
154
|
+
{
|
|
155
|
+
$ref: "#/definitions/line"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
type: "array",
|
|
159
|
+
items: {
|
|
160
|
+
$ref: "#/definitions/line"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
numNewlines: {
|
|
166
|
+
type: "integer",
|
|
167
|
+
minimum: 0
|
|
168
|
+
},
|
|
169
|
+
settings: {
|
|
170
|
+
type: "object",
|
|
171
|
+
properties: {
|
|
172
|
+
lineEndings: {
|
|
173
|
+
type: "string",
|
|
174
|
+
enum: ["unix", "windows"]
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
additionalProperties: false
|
|
178
|
+
},
|
|
179
|
+
options: {
|
|
180
|
+
anyOf: [
|
|
181
|
+
{
|
|
182
|
+
type: "array",
|
|
183
|
+
minItems: 1,
|
|
184
|
+
maxItems: 2,
|
|
185
|
+
items: [
|
|
186
|
+
{ type: "string" },
|
|
187
|
+
{ $ref: "#/definitions/settings" }
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
type: "array",
|
|
192
|
+
minItems: 2,
|
|
193
|
+
maxItems: 3,
|
|
194
|
+
items: [
|
|
195
|
+
{ $ref: "#/definitions/commentType" },
|
|
196
|
+
{ $ref: "#/definitions/headerLines" },
|
|
197
|
+
{ $ref: "#/definitions/settings" }
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
type: "array",
|
|
202
|
+
minItems: 3,
|
|
203
|
+
maxItems: 4,
|
|
204
|
+
items: [
|
|
205
|
+
{ $ref: "#/definitions/commentType" },
|
|
206
|
+
{ $ref: "#/definitions/headerLines" },
|
|
207
|
+
{ $ref: "#/definitions/numNewlines" },
|
|
208
|
+
{ $ref: "#/definitions/settings" }
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
126
215
|
},
|
|
127
216
|
create: function(context) {
|
|
128
217
|
var options = context.options;
|
|
129
|
-
var numNewlines = options.length > 2 ? options[2] : 1;
|
|
218
|
+
var numNewlines = options.length > 2 && typeof options[2] === "number" ? options[2] : 1;
|
|
130
219
|
var eol = getEOL(options);
|
|
131
220
|
|
|
132
221
|
// If just one option then read comment from file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tony.ganchev/eslint-plugin-header",
|
|
3
|
-
"version": "3.1.
|
|
4
|
-
"description": "ESLint plugin to ensure
|
|
3
|
+
"version": "3.1.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
|
"scripts": {
|
|
7
7
|
"test": "npm run lint && npm run unit",
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
"lint": "eslint ."
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"eslint": "^
|
|
13
|
-
"
|
|
12
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
13
|
+
"@eslint/js": "^9.32.0",
|
|
14
|
+
"eslint": "^9.32.0",
|
|
15
|
+
"eslint-plugin-jsdoc": "^52.0.4",
|
|
16
|
+
"mocha": "^11.7.1"
|
|
14
17
|
},
|
|
15
18
|
"peerDependencies": {
|
|
16
19
|
"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"]
|