Skip to content

Read .emailensrc, with per-rule severity - #7

Merged
Ouranos27 merged 1 commit into
mainfrom
rule-severity
Aug 23, 2026
Merged

Ouranos27 merged 1 commit into
mainfrom
rule-severity

Conversation

@Ouranos27

Copy link
Copy Markdown
Member

The other half of emailens/vscode#10.

The VS Code extension has read .emailensrc 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.

{
  "skip": ["spam"],
  "rules": {
    "border-radius": "error",
    "insecure-link": "off"
  }
}

rules uses the code lint already prints, so there is no new vocabulary. Promoting one to error makes 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

  • Precedence is deliberately the opposite of the editor's. A command-line flag wins over the file here, because it is an explicit choice for one invocation. In the editor the repo's file wins over personal settings, because those are ambient and the file is the team's.
  • Invalid severities go to stderr. Named and ignored rather than silently dropped: a rule someone believes is off but is not is worse than no setting at all. stderr specifically, so lint --json | jq stays parseable — there is a test asserting stdout parses and stderr is empty under --json.
  • A malformed config is linted without, not fatal.
  • clients in the file is not read here yet. lint has 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 .emailensrc that was previously inert now changes what lint reports and what it exits with.


Generated by Claude Code

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.
@Ouranos27
Ouranos27 merged commit 984098c into main Aug 23, 2026
1 check passed
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.

1 participant