Skip to content

Conversation

@tonyganchev
Copy link

@tonyganchev tonyganchev commented Jun 10, 2024

Temporary fix to allow the header rule options to pass schema validation introduced in eslint 9 as per https://eslint.org/blog/2024/04/eslint-v9.0.0-released/#changes-to-how-you-write-rules

Fixes #57

@tonyganchev tonyganchev changed the title fix: disable rule options schema validation in eslint 9 fix: disable rule options schema validation in eslint 9, fix https://github.com/Stuk/eslint-plugin-header/issues/57 Jun 10, 2024
@tonyganchev
Copy link
Author

I've published a fork at https://www.npmjs.com/package/@tony.ganchev/eslint-plugin-header containing my fix.

tonyganchev and others added 22 commits June 20, 2025 22:35
In the process, upgraded all  dependencies
Original logic was expecting the third argument of the header rule to always be the number of empty lines expected. Unfortunately, after line-ending character settigns were added as an optional config argument, the logic no longer stands true.
Goal is to use the header rule itself to lint its codebase.
# Why?
Most unit invalid test cases did not pass when running under Windows because test cases expected fixes to use LF and not CR+LF.

# The Fix
Modify node's line ending property using testdouble to ensure the test cases are executed in a POSIX-compatible/simulated environment.

# Upcomming Fix
A subsequent PR will add a good representation of both POSIX and Windows in the test cases.
# The Problem
There was a bug in `genCommentsRange()` where only one character is checked after the comment for an EOL character. Since on Windows we need two characters, the check failed and the wrong number of empty lines was added on windows (desired+1) which caused both tests to fail and the autofix to give different results from POSIX.

# The Fix
_N_ number of characters are tested, where _N_ is the length of the current EOL string.
This would help the IDE give better autocompletion suggestion. The changes are only tested with VS Code.
- Perf fix: bail on first line in a header comment not matching.
- added constants for comment-style and line-ending overrides.
tonyganchev and others added 30 commits November 13, 2025 10:10
With the current change, users get much more precise information about what is worng with their headers:
- when a pattern is used for the whole header, the error remains the same but the error markers span the header, not the codebase below (same as previous update).
- when multi-line config is used:
  - error is shown over the first line that does not match matching the line with regular expression. The pattern is added as part of the error message.
  - error is shown over the remainder of the line after the first mismatched character when string matching is used. The remaining expected characters are shown in the error message
  - error is shown over the end of the line if the line is shorter than expected.
  - error is shown at the end of the header if it is shorter than expected.
  - error is shown over any unexpected lines at the end of the header.
- Autofixes still reapply the whole header so it will wipe out any year history from the current header of the file.
- There is an ongoing deliberation tracked in #63 whether the first comment should always be configured a header. This may affect the error-reporting behavior modified in this change or it may only affect the autofix. Bottom line: there will be further changes.

fixes #58, #59
…n permissions (#104)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…n permissions (#105)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
cleared a number of security-related overrides that are no longer necessary.
* docs,devops: smoke tests for ESLint 8

- E2E tests for ESLint 8, 9, and 10 to verify the plugin works end-to-end.
- ESLint 8 test uses legacy hierarchical config.
- updated plugin minimum ESLint version requirement.

* docs: fixed md lint errors

* Potential fix for code scanning alert no. 5: Shell command built from environment values

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Revert "Potential fix for code scanning alert no. 5: Shell command built from environment values"

This reverts commit 4a6f1b3.

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* docs,devops: smoke tests for ESLint 8

- E2E tests for ESLint 8, 9, and 10 to verify the plugin works end-to-end.
- ESLint 8 test uses legacy hierarchical config.
- updated plugin minimum ESLint version requirement.

* docs: fixed md lint errors

* Potential fix for code scanning alert no. 5: Shell command built from environment values

* Revert "Potential fix for code scanning alert no. 5: Shell command built from environment values"

This reverts commit 4a6f1b3.

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* docs: Modifying documentation to the new config format.

- _README.md_ - new configuration format.
- _legacy-config.md_ - legacy configuration format.
- _migrate-md_ - migrate from the legacy to the new configuration  format.

* devops: remove unnecessary eslint-env comment

* feat: support passing RegExp objects

Only relevant when using flat config.

Allows users to specify patterns using `/regexp-syntax/` and not a string with double-escaped backslashes.

* docs: reflect RegExp capabilities annd other improvements

* docs: fix lint errors
Bumps the npm_and_yarn group with 1 update in the / directory: [lodash](https://github.com/lodash/lodash).


Updates `lodash` from 4.17.21 to 4.17.23
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash
  dependency-version: 4.17.23
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
* chore: consistent node imports

* fix: green tests broken by move to node: imports
Issue was that the version was taken from the unparsed package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: Key "rules": Key "header/header": should NOT have more than 0 items.

2 participants