Specify --no-highlight-code in Babel Require Hook options - babeljs

How to specify the --no-highlight-code option in Babel's Require Hook options object?
require('babel/register')({
'--no-highlight-code': true,
'no-highlight-code': true,
'noHighlightCode': true,
});
require('./script');
All of those give the error Unknown option: no-highlight-code
It's an option present Babel's command line usage, so I'm not even sure if I'm supposed to use it like that, although the example page lists blacklist and whitelist could be used ..
babel --help
Usage: index [options] <files ...>
Options:
-h, --help output usage information
-f, --filename [string] filename to use when reading from stdin - this will be used in source-maps, errors etc
--module-id [string] specify a custom name for module ids
--retain-lines retain line numbers - will result in really ugly code
--no-non-standard enable/disable support for JSX and Flow (on by default)
--experimental allow use of experimental transformers
--no-highlight-code enable/disable ANSI syntax highlighting of code frames (on by default)
-e, --stage [number] ECMAScript proposal stage version to allow [0-4]

The option to disable highlighting code is (by default) on, and the command line option has the (added) prefix "no".
require("babel/register")({ highlightCode: false }) is the way to disable highlighting code in parse time SyntaxErrors when passing an object to babel/register.
Passing { highlightCode: true } does nothing; the default is true.

Related

python-language-server config file location

I'm trying to use flake8 as the default python linter using python-language-server on neovim v0.5.
python-lsp documentation says to set pylsp.configurationSources to ['flake8'], but doesn't specify which file to edit.
Where does the python-lsp-server config file reside?
According to flake8 documentation, the location of flake8 config varies based on systems, on Linux and Mac, it is ~/.config/flake8, and for Windows, it is $HOME\.flake8 ($HOME is like C:\\Users\sigmavirus24). The content should be in INI format:
[flake8]
max-line-length = 100
max-complexity = 30
ignore =
# missing whitespace around arithmetic operator
E226,
# line break before/after binary operator
W503,
W504,
# expected 1 blank line, found 0
E301,E302,
To suppress a single warning, it is also handy to add # noqa: F841-like (change the code to the actual code you want to use) comment string to suppress it.
Ref: https://jdhao.github.io/2020/11/05/pyls_flake8_setup/#config-location

How do I set basic options with meson?

I'm trying to configure a project with meson. Specifically, I'm trying to set some of the options.
meson config tells me, among other things:
Core options:
Option Current Value Possible Values Description
------ ------------- --------------- -----------
buildtype debug [plain, debug, debugoptimized, release, minsize, custom] Build type to use
Base options:
Option Current Value Possible Values Description
------ ------------- --------------- -----------
b_lto false [true, false] Use link time optimization
(other options were clipped from this printout of course.)
So, I write:
meson build . --buildtype=release
in my build directory, and this goes fine - no warnings or errors (I double-checked that the option value had changed). Then I write:
meson build . --b_lto=true
but this gets me:
meson: error: unrecognized arguments: --b_lto=true
I also tried -b_lto=true, --b_lto true, b_lto=true and b_lto true. And all of those without the true value. No luck.
How do I set these "base options" then?
The --option=value, and --option value styles to pass arguments only applies to the universial options section in meson's manual...so not to base options, and others. Instead use the -Doption=value syntax to set options. It is the suggested way, since meson setup --help declares [-D option] to be used for setting all sorts of options. See this answer by the meson team. So, in your case run:
meson build . -Db_lto=true
but, better use this ordering, since its specified this way in the manual (man meson).
meson -Db_lto=true build .
or
meson configure build -Db_lto=true
If the build directory changed since the last configure use reconfigure instead.
meson reconfigure build -Db_lto=true
or explicitly:
meson setup --reconfigure -Db_lto=true build

Disable critic for an entire file - Parse::RecDescent precompiled parser & PerlCritic/Tidyall

I'm trying to remove an error from my sanity-checking [when I push code to my git repo, there's a hook that checks the code with perltidy & critic... using tidyall as the handler.]
The specific issue I have is with a pre-compiled Grammar Parser.... and this is not something I want to dive in & fix (sorry - that's outside my comfort zone)
If I add a simple ## no critic to the start of the file, then
perlcritic path/to/class/file.pm
comes back
path/to/class/file.pm source OK
however
tidyall --check-only -r .
comes back with
perlcritic /tmp/Code-TidyAll-Frb0/path/to/class/file.pm failed
exited with 2 - output was:
Unrestricted '## no critic' annotation at line 6, column 1. (Miscellanea::ProhibitUnrestrictedNoCritic, severity 3)
I know I can fix this in the tidyall.ini file:
[PerlCritic lib]
select = **/*.{pm}
ignore = **/class/file.pm
.... however I feel there should be a cleaner solution.
(or, why doesn't tidyall critique the same as critic?)
why doesn't tidyall critique the same as critic?
A simple perlcritic on the command line defaults to severity 5, unless you've configured something different in your ~/.perlcriticrc. The rule ProhibitUnrestrictedNoCritic defaults to severity 3, so your tidyall is running Perl::Critic with at least severity 3. As per its documentation, you can change that via something like this in the tidyall.ini:
[PerlCritic]
argv = -severity 4
And then tidyall's checks should be the same as a perlcritic -4 from the command line. (Unless you've configured custom severity levels in your .perlcriticrc.)
Update: As per your comment, you want to check everything at the "brutal" level. In that case, you can create a perlcriticrc file containing the line [-Miscellanea::ProhibitUnrestrictedNoCritic] which will disable that policy, and then point perlcritic at that file by adding the command-line argument --profile /path/to/custom/perlcriticrc.

Algebra filter error in moodle

I installed moodle 1.9.12 and now I want to use Algebra notation in content. I enable "TeX Notation" and "Algebra Notation" in administrator panel and also install mimetext and dvips and Imagemagic on the server. fortunately Tex Notation works fine but I got the following error for Algebra:
sh: /var/www/html/moodle/filter/tex/mimetex.linux: not found
The shell command
"/var/www/html/moodle/filter/tex/mimetex.linux" -e "/var/www/moodledata/filter/algebra/de06d6c44d98ba4e42dffca988bf530b.gif" -- '\Large \frac{\sin\left(z\right)}{x^{2}+y^{2}}'
returned status = 127
File size of mimetex executable /var/www/html/moodle/filter/tex/mimetex.linux is 830675
The file permissions are: 100775
The md5 checksum of the file is 56bcc40de905ce92ebd7b083c76e019e
Image not found!
Note: /var/www/html/moodle/filter/tex/mimetex.linux exists on the server and is executable!!!
What is the problem?? Any idea?????
From what you have described, calling the general tex filter debug page works and does not show up the same error.
/filter/tex/texdebug.php works, but /filter/algebra/algebradebug.php does not.
If this is the case, perhaps you could check for an open_basedir, or safe_mode_exec_dir being set to include the current working directory, or otherwise restricting the execution of /var/www/html/moodle/filter/tex/mimetex.linux, while the current working directory is /var/www/html/moodle/filter/algebra.
You could look at this by visiting /admin/phpinfo.php at your site, and look carefully at the effective values of open_basedir, safe_mode and safe_mode_exec_dir.
You could also check the apache error log or add the following lines to the top of the algebra debug php file, and you might see some extra error messages:
$CFG->debug = 6143 ;
$CFG->debugdisplay= 1 ;
Hope that helps

Erlang: How to access CLI flags (arguments) as application environment variables?

How does one access command line flag (arguments) as environment variables in Erlang. (As flags, not ARGV) For example:
RabbitMQ cli looks something like:
erl \
...
-sasl errlog_type error \
-sasl sasl_error_logger '{file,"'${RABBITMQ_SASL_LOGS}'"}' \
... # more stuff here
If one looks at sasl.erl you see the line:
get_sasl_error_logger() ->
case application:get_env(sasl, sasl_error_logger) of
% ... etc
By some unknown magic the sasl_error_logger variable becomes an erlang tuple! I've tried replicating this in my own erlang application, but I seem to be only able to access these values via init:get_argument, which returns the value as a string.
How does one pass in values via the commandline and be able to access them easily as erlang terms?
UPDATE Also for anyone looking, to use environment variables in the 'regular' way use os:getenv("THE_VAR")
Make sure you set up an application configuration file
{application, fred,
[{description, "Your application"},
{vsn, "1.0"},
{modules, []},
{registered,[]},
{applications, [kernel,stdlib]},
{env, [
{param, 'fred'}
]
...
and then you can set your command line up like this:
-fred param 'billy'
I think you need to have the parameter in your application configuration to do this - I've never done it any other way...
Some more info (easier than putting it in a comment)
Given this
{emxconfig, {ets, [{keypos, 2}]}},
I can certainly do this:
{ok, {StorageType, Config}} = application:get_env(emxconfig),
but (and this may be important) my application is started at this time (may actually just need to be loaded and not actually started from looking at the application_controller code).