chore: Add ESLint for code linting

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2024-06-19 11:21:22 +02:00
Родитель f61d0a3e6f
Коммит b4edb6b224
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 45FAE7268762B400
3 изменённых файлов: 105 добавлений и 17 удалений

98
.github/workflows/lint-eslint.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,98 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
#
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT
name: Lint eslint
on: pull_request
permissions:
contents: read
concurrency:
group: lint-eslint-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
src: ${{ steps.changes.outputs.src}}
steps:
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
continue-on-error: true
with:
filters: |
src:
- '.github/workflows/**'
- 'src/**'
- 'appinfo/info.xml'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- '.eslintrc.*'
- '.eslintignore'
- '**.js'
- '**.ts'
- '**.vue'
lint:
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.src != 'false'
name: NPM lint
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
id: versions
with:
fallbackNode: '^20'
fallbackNpm: '^10'
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v3
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
- name: Install dependencies
env:
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_DOWNLOAD: true
run: npm ci
- name: Lint
run: npm run lint
summary:
permissions:
contents: none
runs-on: ubuntu-latest
needs: [changes, lint]
if: always()
# This is the summary, we just avoid to rename it so that branch protection rules still match
name: eslint
steps:
- name: Summary status
run: if ${{ needs.changes.outputs.src != 'false' && needs.lint.result != 'success' }}; then exit 1; fi

17
.github/workflows/lint.yml поставляемый
Просмотреть файл

@ -1,17 +0,0 @@
name: Lint
on: pull_request
jobs:
node-linters:
runs-on: ubuntu-latest
name: Check types
steps:
- uses: actions/checkout@master
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: npm install
run: npm i
- name: Check types
run: npm run check-types

Просмотреть файл

@ -29,14 +29,21 @@
"build:doc": "typedoc --out dist/doc lib && touch dist/doc/.nojekyll",
"dev": "vite --mode development build",
"dev:watch": "vite --mode development build --watch",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
},
"browserslist": [
"extends @nextcloud/browserslist-config"
],
"eslintConfig": {
"extends": "@nextcloud/eslint-config/typescript"
},
"devDependencies": {
"@nextcloud/browserslist-config": "^3.0.1",
"@nextcloud/eslint-config": "^8.4.1",
"@nextcloud/vite-config": "^2.0.2",
"@types/node": "^20.14.5",
"eslint": "^8.57.0",
"typedoc": "^0.25.13",
"typescript": "^5.4.5",
"vite": "^5.3.1",