-
Notifications
You must be signed in to change notification settings - Fork 7
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 eslint and JavaScript linting in GitHub Actions #36
Changes from all commits
3b2522c
9550505
611cc8c
0734e0f
1b9260c
874fa65
090f7e4
f8eff65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: JavaScript Linting | ||
|
||
on: | ||
push: | ||
branches: | ||
- trunk | ||
paths: | ||
- "**.js" | ||
- "**.mjs" | ||
- .github/workflows/js-linting.yml | ||
pull_request: | ||
paths: | ||
- "**.js" | ||
- "**.mjs" | ||
- .github/workflows/js-linting.yml | ||
Comment on lines
+4
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💅 Maybe running this WorkFlow on PR against trunk would be enough? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the linting check only runs on PR against trunk, PR to PR, like this current one (#34), wouldn't be run. I think finding out linting errors earlier should be ideal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I meant is to remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The temporarily merged code of a PR to be run checks is not always the same as the merged one after a PR actually gets merged. For example, if there are other commits are pushed to trunk after this PR was opened, this PR won't be triggered and run the check again if there are no conflicts. When two PR change the same file like this: const config = {
+ hello: '123', // Added by PR A
howdy: '000',
+ hello: '456', // Added by PR B
};
}; Both PR could pass the check, but it would be a problem after merging. When this happens, the check run on push events of trunk might find out this problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right! Thanks for the explanation 👌 |
||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
FORCE_COLOR: 2 | ||
|
||
jobs: | ||
JSLintingCheck: | ||
name: Lint JavaScript | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Prepare node | ||
uses: woocommerce/grow/prepare-node@actions-v1 | ||
with: | ||
node-version-file: .nvmrc | ||
|
||
- name: Prepare annotation formatter | ||
uses: woocommerce/grow/eslint-annotation@actions-v1 | ||
|
||
# Turn off import/no-unresolved rule since this check doesn't install packages for all sub-packages. | ||
- name: Lint JavaScript and annotate linting errors | ||
run: | | ||
npm run lint:js -- --rule 'import/no-unresolved: 0' --format ./eslintFormatter.cjs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lts/fermium |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require( '@wordpress/prettier-config' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💅 If we are going to set up a global package.json I'd also add a
.nvmrc
fileThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in fa4b346.