What I do is blindly copy the workflows from GitHub - discourse/discourse-plugin-skeleton: Template for Discourse plugins and GitHub - discourse/discourse-theme-skeleton: Template for Discourse themes. (I do have to tweak the plugin one a bit for my dashboard plugin, which depends on the stripe plugin). This, I’m willling to believe, is good enough to do the linting.
What I want, though, is for vscode to do the linting before I do the commit. I’ve had it working in the past, but it’s stopped and I feel like someone who knows about VScode that I knew about Emacs 20 years ago, could say some stuff like “type control-p, now do the thing to install the formatting thingy, now edit the config file so that it does the Right Thing” and then I could once again, type control-S and have my handlebars, javascript, and whatever else formatted pretty, and also find all the pesky variables that I defined but never used and on like that.
Getting closer
OK, but I did this:
npm install --global yarn
yarn add prettier
And now I have discourse-prettier
:
#!/usr/bin/env bash
if [ -n "$(find assets -type f \( -name "*.scss" -or -name "*.js" -or -name "*.es6" -or -name "*.hbs" \) 2>/dev/null)" ]; then
yarn prettier --write "assets/**/*.{scss,js,es6,hbs}"
fi
if [ -n "$(find admin/assets -type f \( -name "*.scss" -or -name "*.js" -or -name "*.es6" -or -name "*.hbs" \) 2>/dev/null)" ]; then
yarn prettier --write "admin/assets/**/*.{scss,js,es6,hbs}"
fi
if [ 0 -lt $(find test -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
yarn prettier --write "test/**/*.{js,es6}"
fi
if [ -n "$(find assets -type f \( -name "*.scss" -or -name "*.js" -or -name "*.es6" -or -name "*.hbs" \) 2>/dev/null)" ]; then
yarn prettier --list-different "assets/**/*.{scss,js,es6,hbs}"
fi
if [ -n "$(find admin/assets -type f \( -name "*.scss" -or -name "*.js" -or -name "*.es6" -or -name "*.hbs" \) 2>/dev/null)" ]; then
yarn prettier --list-different "admin/assets/**/*.{scss,js,es6,hbs}"
fi
if [ 0 -lt $(find test -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
yarn prettier --list-different "test/**/*.{js,es6}"
fi
That’s solved part of my problem, so at least I can get prettier
to run from the command line. But I’m still willing to pay for help to get vscode to do my dirtywork. When I save, it should run eslint (or rubop or whatever) and either fix it or tell me that it can’t. I’m too old to think that my editor should write my code, but not so old that I think it shouldn’t format it.
There used to be a topic where someone suggested which vscode plugins they were using, which helped me some, but I don’t see it now.