Skip to content

Commit

Permalink
Add a GitHub Action Workflow to run eslint. Install 10up-toolkit and …
Browse files Browse the repository at this point in the history
…use it to run eslint, adding proper configurations. Also set things up to run stylelint, though we don't use that currently in an Action Workflow
  • Loading branch information
dkotter committed May 31, 2024
1 parent 2a3a535 commit f3b80c3
Show file tree
Hide file tree
Showing 8 changed files with 19,645 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[{*.json,*.yml,.babelrc,.bowerrc,.browserslistrc,.postcssrc}]
indent_style = space
indent_size = 2

[*.txt,wp-config-sample.php]
end_of_line = crlf
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
js/i18n
js/datepicker.js
js/scrollTo.js
tests
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@10up/eslint-config/wordpress'],
};
42 changes: 42 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: JS Linting

on:
push:
branches:
- develop
- main
paths:
- '**.js'
pull_request:
branches:
- develop
paths:
- '**.js'

jobs:
eslint:
runs-on: ubuntu-latest

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

- name: Setup node and npm cache
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm

- name: Install Node dependencies
run: npm ci --omit=optional

- name: Get updated JS files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
**/*.js
- name: Run JS linting
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
run: ./node_modules/.bin/10up-toolkit lint-js ${{ steps.changed-files.outputs.all_changed_files }}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
Loading

0 comments on commit f3b80c3

Please sign in to comment.