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

Added linters. #166

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
74 changes: 74 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Lint
on: [pull_request]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache PHP dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Cache node modules
id: cache
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}

- name: Install PHP dependencies
run: composer install --prefer-dist

- name: Install JS dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install

- name: Install reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

- name: Lint styles
uses: reviewdog/action-stylelint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
stylelint_input: '**/*.scss'
fail_on_error: true
if: always()

- name: Lint scripts
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
fail_on_error: true
if: always()

- name: Lint PHP
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: php ./vendor/bin/phpcs --report=diff -- $(git diff --name-only --diff-filter=ACMR origin/master | grep \\.php | xargs) | sed -r 's/[[:cntrl:]]\[[0-9]{1,3}m//g' | sed -E 's/--- (.+)$/\0\n+++ \1/g; /\+\+\+ PHP_CodeSniffer$/d' | reviewdog -f=diff -f.diff.strip=0 -name=phpcs -reporter=github-pr-review -filter-mode=nofilter -fail-on-error
if: always()
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/node_modules/*
node_modules
vendor

.eslintcache
.stylelintcache
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
15 changes: 15 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,20 @@
"require": {
"php": ">=7.0.0",
"composer/installers": "^1"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/netzstrategen/phpcs-config.git"
}
],
"require-dev": {
"netzstrategen/phpcs-config": "dev-main",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1"
},
"scripts": {
"post-install-cmd": [
"cp ./vendor/netzstrategen/phpcs-config/phpcs.xml ."
]
}
}
Loading