Read .emailensrc, with per-rule severity - #7
Merged
Merged
Conversation
The VS Code extension has read this file since it shipped; the CLI has not, so a rule demoted in the editor still failed the build. That is the worst of both: the Problems panel says it does not matter and CI says it does, and the person who set it has no way to tell which is lying. `lint` now reads `skip` and `rules` from `.emailensrc`, or from an `emailens` key in `package.json`, walking up from the working directory because lint is usually run from the repo root and the emails are not. `rules` sets a severity per rule — the code `lint` already prints, so no new vocabulary — and `off` drops it. Promoting one to `error` makes it exit 1, which is the point: the only control before was `--skip`, so a team that cared about one Outlook property had to keep the entire compatibility check at warning level. A severity that is not one of the four is named on stderr and ignored, because a rule someone believes is off but is not is worse than no setting at all. Those complaints go to stderr specifically so that `lint --json | jq` stays parseable, and there is a test for that. A malformed file is linted without rather than being fatal. Flags win over the file here; in the editor the file wins over settings. A flag is an explicit choice for one invocation, an editor setting is ambient, and the repo's file is the team's. 59 tests: the unit half on parsing and precedence, the end-to-end half running the real binary and asserting on the exit code, because that is what a pipeline branches on. Four fail if the severities stop applying.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The other half of emailens/vscode#10.
The VS Code extension has read
.emailensrcsince it shipped. The CLI has not — so a rule demoted in the editor still failed the build. That is the worst of both: the Problems panel says it does not matter and CI says it does, and the person who set it has no way to tell which is lying.lintnow readsskipandrulesfrom.emailensrc, or from anemailenskey inpackage.json, walking up from the working directory because lint is usually run from the repo root and the emails are not.{ "skip": ["spam"], "rules": { "border-radius": "error", "insecure-link": "off" } }rulesuses the codelintalready prints, so there is no new vocabulary. Promoting one toerrormakes it exit 1, which is the point of the feature — the only control before was--skip, so a team that cared about one Outlook property had to keep the entire compatibility check at warning level.Details worth reviewing
lint --json | jqstays parseable — there is a test asserting stdout parses and stderr is empty under--json.clientsin the file is not read here yet.linthas no client filter, so there is nothing to apply it to. Called out in the README and the changelog rather than silently ignored.Tests
59 total, 22 new. The unit half covers parsing, precedence and the upward search; the end-to-end half runs the real binary in a temp project and asserts on the exit code, because that is what a pipeline branches on. Four fail if the severities stop being applied.
Typecheck clean, build clean. Shipping as 0.5.0 — additive, but a
.emailensrcthat was previously inert now changes whatlintreports and what it exits with.Generated by Claude Code