diff --git a/developer_manual/digging_deeper/continuous_integration.rst b/developer_manual/digging_deeper/continuous_integration.rst index 94d5246bf..a1cf96135 100644 --- a/developer_manual/digging_deeper/continuous_integration.rst +++ b/developer_manual/digging_deeper/continuous_integration.rst @@ -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 `_. + Linting ------- @@ -43,28 +45,24 @@ You can validate the ``info.xml`` :ref:`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 `_. +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 `_ as well as the +relevant github actions in our `nextcloud template repository `_. - 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: diff --git a/developer_manual/digging_deeper/npm.rst b/developer_manual/digging_deeper/npm.rst index 2f1477611..2af1e4c76 100644 --- a/developer_manual/digging_deeper/npm.rst +++ b/developer_manual/digging_deeper/npm.rst @@ -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 `_: .. 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 `_ on npm too. .. code-block:: json { "scripts": { - "stylelint": "stylelint src" + "stylelint": "stylelint src", + "stylelint:fix": "stylelint src --fix" } }