ember-template-lint / ember-template-lint

Linter for Ember or Handlebars templates
MIT License
267 stars 235 forks source link

Should not fail when no hbs files match #2542

Open simonihmig opened 2 years ago

simonihmig commented 2 years ago

Currently template-lint will exit with a non-zero code, when no hbs files match (for the given config). I believe it should not do that, instead it should maybe emit a warning message, but at least not fail. Similiar to e.g. ESLint, which also does not fail when there are no js files to lint.

This is an issue currently for freshly generated v2 addons, using the WIP blueprint. Just as the existing v1 addon blueprint, the v2 one will not create any components by default. For such an empty v1 addon, this was not a problem as every v1 addon has the test/dummy app intertwingled, which happens (more an unrelated coincidence) to have a templates/application.hbs file. This is why a new v1 addon does not fail the linting.

But for v2 addons, the addon and the test-app are more strictly separated, so the addon does not have any templates by default, and as such a new v2 addon will fail CI by default, only because of template-lint not finding any templates.

Not having ember-template-lint set up by default would be bad IMHO, as you might for example start with an addon that has just say a helper (i.e. no templates), but then later you add a component. When you do that, it should just start linting it. Having template-lint not set up by default would likely lead to users forgetting to add it later, when it is actually needed/useful...

Related: https://github.com/embroider-build/addon-blueprint/issues/18

bmish commented 2 years ago

The goal is to match ESLint behavior so this sounds like an important fix to make.

bertdeblock commented 2 years ago

I could be mistaken / misunderstanding, but ESLint also errors when no files are found matching the provided pattern. That's why both ESLint and ember-template-lint support the --no-error-on-unmatched-pattern flag I think?