The discussion revolves around troubleshooting issues with ESLint. pfaffman is experiencing lint test failures due to an invalid --ext option, despite not using it in their source tree. Alteras shares a similar experience and suggests that the issue may be caused by updating the ESLint config file to the latest flat config format eslint.config.js, which doesn’t support the --ext option.
Alteras recommends reverting to the older .eslintrc.cjs format and provides a link to setup instructions for lint files. pfaffman is puzzled as they don’t have an eslint.config.js file in their source tree.
Alteras suggests checking the package.json file for an ESLint version mismatch. pfaffman discovers that ESLint and Prettier were updated in package.json, which may be the cause of the issue.
merefield offers a solution by running yarn and yarn eslint --fix from the discourse directory. pfaffman successfully resolves the issue using this method and creates a script to automate the process. However, pfaffman seeks clarification on whether running yarn eslint --fix updates ESLint to the correct version or simply runs ESLint with the correct version.
Run if test -f .prettierrc.cjs; then
yarn run v1.22.22
$ /home/runner/work/discourse-multi-rating/discourse-multi-rating/node_modules/.bin/eslint --ext .js,.gjs,.js.es6 --no-error-on-unmatched-pattern test/javascripts assets/javascripts admin/assets/javascripts
Invalid option '--ext' - perhaps you meant '-c'?
You're using eslint.config.js, some command line flags are no longer available. Please see https://eslint.org/docs/latest/use/command-line-interface for details.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 2.
I don’t see --ext in my source tree, so maybe it’s in @discourse/lint-configs/eslint")? I don’t know where to find that.
I can’t see what I’m doing wrong or how this isn’t affecting a whole bunch of plugins.
I’ve seen this error on my own plugin. I figured out it was because I tried to update the eslint config file from .eslintrc.cjs to the latest flat config format eslint.config.js via the eslint migration. eslint.config.js doesn’t support the --ext (Command Line Interface Reference - ESLint - Pluggable JavaScript Linter), so changing the file to the older .eslintrc.cjs should fix it.
OMG. I’d just managed to fix it in some way that was completely impossible to reproduce, so this is a lifesaver. And now I’ve added it to my magic file so this might work next time
if [[ "$ARG" == 'fix-eslint' ]]
then
cd ~/src/discourse-repos/discourse
yarn
for x in ~/plugins/*
do
yarn eslint --fix x
done
fi