dart_custom_lint icon indicating copy to clipboard operation
dart_custom_lint copied to clipboard

Add out of the box support for YamlLint and YamlFix

Open guenth39 opened this issue 1 year ago • 11 comments

Is your feature request related to a problem? Please describe. For me, it's quite difficult at the moment to write custom lints for yaml files. To write a lint is possible, but I can't make the fixes work. It would be nice if the package could offer a simple solution for that, like with DartLint and DartFix.

Describe the solution you'd like Add corresponding YamlLint and YamlFix class.

Describe alternatives you've considered Add a guide on how to write linter rules for files others than dart.

guenth39 avatar Aug 08 '24 13:08 guenth39

It is low priority for me. But sure

rrousselGit avatar Aug 08 '24 17:08 rrousselGit

cc @Rexios80

If you're following to work on this, I'm open to guiding you on it :)

rrousselGit avatar Sep 13 '24 18:09 rrousselGit

Do you have any thoughts on this?

Linting yaml files kind of works, but the plugin doesn't get notified about updates to yaml files. I tried adding *.yaml to the interestingFiles field here, but that somehow broke yaml file linting completely.

https://github.com/invertase/dart_custom_lint/blob/b50bd2b0f2125be2956a44113c60cacd42767c41/packages/custom_lint/lib/src/v2/custom_lint_analyzer_plugin.dart#L330

Ideally we pass in the globs from LintRule.filesToAnalyze, but I was just trying to get a proof of concept working.

Rexios80 avatar Sep 13 '24 18:09 Rexios80

Analyzer_plugin is likely the issue here. I'd suggest raising an issue on the dart sdk for that. There's likely already one

rrousselGit avatar Sep 13 '24 19:09 rrousselGit

Actually it looks like custom_lint isn't working as a path dependency. It doesn't seem to work in the dart_custom_lint project at all either, so it's not just my project. Do you have any ideas how to fix that?

Rexios80 avatar Sep 14 '24 22:09 Rexios80

You need to edit the tools/analyzer_plugin/pubspec.yaml https://github.com/invertase/dart_custom_lint/blob/90365e2c47526587603f9132cf89eb7d352ee057/packages/custom_lint/tools/analyzer_plugin/pubspec.yaml#L14

rrousselGit avatar Sep 14 '24 22:09 rrousselGit

You may have to clear your pub cache after editing the pubspec too. Or your change may not get picked up.

Analyzer_plugins are ... let's say ... not exactly easy to use.

rrousselGit avatar Sep 14 '24 22:09 rrousselGit

Is that in the documentation somewhere? I looked but couldn't find it. Maybe we should add this to a CONTRIBUTING.md file?

Rexios80 avatar Sep 14 '24 22:09 Rexios80

There's a TODO in the pubspec, but a CONTRIBUTING.md could be good too.

rrousselGit avatar Sep 14 '24 22:09 rrousselGit

I think I got it kind of working by symlinking my fork of custom_lint into the pub cache, but I still can't get yaml lints to update in real time. I don't have the bandwidth to diagnose this at the moment, so I'm giving up for now.

Rexios80 avatar Sep 15 '24 19:09 Rexios80

As I mentioned, the update issue is likely not from custom_lint

rrousselGit avatar Sep 15 '24 20:09 rrousselGit