@tony.ganchev/eslint-plugin-header 3.4.0 → 3.4.2

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/README.md CHANGED
@@ -7,8 +7,8 @@
7
7
  The native ESLint 9/10 standard header-validating plugin. A zero-bloat, drop-in
8
8
  replacement for [eslint-plugin-header](https://github.com/Stuk/eslint-plugin-header)
9
9
  with first-class Flat Config & TypeScript support. Auto-fix copyright, license,
10
- and banner comments in JavaScript, TypeScript, CSS, HTML, and Markdown files.
11
- Supports _oxlint_.
10
+ and banner comments in JavaScript, TypeScript, Vue, Svelte, CSS, HTML, and
11
+ Markdown files. Supports _oxlint_.
12
12
 
13
13
  ## Table of Contents
14
14
 
@@ -30,11 +30,14 @@ Supports _oxlint_.
30
30
  4. [Examples](#examples)
31
31
  5. [Linting CSS](#linting-css)
32
32
  6. [Linting HTML](#linting-html)
33
- 7. [Linting Markdown](#linting-markdown)
33
+ 7. [Linting Vue](#linting-vue)
34
+ 8. [Linting Svelte](#linting-svelte)
35
+ 9. [Linting Markdown](#linting-markdown)
34
36
  5. [Comparison to Alternatives](#comparison-to-alternatives)
35
37
  1. [Compared to eslint-plugin-headers](#compared-to-eslint-plugin-headers)
36
38
  1. [Health Scans](#health-scans)
37
39
  2. [Compared to eslint-plugin-license-header](#compared-to-eslint-plugin-license-header)
40
+ 3. [Compared to eslint-plugin-notice](#compared-to-eslint-plugin-notice)
38
41
  6. [Versioning](#versioning)
39
42
  1. [What is a Feature?](#what-is-a-feature)
40
43
  2. [What is Backward-compatibility?](#what-is-backward-compatibility)
@@ -117,7 +120,7 @@ copyright headers in CSS, HTML, or Markdown rely on APIs introduced with ESLint
117
120
  The plugin works with latest version of **oxlint** too. We have a smoke-test
118
121
  running to confirm the plugin works with the latest version of oxlint. Features
119
122
  relying on the use of non-standard parsers such as linting headers in CSS, HTML,
120
- or Markdown cannot be supported.
123
+ Vue, or Markdown cannot be supported.
121
124
 
122
125
  ### Configuration Formats
123
126
 
@@ -131,9 +134,9 @@ statements. Smoke tests cover this support as well.
131
134
  ### Languages
132
135
 
133
136
  Currently the plugin supports linting copyright headers in JavaScript,
134
- TypeScript and their JSX / TSX flavors; CSS, HTML, and Markdown files. As
135
- mentioned in the previous sections, not all languages are supported for oxlint
136
- or ESLint older than 9. Refer to the table below for more details.
137
+ TypeScript and their JSX / TSX flavors; Vue, Svelte, CSS, HTML, and Markdown
138
+ files. As mentioned in the previous sections, not all languages are supported
139
+ for oxlint or ESLint older than 9. Refer to the table below for more details.
137
140
 
138
141
  | Language | ESLint 7 / 8 | ESLint 9 / 10 | oxlint |
139
142
  |------------|---------------|---------------|--------|
@@ -141,6 +144,8 @@ or ESLint older than 9. Refer to the table below for more details.
141
144
  | TypeScript | ✅ Yes | ✅ Yes | ✅ Yes |
142
145
  | JSX | ✅ Yes | ✅ Yes | ✅ Yes |
143
146
  | TSX | ✅ Yes | ✅ Yes | ✅ Yes |
147
+ | Vue | ✅ Yes | ✅ Yes | ❌ No |
148
+ | Svelte | ✅ Yes | ✅ Yes | ❌ No |
144
149
  | CSS | ❌ No | ✅ Yes | ❌ No |
145
150
  | HTML | ❌ No | ✅ Yes | ❌ No |
146
151
  | Markdown | ❌ No | ✅ Yes | ❌ No |
@@ -1328,6 +1333,103 @@ export default [
1328
1333
 
1329
1334
  As with CSS, only block comments are supported - no line- or shebang comments.
1330
1335
 
1336
+ ### Linting Vue
1337
+
1338
+ The rule supports linting copyright notices in Vue files. The rule works with
1339
+ the _eslint-plugin-vue_ plugin and its parser.
1340
+
1341
+ To turn on header validation for Vue files, configure the parser, the plugin,
1342
+ and the rule:
1343
+
1344
+ ```ts
1345
+ import header from "@tony.ganchev/eslint-plugin-header";
1346
+ import vueParser from "vue-eslint-parser";
1347
+ import vuePlugin from "eslint-plugin-vue";
1348
+
1349
+ export default [
1350
+ {
1351
+ files: ["**/*.vue"],
1352
+ plugins: {
1353
+ "@tony.ganchev": header,
1354
+ vue: vuePlugin
1355
+ },
1356
+ languageOptions: {
1357
+ parser: vueParser
1358
+ },
1359
+ rules: {
1360
+ "@tony.ganchev/header": [
1361
+ "error",
1362
+ {
1363
+ header: {
1364
+ commentType: "block",
1365
+ lines: [" Copyright 2025 "]
1366
+ }
1367
+ }
1368
+ ]
1369
+ }
1370
+ }
1371
+ ];
1372
+ ```
1373
+
1374
+ ```vue
1375
+ <!-- Copyright 2025 -->
1376
+ <template>
1377
+ <div>Hello, world!</div>
1378
+ </template>
1379
+ ```
1380
+
1381
+ As with HTML and CSS, only block comments are supported at the top of the file -
1382
+ no line- or shebang comments.
1383
+
1384
+ ### Linting Svelte
1385
+
1386
+ The rule supports linting copyright notices in Svelte files. The rule works with
1387
+ the _eslint-plugin-svelte_ plugin and its parser.
1388
+
1389
+ To turn on header validation for Svelte files, configure the parser and the rule:
1390
+
1391
+ ```ts
1392
+ import header from "@tony.ganchev/eslint-plugin-header";
1393
+ import svelteParser from "svelte-eslint-parser";
1394
+ import sveltePlugin from "eslint-plugin-svelte";
1395
+
1396
+ export default [
1397
+ {
1398
+ files: ["**/*.svelte"],
1399
+ plugins: {
1400
+ "@tony.ganchev": header,
1401
+ svelte: sveltePlugin
1402
+ },
1403
+ languageOptions: {
1404
+ parser: svelteParser
1405
+ },
1406
+ rules: {
1407
+ "@tony.ganchev/header": [
1408
+ "error",
1409
+ {
1410
+ header: {
1411
+ commentType: "block",
1412
+ lines: [" Copyright 2025 "]
1413
+ }
1414
+ }
1415
+ ]
1416
+ }
1417
+ }
1418
+ ];
1419
+ ```
1420
+
1421
+ ```svelte
1422
+ <!-- Copyright 2025 -->
1423
+ <script>
1424
+ let name = 'world';
1425
+ </script>
1426
+
1427
+ <h1>Hello {name}!</h1>
1428
+ ```
1429
+
1430
+ As with Vue, HTML and CSS, only block comments are supported at the top of the
1431
+ file - no line- or shebang comments.
1432
+
1331
1433
  ### Linting Markdown
1332
1434
 
1333
1435
  The rule supports copyright comments in Markdown syntax in both _commonmark_ and
@@ -1403,12 +1505,16 @@ _eslint-plugin-header_ and all plugins that already use the latter can migrate
1403
1505
  to the fork right away. At the same time, it provides improved user experience
1404
1506
  and windows support.
1405
1507
 
1406
- eslint-plugin-headers is not a drop-in replacement. It offers additional
1407
- features. Some of them, such as support for Vue templates do not have an
1408
- analogue in the current version of _\@tony.ganchev/eslint-plugin-header_ while
1409
- others such as `{year}` variable placeholders are redundant in the world of
1410
- ESLint 9's flat, JavaScript-based configuration as [already pointed out in this
1411
- document](#providing-to-year-in-auto-fix).
1508
+ _eslint-plugin-headers_ is not a drop-in replacement. It offers additional
1509
+ features that are not first-level use-cases for
1510
+ _\@tony.ganchev/eslint-plugin-header_. One example is support for `{year}`
1511
+ variable placeholders which are redundant with ESLint's JavaScript-based
1512
+ configuration as [already pointed out in this document](#providing-to-year-in-auto-fix).
1513
+ JSDoc support can be achieved with regular expressions and the overall
1514
+ configuration capabilities of _\@tony.ganchev/eslint-plugin-header_. It is worth
1515
+ noting that the source code of _\@tony.ganchev/eslint-plugin-header_ already
1516
+ uses JSDoc-style comments for its own header which are in turn validated using
1517
+ _\@tony.ganchev/eslint-plugin-header/header_ rule.
1412
1518
 
1413
1519
  The configuration format philosophy of the two plugin differs.
1414
1520
  _\@tony.ganchev/eslint-plugin-header_ supports both the legacy model inherited
@@ -1475,6 +1581,30 @@ We have prepared a detailed
1475
1581
  [migration guide](docs/migrate-from-license-header.md) for anyone eager to
1476
1582
  migrate to _\@tony.ganchev/eslint-plugin-header_.
1477
1583
 
1584
+ ### Compared to [eslint-plugin-notice](https://github.com/earl-man/eslint-plugin-notice)
1585
+
1586
+ _eslint-plugin-notice_ is another alternative that uses a template-based approach
1587
+ (powered by Lodash templates) to manage headers. This makes it quite powerful for
1588
+ dynamic content but also brings in more dependencies and a more complex
1589
+ configuration schema that doesn't always feel "native" to the new ESLint Flat
1590
+ Config era.
1591
+
1592
+ Key differences:
1593
+
1594
+ - **Philosophy**: _\@tony.ganchev/eslint-plugin-header_ focuses on a zero-bloat,
1595
+ native ESLint feel with first-class support for Flat Config and TypeScript.
1596
+ - **ESLint 9/10**: Our plugin is built from the ground up to support the latest
1597
+ ESLint versions and their core features.
1598
+ - **Languages**: We provide native support for linting headers in HTML, CSS,
1599
+ and Markdown via their respective ESLint ecosystem plugins.
1600
+ - **Simplicity**: No need for external template engines or complex variable
1601
+ mappings. Use standard JavaScript template literals in your `eslint.config.ts`
1602
+ to handle dynamic years or other variables.
1603
+
1604
+ We have prepared a detailed
1605
+ [migration guide](docs/migrate-from-notice.md) for anyone eager to
1606
+ migrate to _\@tony.ganchev/eslint-plugin-header_.
1607
+
1478
1608
  ## Versioning
1479
1609
 
1480
1610
  The project follows standard [NPM semantic versioning policy](
@@ -37,10 +37,8 @@ const assert = require("node:assert");
37
37
  * This is a really simple and dumb parser, that looks just for a
38
38
  * single kind of comment. It won't detect multiple block comments.
39
39
  * @param {string} commentText Content to parse.
40
- * @param {Language} language The language
41
- * configuration.
42
- * @returns {[CommentType, string[]]} Comment type and
43
- * content.
40
+ * @param {Language} language The language configuration.
41
+ * @returns {[CommentType, string[]]} Comment type and content.
44
42
  * @throws {Error} If `commentText` starts with an unrecognized comment token.
45
43
  */
46
44
  module.exports = function commentParser(commentText, language) {
@@ -1205,13 +1205,46 @@ const headerRule = {
1205
1205
  }
1206
1206
  };
1207
1207
 
1208
+ /**
1209
+ * Tests if the source code was parsed by _@html-eslint/eslint-plugin_'s
1210
+ * parser.
1211
+ * @returns {boolean} `true` if the source code is parsed by the parser.
1212
+ */
1213
+ function isHtmlParser() {
1214
+ return sourceCode.constructor.name === "HTMLSourceCode";
1215
+ }
1216
+
1217
+ /**
1218
+ * Tests if the source code was parsed by _vue-eslint-parser_.
1219
+ * @returns {boolean} `true` if the source code is parsed by the parser.
1220
+ */
1221
+ function isVueParser() {
1222
+ // Vue parser mimic JS parser identity but has a
1223
+ // template section under its AST.
1224
+ return "templateBody" in sourceCode.ast;
1225
+ }
1226
+
1227
+ /**
1228
+ * Tests if the source code was parsed by _svelte-eslint-parser_.
1229
+ * @returns {boolean} `true` if the source code is parsed by the parser.
1230
+ */
1231
+ function isSvelteParser() {
1232
+ // Svelte parser mimic JS parser identity but has an
1233
+ // identifier in its `parserServices` section.
1234
+ return sourceCode.parserServices.isSvelte;
1235
+ }
1236
+
1237
+ /**
1238
+ * Tests if the source code is parsed by a HTML-style language parser.
1239
+ * @returns {boolean} `true` if the source code is parsed by a
1240
+ * HTML-style language parser.
1241
+ */
1242
+ function isHtmlStyleLanguage() {
1243
+ return isHtmlParser() || isVueParser() || isSvelteParser();
1244
+ };
1245
+
1208
1246
  const hooks = {
1209
- Program: () =>
1210
- onRootNode(
1211
- sourceCode.constructor.name === "HTMLSourceCode"
1212
- ? htmlStyleLanguage
1213
- : jsStyleLanguage
1214
- ),
1247
+ Program: () => onRootNode(isHtmlStyleLanguage() ? htmlStyleLanguage : jsStyleLanguage),
1215
1248
  StyleSheet: () => onRootNode(cssStyleLanguage),
1216
1249
  // eslint/markdown
1217
1250
  root: () => onRootNode(htmlStyleLanguage),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tony.ganchev/eslint-plugin-header",
3
- "version": "3.4.0",
4
- "description": "The native ESLint 9/10 header plugin. A zero-bloat, drop-in replacement for 'eslint-plugin-header' with first-class Flat Config & TypeScript support. Auto-fix Copyright, License, and banner comments in JavaScrip, TypeScript, CSS, HTML, and Markdown files. Supports oxlint.",
3
+ "version": "3.4.2",
4
+ "description": "The native ESLint 9/10 header plugin. A zero-bloat, drop-in replacement for 'eslint-plugin-header' with first-class Flat Config & TypeScript support. Auto-fix Copyright, License, and banner comments in JavaScript, TypeScript, Vue, Svelte, CSS, HTML, and Markdown files. Supports oxlint.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "exports": {
@@ -32,12 +32,16 @@
32
32
  "eslint-plugin-eslint-plugin": "^7.3.2",
33
33
  "eslint-plugin-jsdoc": "^62.9.0",
34
34
  "eslint-plugin-n": "^17.24.0",
35
+ "eslint-plugin-svelte": "^3.17.0",
36
+ "eslint-plugin-vue": "^10.8.0",
35
37
  "globals": "^17.4.0",
36
38
  "markdownlint-cli": "^0.48.0",
37
39
  "mocha": "12.0.0-beta-10",
40
+ "svelte-eslint-parser": "^1.6.0",
38
41
  "testdouble": "^3.20.2",
39
42
  "typescript": "^5.9.3",
40
- "typescript-eslint": "^8.58.0"
43
+ "typescript-eslint": "^8.58.0",
44
+ "vue-eslint-parser": "^10.4.0"
41
45
  },
42
46
  "peerDependencies": {
43
47
  "eslint": ">=7.7.0"
@@ -74,7 +78,13 @@
74
78
  "oxc",
75
79
  "react",
76
80
  "source-header",
77
- "typescript"
81
+ "svelte",
82
+ "sveltejs",
83
+ "svelte-js",
84
+ "typescript",
85
+ "vue",
86
+ "vuejs",
87
+ "vue-js"
78
88
  ],
79
89
  "repository": {
80
90
  "type": "git",
@@ -1 +1 @@
1
- {"version":3,"file":"comment-parser.d.ts","sourceRoot":"","sources":["../../lib/comment-parser.js"],"names":[],"mappings":"AA6CiB,uCAPN,MAAM,YACN,QAAQ,GAEN,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,CA4BnC;;8BAxCyC,gBAAgB;iCAAhB,gBAAgB"}
1
+ {"version":3,"file":"comment-parser.d.ts","sourceRoot":"","sources":["../../lib/comment-parser.js"],"names":[],"mappings":"AA2CiB,uCALN,MAAM,YACN,QAAQ,GACN,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,CA2BnC;;8BAtCyC,gBAAgB;iCAAhB,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../lib/rules/header.js"],"names":[],"mappings":"2BAsCa,iBAAiB;0BACjB,gBAAgB;wBAChB,cAAc;0BACd,gBAAgB;;;;;yBAIhB,IAAI,GAAG,MAAM;;;;;;;;;;aAOZ,MAAM,GAAG,MAAM;;;;;;;;;;;;yBAOhB,MAAM,GAAG,MAAM,GAAG,iBAAiB;;;;;0BAGnC,UAAU,G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