mirror of
https://github.com/nextcloud/documentation.git
synced 2026-01-02 17:59:36 +07:00
Merge pull request #6930 from nextcloud/feat/workflow-lint
Update linting documentation and workflow examples
This commit is contained in:
@@ -13,6 +13,8 @@ We highly recommend setting up automated tests for your app, so that every chang
|
||||
* Unit testing: run unit tests for front-end and back-end where individual classes and components are tested in isolation
|
||||
* Integration testing: test components when they are combined
|
||||
|
||||
You can find a list of available github workflow templates in our `nextcloud template repository <https://github.com/nextcloud/.github>`_.
|
||||
|
||||
Linting
|
||||
-------
|
||||
|
||||
@@ -43,28 +45,24 @@ You can validate the ``info.xml`` :ref:`app metadata<app metadata>` file of an a
|
||||
php
|
||||
^^^
|
||||
|
||||
A lint of all php source files can find syntax errors that could crash the application in production. The github action below uses a test matrix of multiple php versions. Adjust it to the ones your app supports.
|
||||
A lint of all php source files can find syntax errors that could crash the application in production. You can find the github actions in our `nextcloud template repository <https://github.com/nextcloud/.github>`_.
|
||||
You will also require the following lint script in your ``composer.json``:
|
||||
|
||||
.. code-block:: yaml
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"scripts": {
|
||||
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l"
|
||||
}
|
||||
}
|
||||
|
||||
php-cs
|
||||
^^^^^^
|
||||
|
||||
We encourage the usage of php-cs linting. You can find some documentation on how to set this up in the
|
||||
`nextcloud coding-standard repository <https://github.com/nextcloud/coding-standard>`_ as well as the
|
||||
relevant github actions in our `nextcloud template repository <https://github.com/nextcloud/.github>`_.
|
||||
|
||||
name: Lint
|
||||
on: pull_request
|
||||
php-linters:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: [7.3, 7.4]
|
||||
name: php${{ matrix.php-versions }} lint
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
- name: Set up php${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@master
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
coverage: none
|
||||
- name: Lint
|
||||
run: composer run lint
|
||||
|
||||
.. _app-static-analysis:
|
||||
|
||||
|
||||
@@ -81,22 +81,25 @@ npm run lint (optional)
|
||||
-----------------------
|
||||
|
||||
Nextcloud apps that use linting tools for consistent code formatting typically add a ``lint`` script to their
|
||||
``package.json``:
|
||||
``package.json`` and install the appropriate `eslint config <https://www.npmjs.com/package/@nextcloud/eslint-config>`_:
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"scripts": {
|
||||
"lint": "eslint --ext .js,.vue src"
|
||||
"lint": "eslint --ext .js,.vue src",
|
||||
"lint:fix": "eslint --ext .js,.vue src --fix"
|
||||
}
|
||||
}
|
||||
|
||||
If style linting is a separate script, ``stylelint`` shall be used as conventional script name:
|
||||
If style linting is a separate script, ``stylelint`` shall be used as conventional script name.
|
||||
You can find the standard nextcloud `stylelint config <https://www.npmjs.com/package/@nextcloud/stylelint-config>`_ on npm too.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"scripts": {
|
||||
"stylelint": "stylelint src"
|
||||
"stylelint": "stylelint src",
|
||||
"stylelint:fix": "stylelint src --fix"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user