Update linting documentation and workflow examples

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv)
2021-07-06 11:19:22 +02:00
parent 033a285ece
commit e7e5a87de0
2 changed files with 25 additions and 24 deletions

View File

@@ -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:

View File

@@ -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"
}
}