Update to bin/lint breaks linting flow for non-bundled plugins

A recent change on Discourse main branch (https://github.com/discourse/discourse/commit/e84d7c9f26ed) broke our way of linting the custom plugins we’re working on.

The PR/commit subject was

DEV: Update bin/lint to work correctly for non-bundled plugins

So I’m wondering if we’re doing something entirely wrong with our linting workflow (cc @david).

How I lint

The way I was using bin/lint was, to run it from Discourse root and point it to my plugin inside the plugin directory:

bin/lint --fix plugins/my-custom-plugin

That broken with the commit mentioned above. pnpm errors about being run in a plugin directory and then isn’t able to find the files any more. One example from the error output:

> pnpm was run inside a plugin directory. Re-executing with --ignore-workspace...
NoFilesFoundError: No files matching the pattern "plugins/zlb-community/assets/stylesheets/common/atoms/category-button.scss, plugins/zlb-community/assets/stylesheets/common/atoms/category-icon.scss, plugins/zlb-community/assets/stylesheets/common/atoms/icon-info.scss, plugins/zlb-community/assets/stylesheets/common/atoms/user-pill.scss, plugins/zlb-community/assets/stylesheets/common/base/grid.scss, plugins/zlb-community/assets/stylesheets/common/base/normalize.scss, plugins/zlb-community/assets/stylesheets/common/base/rich-text.scss, plugins/zlb-community/assets/stylesheets/common/base/stack.scss, plugins/zlb-community/assets/stylesheets/common/index.scss, plugins/zlb-community/assets/stylesheets/common/molecules/card.scss, plugins/zlb-community/assets/stylesheets/common/molecules/expander.scss, plugins/zlb-community/assets/stylesheets/common/molecules/header.scss, plugins/zlb-community/assets/stylesheets/common/molecules/user-pill-list.scss, plugins/zlb-community/assets/stylesheets/common/organisms/category-header.scss, plugins/zlb-community/assets/stylesheets/common/templates/lobby.scss, plugins/zlb-community/assets/stylesheets/community-sidebar.scss, plugins/zlb-community/assets/stylesheets/user_home.scss, plugins/zlb-community/assets/stylesheets/common/atoms/badge.scss" were found.
    at standalone (file:///Users/max/code/bitcrowd/zlb/discourse/plugins/zlb-community/node_modules/.pnpm/stylelint@17.5.0_typescript@5.9.3/node_modules/stylelint/lib/standalone.mjs:293:43)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

It worked perfectly fine before. How (unless I go back to the commit before the change…) I can only lint globally with bin/lint in root. But that obviously takes way longer.

Should this be done differently?

Thanks for the report @klappradla. This should fix it up:

Thanks!

I tried out the branch from your fix. It works only partially for me though, as it stops after template-lint and does not run any further checks.

I suspect it is running stylelint after ember-template-lint, but the output is empty so it’s not obvious. I just pushed a commit which adds some simple progress output, and a final summary.

I tried your updated branch, but I think the problem lies somewhere else. It’s now printing the summary, that’s nice and fine, but I think it does not look at the right files :joy:

If I compare it to 146fb61e104e, it just does not detect any linting violations I insert in .scss or .js files.

I tried adding violations in scss and js files in my testing, and it seemed to work. Could you try running bin/lint --verbose plugins/my-custom-plugin, and see if the files are listed correctly in the output?

Good point about verbose!

Yes, the file paths are ok and I can get it to report :tada:. However, it silently does nothing when I pass --fix. Did you change the API there?

Oh… :facepalm:

I pushed another commit. Would you mind trying one more time?

Nice! Works fine for me now :tada:

Sorry for the late response - was off for non-computer duties.

Great - thanks for your help! I’ve merged the PR :rocket: