5.1, Grunt, TinyMCE plugins, documentation

5.1, Grunt, TinyMCE plugins, documentation

tim st.clair írta időpontban
Válaszok szám: 1
Kép Kép

I'm trying my hand at writing a simple TinyMCE plugin in Moodle 5.1

I've been following along on the https://moodledev.io/docs/5.1/apis/plugintypes/tiny documentation, which tells me in plugin.js to

export default new Promise(async(resolve) => {

Which then causes grunt to complain:

  32:28  error  Promise executor functions should not be async  no-async-promise-executor

After a bit of googling, it seems that I have to disable eslint for that line:

// eslint-disable-next-line no-async-promise-executor
export default new Promise(async(resolve) => {
 
Should the documentation be updated on the moodledev site to explain grunt errors?
Értékelések átlaga:Useful (1)
Válasz erre: tim st.clair

5.1, Grunt, TinyMCE plugins, documentation

A K M SAFAT SHAHIN írta időpontban
Kép Kép Kép
Hi,
Thank you for raising this. Seems like it's a very regular pattern in the core to add this line, some examples are here:
https://github.com/moodle/moodle/blob/main/public/lib/editor/tiny/plugins/premium/amd/src/plugin.js#L33
https://github.com/moodle/moodle/blob/main/public/lib/editor/tiny/plugins/aiplacement/amd/src/plugin.js#L34

We can consider adding this line in the code example for plugin.js so that it's clearer in the devdocs:
https://github.com/moodle/devdocs/blob/main/docs/apis/plugintypes/tiny/index.md
Feel free to push a patch for this improvement.

Cheers!