dart_custom_lint
dart_custom_lint copied to clipboard
Add out of the box support for YamlLint and YamlFix
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.
It is low priority for me. But sure
cc @Rexios80
If you're following to work on this, I'm open to guiding you on it :)
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.
Analyzer_plugin is likely the issue here. I'd suggest raising an issue on the dart sdk for that. There's likely already one
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?
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
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.
Is that in the documentation somewhere? I looked but couldn't find it. Maybe we should add this to a CONTRIBUTING.md file?
There's a TODO in the pubspec, but a CONTRIBUTING.md could be good too.
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.
As I mentioned, the update issue is likely not from custom_lint