Score:1

Correctly configure the JavaScript tools

de flag

I am trying to configure eslint for Drupal in PHPStorm, and it's really confusing.

For example, I have installed the node dependencies that comes in the web/core/package.json file. In PHPStorm, in the Eslint settings, I have configured web/core/node_modules/eslint, but with this module (eslint-config-drupal), I don't know if to configure it with node_modules/eslint which is in the root where I installed eslint-config-drupal. The same goes for prettier.

When I check the Drupal JavaScript coding standards using, for example, ./node_modules/.bin/eslint --no-ignore "../modules/custom/my_module/js/file.js" I had to pass the --no-ignore parameter in order to see the style errors.

The package.json used by Drupal core has some interesting commands that I am interested in using, such as transpiling ES6 to ES5. What the core does is transpile a file.es6.js file to file.js.

In the Drupal documentation I see that the command can apparently be used like npm run build:js -- --file ../modules/custom/my_module/js/file.es6.js, but when I do so, I notice That the Babel plugins don't process them and only show the same file. I only added a generic header text.

I understand that these commands are for the Drupal core, and if I temporarily copy a file.es6.js file to a location within the core, Babel transpiles it correctly.

The only way I have managed to transpile it is to copy the package.json file, the core JavaScript files, and use it in the root of the project. What I don't like is having everything duplicated.

I don't know if there is a way to use what comes with Drupal core in a transparent way.

Score:0
de flag

Update:

Starting with Drupal 10, an ES6 build process will no longer be used, and several of the scripts related to these tasks are removed.

Now Js code will be written directly without an intermediate compilation process.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.