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

Add JS linter and fix reported issues #424

Merged
merged 11 commits into from
Dec 15, 2023
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

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

[*.{yml,yaml}]
indent_style = space
indent_size = 2

[*.{gradle,java,kt}]
indent_style = space

[packages/react-native-*/**.xml]
indent_style = space

3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ]
}
37 changes: 37 additions & 0 deletions .github/workflows/lint-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Lint JS

on:
# Run on pushes to select branches and on all pull requests.
push:
branches:
- master
aristath marked this conversation as resolved.
Show resolved Hide resolved
- develop
- trunk
- 'feature/**'
- 'release/**'
- 'hotfix/[0-9]+.[0-9]+*'
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest

name: "Lint: JS"

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

# The lint stage doesn't run the unit tests or use code style, so no need for PHPUnit, WPCS or phpcompatibility.
- name: 'Install NPM packages'
run: npm install
- name: 'Run ESLint'
run: npm run lint:js
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml → .github/workflows/lint-php.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint
name: Lint PHP

on:
# Run on pushes to select branches and on all pull requests.
Expand Down Expand Up @@ -69,4 +69,4 @@ jobs:
tools: cs2pr

- name: Lint against parse errors
run: composer lint -- --checkstyle | cs2pr
run: composer lint -- --checkstyle | cs2pr
93 changes: 47 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
"build": "npx webpack",
"dev": "npx webpack --watch --mode development",
"dist": "npx webpack --mode production && composer install --no-dev && composer dump-autoload --no-dev -o && wp-scripts plugin-zip && mv accessibility-checker.zip ./dist && composer install",
"lint": "./vendor/bin/phpcs",
"test:e2e": "npx wp-env clean tests && npx playwright test ./e2e/specs"
"lint": "./vendor/bin/phpcs && npm run lint:js",
"lint:php": "./vendor/bin/phpcs",
"lint:js": "wp-scripts lint-js",
"lint:js:fix": "wp-scripts lint-js --fix",
"test:e2e": "npx wp-env clean tests && npx playwright test ./e2e/specs"
},
"files": [
"LICENSE.txt",
Expand All @@ -33,9 +36,10 @@
"devDependencies": {
"@babel/core": "^7.22.1",
"@babel/preset-env": "^7.22.4",
"@babel/preset-react": "^7.22.3",
"@babel/preset-react": "^7.22.3",
"@floating-ui/dom": "^1.2.9",
"@wordpress/env": "*",
"@wordpress/eslint-plugin": "^17.5.0",
"@wordpress/scripts": "^26.5.0",
"axe-core": "^4.7.2",
"babel-loader": "^9.1.2",
Expand Down
Loading