Skip to content

feat(linters): Add bloc linter - #945

Open
eduardomcv wants to merge 4 commits into
mfussenegger:masterfrom
eduardomcv:feat/add-bloc-linter
Open

eduardomcv wants to merge 4 commits into
mfussenegger:masterfrom
eduardomcv:feat/add-bloc-linter

Conversation

@eduardomcv

Copy link
Copy Markdown

Add support for the bloc linter.

Bloc is a Dart state management library which provides its own linting tool. To support this, I'm using the CLI tool and parsing the output to generate diagnostics. I also tested this configuration on my own Flutter projects.

Comment thread lua/lint/linters/bloc.lua
local linter_name = "bloc"

-- See https://bloclibrary.dev/lint/
local pattern = "(%w+)%[([%w_]+)%]:%s*(.-)\n%s*%-%->%s*.-:(%d+)\n%s*|\n%s*|.-\n%s*| (%s*)(%^+)"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Given the linter is already using a pattern, can't it use the from_pattern function to generate the parse function?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It could, but I think the code would become more confusing.

AFAIK from_pattern reads line by line, but the bloc output is multi-line. The relevant info is scattered across those lines. What the pattern does is it matches the whole chunk of lines we need. Then the custom function parses that chunk into something nvim-lint can use.

If I were to use from_pattern, I would need to split the current pattern into smaller patterns that match each individual line. I would also need to write a custom function anyway. That function would need to know which line it is at, in order to apply the correct pattern, and have some external variable to hold all the pending values.

In any case, let me know if you want me to make the change.

@eduardomcv
eduardomcv force-pushed the feat/add-bloc-linter branch from de521b2 to 6da6c9d Compare October 9, 2026 14:57
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.

2 participants