Skip to content

Allow ignoring lints - #104

Open
saecki wants to merge 7 commits into
mainfrom
lint-categories
Open

saecki wants to merge 7 commits into
mainfrom
lint-categories

Conversation

@saecki

@saecki saecki commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Implements #55, #95

This categorizes all lint codes into three categories:

  • user ignorable
  • staff ignorable
  • not ignorable

Ignorable hints can be silenced in the typst.toml manifest using three different types of selectors, depending on the scope of the lint. There are:

  • project level lints: these can only be disabled for the whole project
  • file level lints: these can be disabled for specific files, using globs
  • text level lints: these can be disabled for specific names/strings using a list of regexes

Here is an example of the three lint types:

[tool.package-check.ignored-lints]
"manifest/package/description/typst" = true
"size/large".files = ["examples/*"]
"readme/image/inadequate-alt".alt-text = ["Repo", "License"]
  • Currently the staff-ignorable lints aren't treated differently from user ignorable ones. The only staff-ignorable lints are the size/bundle and size/archive lints. The plan is to make the github action read package size exceptions from a database that can only be edited by the staff. This way we can't miss any packages ignoring the lints during review.
  • There are warnings for ignored lint selectors that didn't match any diagnostics.

TODO/To decide

  • If any lint is ignorable lint is emitted, we should mention that it can be ignored and link to the docs.
  • Decide on the size limits: They are currently 15MB for the bundle, and double that for the whole archive.
  • Regexes are currently not anchored. Should we always anchor them, or only plain text ones?
  • Add a CLI flag to print ignored lints
  • Packages that target bundle/html export might emit compile errors/warnings: Should they be ignorable in all cases?
  • Decide what to do with the readme markdown extension lints. Either add support on Typst Unviverse and remove them or make them ignorable.
  • The docs should be updated
    • A section explaining how to ignore lints.
    • Document the size limits for packages and add it to Docs.
    • Add docs for relative imports to the package entrypoint.
    • Improve docs for links to default branch.
    • Document that we require alternative descriptions for readme images.

@laurmaedje laurmaedje left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! A few remarks:

I find that "readme/image/inadequate-alt".alt-text = ["Repo", "License"] does not really tell me what it does by itself. Together with the table heading ignored-lints, it does sort of, but it's not very clear when viewed locally.

I tried to come up with something clearer, but did not manage to find a spelling that's clearly better. I do have a few ideas (some of which you probably already considered and decided against).

First of all, I think one small improvement would be to have a consistent naming for each kind of filter, e.g. always matches instead of alt-text, urls, and names. The alt-text part in particular was confusing to me because it does not tell me what it does. inadequate-alt".alt-text = ["Repo"] reads to me as if the alt text "Repo" is inadequate, even though we are stating the opposite with this rule!

I also find the string followed by dot key a bit hard to read and unpretty. Personally, I would probably demonstrate the slightly more verbose spelling with an inline dictionary.

Combined, it would then be something like this

[tool.package-check.ignored-lints]
"manifest/package/description/typst" = true
"size/large" = { files = "examples/*" }
"readme/image/inadequate-alt" = { matches = "Repo|License" }

For the name ignored-lints, I would also throw allow, lints.allow and lints.ignored into the ring as alternatives, though I'm unsure if any of these is actually better. Maybe it's just my perpetual dislike of multi-word identifiers.

[tool.package-check.lints.allow]
...

To make file and match rules a bit more locally understandable and have just lints as the top-level (which I find a bit nicer conceptually), we could also go with something like this:

[tool.package-check.lints]
"manifest/package/description/typst" = "allow"
"size/large" = { allow-files = "examples/*" }
"readme/image/inadequate-alt" = { allow-matches = "Repo|License" }

The "allow" part is a bit redundant now, but it does imo read a bit better locally. Again, not sure...


They are currently 15MB for the bundle, and double that for the whole archive.

What do you mean with "bundle" and "archive" in this context?

Regexes are currently not anchored. Should we always anchor them, or only plain text ones?

I think I'd expect the regex to have to match the full alt-text / name / URL.

@saecki

saecki commented Nov 18, 2026

Copy link
Copy Markdown
Member Author
[tool.package-check.lints]
"manifest/package/description/typst" = "allow"
"size/large" = { allow-files = "examples/*" }
"readme/image/inadequate-alt" = { allow-matches = "Repo|License" }

I think I like this the most. This morning I've added the --show-ignored flag. Would you also rename that. Somehow --show-allowed and --- allowed diagnostics --- doesn't sound right to me 🤔

What do you mean with "bundle" and "archive" in this context?

The bundle would be the files served when importing the package, so without the excluded files. The archive would be all submitted files. There are hints on the size/bundle and size/archive diagnostics that explain this, and I would also explain this in the package docs.

@laurmaedje

Copy link
Copy Markdown
Member

I think I like this the most.

Me too 👍

This morning I've added the --show-ignored flag. Would you also rename that. Somehow --show-allowed and --- allowed diagnostics --- doesn't sound right to me 🤔

What would it be used for? I could imagine something like --filter denied|all and then putting the "allowed" on each individual diagnostic, e.g. in parenthesis after the message. Or just --all since it's just two states.

The bundle would be the files served when importing the package, so without the excluded files. The archive would be all submitted files.

The sizes seem okay to me then.

@saecki

saecki commented Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

What would it be used for? I could imagine something like --filter denied|all and then putting the "allowed" on each individual diagnostic, e.g. in parenthesis after the message. Or just --all since it's just two states.

It isn't immediately obvious to me what --filter denied would do.
How about --filter all|suppressed? With suppressed being the diagnostics that were allowed by the lint configuration and thus not emitted by default.

Currently the diagnostics are printed as two separate lists separated by headers like this:

--- ignored diagnostics ---
--- regular diagnostics ---

I'm also not a huge fan of the names, but I think this is more readable than having to scan for an allowed tag next to every diagnostic.

@laurmaedje

Copy link
Copy Markdown
Member

The idea was that filter is positive, i.e. what remains: Filtering for "denied" shows only the checks that were denied, i.e. not allowed (the default). Filtering for "all" would show all. For --filter supressed, my interpretation along these lines would be that it's the same as --filter allowed, i.e. show only the allowed lints.

Maybe neither is particularly clear. 😅

@saecki
saecki force-pushed the lint-categories branch 5 times, most recently from 118050c to a7bae96 Compare November 19, 2026 11:20
@saecki
saecki added this pull request to stack #107 November 19, 2026 11:32
@saecki

saecki commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Test @typst/package-review

- This introduces our own `Diagnostic` type that requires a `Code` enum
- The TOML parsing code is quite heavily refactored
- More links to the `typst/packages` docs are added
- Parse `tools.package-check.ignored-lints`
- Filter diagnostics by code
- Warn if `lints` selectors are unused
- Remove `size/extra-large` hint and add `size/bundle`, `size/archive`
- Split off toml module from manifest
…s to `check` command

- Improve the CLI output
- Share printing code between test runner and CLI
- Make the `--json` flag write a JSON object per package
- Document the structure of the JSON output
@saecki
saecki force-pushed the lint-categories branch 2 times, most recently from a591d4a to 9202b32 Compare November 24, 2026 21:07
@saecki
saecki removed this pull request from stack #107 November 25, 2026 10:50
@saecki
saecki added this pull request to stack #110 November 25, 2026 10:50
@saecki
saecki removed this pull request from stack #110 November 25, 2026 10:53
@saecki
saecki added this pull request to stack #112 November 25, 2026 10:54
@saecki
saecki marked this pull request as ready for review November 26, 2026 09:50
@saecki saecki linked an issue Nov 27, 2026 that may be closed by this pull request
- Add an `[overridable]` tag to all overridable diagnostis.
- If overridable diagnostics were denied, add a link to the
  package-check docs
- Add a `lints` subcommand that list all overridable lints
- Update the check run message
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.

Impose a size limit and maximum number of files for the full package Also impose a size limit for Wasm files Opt out mechanism for diagnostics

2 participants