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.
Added comment type as a part of the name.
Fringe case: empty command-line script with no trailing end-line.
* test: achieve and enforce 100% code coverage

- invalid tests cases where fix is not possible.
- invalid test case for empty settings object.
- remove redundant branch for missing header.
- remove fallback for missing options - validated by eslint.
- additional test cases to capture current (quirky) behavior.
- additional code improvements.

* fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! fixup! fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! fixup! fixup! fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! fixup! fixup! fixup! fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! fixup! fixup! fixup! fixup! fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! test: achieve and enforce 100% code coverage

* fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! test: achieve and enforce 100% code coverage
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