JS | Babel | What means and does the mode "spec" and "force all transforms" - babeljs

What means and does the mode "spec" and "force all transforms"
I suppose "force all transforms" transforms a code to ES5. Is it so?
What about "spec"?
Here I have a react component as an example

Related

How to apply multiple auto fixes with nvim LSP

In nvim, using LSP, i want to be able to apply a 'fix all of the same type' similar to what can be done in VSCode (see picture). How would one go about adding this to LSP code actions?
Edit: I know this can be done using COC. But i want it for LSP.
It depends on the language server you are using, in my current NeoVim configuration I'm running both ESLint and tsserver and with a default configuration of ESLint in my root of my project, I get these types of code action.
Assuming you are using lspconfig plugin you need to make sure you have the server configured :
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
require('lspconfig')['tsserver'].setup {
on_attach = function() end,
capabilities = capabilities,
}
require('lspconfig')['eslint'].setup {
on_attach = function() end,
capabilities = capabilities,
}
You can then run in neovim : :lua vim.lsp.buf.code_action() in command mode (n)
You need both LSP installed manually
Ref :
https://github.com/neovim/nvim-lspconfig#quickstart
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#eslint
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#tsserver
N.B. You should probably add your keymap related to LSP in the on_attach callback

Bug on integrating Material UI hooks and Apollo hooks

When using Material UI hooks (as its example shown here) with NextJS and react-apollo-hooks, received bug -
TypeError: Cannot read property 'theme' of undefined
at MyDocument.render (/material-ui/examples/nextjs-hooks-with-typescript/.next/server/static/development/pages/_document.js:156:38)
Expected Behavior 🤔
Able to use Material UI hooks and Apollo hooks together.
Current Behavior 😯
undefined pageContext caused TypeError: Cannot read property 'theme' of undefined at line:
https://github.com/ivawzh/material-ui/blob/fc6ae01e66bde4252a08903719a59ef108e05e5f/examples/nextjs-hooks-with-typescript/pages/_document.tsx#L14
Steps to Reproduce 🕹
This codesandbox.io template _may_ be a good starting point:
https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/create-react-app
If you're using typescript a better starting point would be
https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/create-react-app-with-typescript
If YOU DO NOT take time to provide a codesandbox.io reproduction, should the COMMUNITY take time to help you?
-->
I have prepared a repo here https://github.com/ivawzh/material-ui/commit/fc6ae01e66bde4252a08903719a59ef108e05e5f
Steps:
git clone git#github.com:ivawzh/material-ui.git
cd material-ui/examples/nextjs-hooks-with-typescript
npm install && npm run dev
In web browser, open http://localhost:3000/countries2
See the error in your terminal
Context 🔦
I am trying to use Apollo hooks with Material UI hooks example.
From the repo above you will see the non-hook Apollo endpoint at http://localhost:3000/countries is working fine as expected. But when Apollo hooks is in used, app will crash because pageContext becomes undefined.
Environment 🌎
https://github.com/ivawzh/material-ui/tree/fc6ae01e66bde4252a08903719a59ef108e05e5f/examples/nextjs-hooks-with-typescript
| Tech | Version |
|--------------|---------|
| Material-UI | v3.8.1 |
| React | 16.7.0-alpha.2 |
| Browser | Chrome |
| TypeScript | 3.2.2 |
| react-apollo | 2.3.3 |
| react-apollo-hooks | 0.2.1 |
Related Git issues
https://github.com/mui-org/material-ui/issues/14140

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

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.

Question mark and exclamation point syntax in srpm spec file

I'm trying to understand how the Postgres 9.1 rpms are built on CentOS/RHEL 6, so I'm taking a look at the spec file from the source rpms.
What does the following syntax do/mean? Specifically, the question mark and exclamation point?
%{!?test:%define test 1}
%{!?plpython:%define plpython 1}
%{!?pltcl:%define pltcl 1}
%{!?plperl:%define plperl 1}
%{!?ssl:%define ssl 1}
%{!?intdatetimes:%define intdatetimes 1}
%{!?kerberos:%define kerberos 1}
%{!?nls:%define nls 1}
%{!?xml:%define xml 1}
%{!?pam:%define pam 1}
%{!?disablepgfts:%define disablepgfts 0}
%{!?runselftest:%define runselftest 0}
%{!?uuid:%define uuid 1}
%{!?ldap:%define ldap 1
I understand you can define a macro variable with %define <name>[(opts)] <value>, and I believe the exclamation mark is a logical negation operator. I can't find any info on the question mark or examples like the above though. Seems like some sort of test before defining the macro variable.
Here is a paste of the spec file.
Lets review a single item here:
%{!?plpython:%define plpython 1}
On line 102 we also see this:
%if %plpython
BuildRequires: python-devel
%endif
As you said, we know that this is a macro, that can also be confirmed via the Fedora docs. Now if we expand on our search into the Fedora documentation we find conditional macros. This states the following:
You can use a special syntax to test for the existence of macros. For example:
%{?macro_to_test: expression}
This syntax tells RPM to expand the expression if macro_to_test exists, otherwise ignore. A leading exclamation point, !, tests for the non-existence of a macro:
%{!?macro_to_test: expression}
In this example, if the macro_to_test macro does not exist, then expand the expression.
The Fedora docs have provided the answer, if the plpython macro doesn't exist, then
%define plython 1
If you look at line 38 you can also see this:
# In this file you can find the default build package list macros. These can be overridden by defining
# on the rpm command line:
# rpm --define 'packagename 1' .... to force the package to build.
# rpm --define 'packagename 0' .... to force the package NOT to build.
# The base package, the lib package, the devel package, and the server package always get built.
So if you don't define the the macro when you build the package (I imagine this is what most users would do) it's going to ensure that the buildrequires are properly configured for what appears to be a standard PostgreSQL installation.

How to activate and modify build configurations in cedet/ede?

I basically want to know how to turn off optimization so that gdb works correctly.
When I set up an Automake project from scratch, it seems like the defaults for CPPFLAGS are "-g -O2", but I just want "-g". There is an unrelated question where the answer shows Project.ede files that have the configuration-variables field set for the target here:
Setting up an emacs EDE-project with libraries
Based on this, I edited my target to produce the following Project.ede:
;; Object test3
;; EDE Project Files are auto generated: Do Not Edit
(ede-proj-project "test3"
:file "Project.ede"
:name "test3"
:targets (list
(ede-proj-target-makefile-program "test3"
:name "test3"
:path ""
:source '("main.cpp")
:configuration-variables '(("debug" ("CPPFLAGS" . "-g")) ("release" ("CPPFLAGS" . "-O3")))
:ldlibs '("boost_program_options" "boost_system")
)
)
:makefile-type 'Makefile.am
)
However, executing ede-compile-project and ede-compile-target after these edits still produces the same "-g -O2" values. How do I activate the "debug" configuration that I created? Also, how can I set this to be the default set of configurations for new projects so I don't need to change every new project that I create manually?
You can change current configuration in project settings.
M-x customize-project, then go to the Settings tab and change the Current Configuration value.