ddev-drupal-contrib icon indicating copy to clipboard operation
ddev-drupal-contrib copied to clipboard

`ddev eslint` breaks due to hyphens in project name

Open jameswilson opened this issue 1 year ago • 4 comments

Problem Statement

I see the following error:

$ ddev eslint
/mnt/ddev_config/commands/web/eslint: line 16: cd: web/modules/custom/my-module: No such file or directory
Failed to run eslint : exit status 1

The problematic line is this one:

cd "$DDEV_DOCROOT/modules/custom/$DDEV_SITENAME"

Ddev doesn't allow you to create a project name with underscores in it, because it creates an invalid domain name. Therefore, module names that contain underscores (eg "my_module") must be converted to hyphens for the Ddev project name.

When this happens the module name (my_module) is not the same as the Ddev project name (my-module, and so cd web/modules/custom/my-module will fail.

Proposed resolution

If possible refactor the eslint command file to execute eslint from the project root folder ( like all of the other commands currently do). Pass in the path to the project folder as a flag or option to the eslint command, ideally using wildcard syntax $DDEV_DOCROOT/modules/custom/* so that we don't have to decypher the actual project folder name. (I don't think we have an environment variable for this).

jameswilson avatar May 26 '24 14:05 jameswilson