-
-
Notifications
You must be signed in to change notification settings - Fork 154
feat: implement info
severity level
#1610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for a new "info" severity level across the codebase, ensuring that all formatters and tests correctly handle this additional level. Key changes include updating severity level definitions, enhancing formatter outputs to differentiate "info" from other severities, and adding comprehensive test coverage to validate the new behavior.
Reviewed Changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
packages/textlint/src/shared/type/SeverityLevel.ts | Updates the severity level mapping to distinguish info from none, warning, and error |
packages/@textlint/types/src/Rule/TextlintRuleSeverityLevel.ts | Revises type definitions to support info as a distinct severity |
Various formatter source and test files | Modify message type calculations and summary constructions to handle "info" severity consistently |
packages/@textlint/kernel/src/shared/rule-severity.ts and related | Updates error messages and doc details to include the new "info" severity |
Comments suppressed due to low confidence (1)
packages/@textlint/kernel/src/messages/filter-severity-process.ts:8
- Consider adding tests to verify that info severity messages are correctly filtered out when the --quiet flag is enabled, ensuring that only error messages (severity 2) are displayed in quiet mode.
* Filter messages by their severity.
@@ -101,19 +111,19 @@ function formatter(results: TextlintResult[], options: FormatterOptions) { | |||
}); | |||
|
|||
if (total > 0) { | |||
const problemParts = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for building the summary string for problem counts is duplicated across multiple formatter files. Consider extracting this common logic into a shared utility function to improve maintainability.
Copilot uses AI. Check for mistakes.
The test was expecting '1 warning' but should expect '1 info' when severity is 3. This aligns with the actual formatter output that correctly displays info messages.
- Replace TextlintRuleSeverityLevelKeys with numeric values (1: warning, 2: error, 3: info) - Remove dependency on @textlint/kernel from formatter packages to maintain clean architecture - Update all 10 formatters: stylish, compact, unix, table, checkstyle, junit, tap, pretty-error, fixer-formatter - All tests continue to pass with numeric severity level checks
- Add detailed explanation of severity levels (1: warning, 2: error, 3: info) - Update examples to include severity property - Remove outdated reference to SeverityLevel.js file - Add practical examples showing info level usage
|
- Add tests for filterWarningMessages function to ensure it filters out info messages (severity 3) and warning messages (severity 1) - Add tests for through function to verify it passes all messages unchanged - Add tests for createSeverityFilter to verify --quiet flag behavior - Ensure info messages are properly filtered when using --quiet mode - Tests validate that only error messages (severity 2) are shown in quiet mode
info
severity level
- Fix test case to expect '1 Info' instead of '1 Warning' for info severity (3) - Update warningCount from 1 to 0 in test data to match actual behavior - Info messages should be counted separately from warnings and errors - Table formatter correctly displays info messages with their own category
- Implement tests for the pretty-error formatter to validate error output formatting. - Add tests for the stylish formatter to ensure correct handling of messages and severity levels. - Create tests for the table formatter to verify the output structure for different message scenarios. - Introduce tests for the tap formatter to check the output format for single and multiple messages. - Develop tests for the unix formatter to confirm the correct formatting of error messages across multiple files.
… formatter functionality
type none = 0; | ||
type info = 0; | ||
type warning = 1; | ||
type error = 2; | ||
export type TextlintRuleSeverityLevel = none | info | warning | error; | ||
type info = 3; | ||
export type TextlintRuleSeverityLevel = none | warning | error | info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main change
Summary
This PR implements proper support for the
info
severity level across all formatters and adds comprehensive test coverage, resolving the confusion betweennone
andinfo
severity levels.Fixes #1608
Changes Made
1. Updated Severity Level Definitions
TextlintRuleSeverityLevelKeys.ts
: Changedinfo
from value0
to3
to make it distinct fromnone
TextlintRuleSeverityLevel.ts
: Added proper type support for info levelSeverityLevel.ts
: Aligned CLI severity definitions2. Enhanced All Formatters
Updated all formatters to properly handle the three distinct severity levels:
Linter Formatters:
stylish.ts
: Added green "info" display with proper countingcompact.ts
: Added "Info" prefix for info messagesunix.ts
: Added "[Info/rule_id]" formattable.ts
: Added "info" type in table formatcheckstyle.ts
: Addedseverity="info"
in XML outputjunit.ts
: Added "Info" severity in test outputtap.ts
: Addedseverity: info
in YAML outputpretty-error.ts
: Added info level handling with proper countingFixer Formatter:
stylish.ts
: Added info level support for fix output3. Updated Core Logic
rule-severity.ts
: Updated error message to include "info" in severity optionsfilter-severity-process.ts
: Maintained--quiet
behavior to show only errors4. Comprehensive Test Coverage
Added test cases for info severity level across all formatters:
Behavior Changes
Before
After
Formatter Output Examples
Stylish:
Compact:
Table:
Backward Compatibility
severity: "info"
now works as expectedTesting
Benefits