这是indexloc提供的服务,不要输入任何密码
Skip to content

Add JS & CSS lint actions on PRs #51

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

Merged
merged 8 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
54 changes: 54 additions & 0 deletions .github/workflows/lint-js-css.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Linting

on:
pull_request:
types:
- synchronize
- opened
- ready_for_review

paths:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to require paths explicitly? We already have specified paths in the npm:lint* commands.

- '**.js'
- '.eslint*'
- '**.css'
- '**.scss'
- '.nvmrc'
- '.stylelint*'
- '**/package.json'
- 'package-lock.json'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint JS, CSS, package.json
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm

- name: Install dependencies
run: npm ci

- name: JS Lint
run: npm run lint:js

- name: CSS Lint
run: npm run lint:css

- name: JS Lint Report
run: npm run lint:js:report
continue-on-error: true

- name: package.json Lint
run: npm run lint:package-json
5 changes: 5 additions & 0 deletions .npmpackagejsonlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"valid-values-license": ["error", ["MIT"]]
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"homepage": "https://github.com/rtCamp/theme-elementary#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/rtCamp/theme-elementary.git"
"url": "https://github.com/rtCamp/theme-elementary.git"
},
"bugs": {
"url": "https://github.com/rtCamp/theme-elementary/issues"
Expand Down Expand Up @@ -52,7 +52,7 @@
"lint:js:report": "npm run lint:js -- --output-file lint-js-report.json --format json .",
"lint:php": "vendor/bin/phpcs",
"lint:php:fix": "./bin/phpcbf.sh",
"lint:pkg-json": "wp-scripts lint-pkg-json --ignorePath .gitignore",
"lint:package-json": "wp-scripts lint-pkg-json --ignorePath .gitignore",
"lint:staged": "lint-staged",
"prepare": "husky install && npm run init",
"start": "wp-scripts start",
Expand Down