Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV-37: Lint custom javascript with eslint #223

Merged
merged 20 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ae3e179
Exclude .js from php linters
jesconstantine Jun 7, 2023
efbfd0c
Install node dependencies and lint custom js in code-review target
jesconstantine Jun 7, 2023
0814481
Add config options for eslint directories and extensions
jesconstantine Jun 26, 2023
53cbedb
Use core's actual eslint dependency and our new eslint config options
jesconstantine Jun 26, 2023
a36cb40
Revert "Use core's actual eslint dependency and our new eslint config…
jesconstantine Jun 26, 2023
9da9153
Use built in tools for running eslint (node) and checking dependencie…
jesconstantine Jul 13, 2023
d44aeec
TEMP: update acquia memcache build install steps based on their docs
jesconstantine Jul 13, 2023
f7bf34a
Use yarn to execute eslint binary
jesconstantine Jul 13, 2023
5ed8b94
remove dependency on node dependencies from code-review task
jesconstantine Jul 13, 2023
42fbcb0
create discrete eslint phing task
jesconstantine Jul 13, 2023
1e5dd5d
use recommended yarn cli command for checking installed packages
jesconstantine Jul 13, 2023
f15aee8
Don't touch settings file which is being removed anyway
jesconstantine Jul 13, 2023
c1d7ef4
Clean up comments for the eslint target
jesconstantine Jul 13, 2023
0a5eec8
Make the directions clearer for multiple eslint directory patterns
jesconstantine Jul 13, 2023
946638a
Add more context for eslint ext argument.
jesconstantine Jul 13, 2023
5c3c004
I think we should allow ignore files, patterns to be used.
jesconstantine Jul 13, 2023
2aaded8
Merge branch 'develop' into dev-37-eslint
agentrickard Aug 16, 2023
893856d
dev-37 - Use php 8.1.18.
raylwalters Aug 16, 2023
042cee7
Revert "dev-37 - Use php 8.1.18."
raylwalters Aug 16, 2023
6bcfd92
Merge branch 'develop' into dev-37-eslint
byrond Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,21 @@ styleguide:
root: 'styleguide'
# Command to compile the style guide assets, for use during the build and artifact steps.
command: 'yarn default'

# Configuration for linting custom javascript.
#
# Update these properties to reflect the directories and extensions used for
# your project's custom javascript.
# @see https://eslint.org/docs/latest/use/core-concepts
eslint:
# Run eslint on custom modules AND themes, this must be a single value.
# @see: https://eslint.org/docs/latest/use/command-line-interface#run-the-cli
#
# If you need multiple directories that don't match a single pattern, you
# may need to add multiple config values here and add a for loop to the build
# target for eslint.
directory: "${drupal.root}/**/custom/"
# Run eslint on files with .es6.js extension.
# This can be a comma separated list.
# @see: https://eslint.org/docs/latest/use/command-line-interface#--ext
extensions: ".es6.js"
35 changes: 35 additions & 0 deletions defaults/install/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@

<!-- Run Drupal Check. -->
<foreach list="${drupal-check.directories}" param="drupal-check.dir" target="drupal-check" />
<!-- Run eslint -->
<phingcall target="eslint" />
</target>


Expand All @@ -140,6 +142,13 @@
<exec command="${drupal-check.command}" logoutput="true" checkreturn="true" />
</target>

<!-- Target: eslint -->
<target name="eslint" depends="install-node-dependencies">
<!-- Lint custom module and theme (by default) javascript. -->
<echo msg="$> yarn run eslint --ext ${eslint.extensions} ${eslint.directory}" />
<exec command="yarn run eslint --fix-dry-run --ext ${eslint.extensions} --resolve-plugins-relative-to ${drupal.root}/core --no-error-on-unmatched-pattern ${eslint.directory}" logoutput="true" checkreturn="true" />
</target>


<!-- Target: code-fix -->
<target name="code-fix" description="Run the automated code fixer.">
Expand All @@ -148,6 +157,32 @@
<exec command="vendor/bin/phpcbf" logoutput="true" checkreturn="false" />
</target>

<!-- Target: install-node-dependencies -->
<target name="install-node-dependencies" depends="" description="Install project, core, and custom module node dependencies">
<echo msg="Seeing if project npm packages are installed and at the expected version." />
<exec command="yarn install --check-files --verbose" returnProperty="project_dependencies" logoutput="true" />
<if>
<not>
<equals arg1="${project_dependencies}" arg2="0" />
</not>
<then>
<echo msg="Install project node dependencies to get eslint libraries." />
<exec dir="${drupal.root}/.." command="yarn install" logoutput="true" />
</then>
</if>
<echo msg="Seeing if Drupal core npm packages are installed and at the expected version." />
<exec dir="${drupal.root}/core" command="yarn install --check-files --verbose" returnProperty="core_dependencies" logoutput="true" />
<if>
<not>
<equals arg1="${core_dependencies}" arg2="0" />
</not>
<then>
<echo msg="Install Core node dependencies to get eslint libraries." />
<exec dir="${drupal.root}/core" command="yarn install" logoutput="true" checkreturn="true" />
</then>
</if>
</target>


<!-- Target: artifact -->
<target name="artifact" description="Build and deploy the application.">
Expand Down
2 changes: 1 addition & 1 deletion defaults/install/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<config name="ignore_errors_on_exit" value="0" />

<!-- Set extensions to scan. -->
<arg name="extensions" value="php,module,inc,install,test,profile,theme,info,yml,css,js"/>
<arg name="extensions" value="php,module,inc,install,test,profile,theme,info,yml,css"/>

<!-- Use colors in output. -->
<arg name="colors"/>
Expand Down
9 changes: 8 additions & 1 deletion targets/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,14 @@
<case value="acquia">
<!-- Site-level setup -->
<!-- @see https://docs.acquia.com/cloud-platform/performance/memcached/enable/ -->
<httpget url="https://docs.acquia.com/_downloads/cloud-memcache-d8+.php" dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}" filename="settings.acquia-memcache.php"/>
<composer command="require" composer="${composer.composer}">
<arg line="--working-dir ${application.startdir}"/>
<arg value="drupal/memcache"/>
</composer>
<composer command="require" composer="${composer.composer}">
<arg line="--working-dir ${application.startdir}"/>
<arg value="acquia/memcache-settings"/>
</composer>
Copy link
Contributor Author

@jesconstantine jesconstantine Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can roll this back once #226 is merged but this unblocks the build installer test step.

</case>

<case value="pantheon">
Expand Down