Setting HTML properties in a Gutenberg plugin using WordPress settings

I came to this question almost 3 years late, but there is a better way of doing that now: WordPress recommends using wp_add_inline_script when you want to pass data between PHP and JS, you can read about it here

Basically, what you will do, is changing your wp_localize_script function call in your code, for this:

wp_add_inline_script('my-script-name', 'const my_plugin_max_length=" . get_option( "my_plugin_maxlength' ), 'before'); 

And then you can use the variable my_plugin_max_length in your JS file.