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.