-
Notifications
You must be signed in to change notification settings - Fork 3
update: enable linting and formatting via pre-commit hooks #31
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
Open
Isha-Sharma
wants to merge
10
commits into
main
Choose a base branch
from
linting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f6f4196
feat: linting, formatting, common tsconfig files
Isha-Sharma 0741b5c
chore: lint files @ formula-editor
Isha-Sharma 315743d
Merge branch 'main' into linting
Isha-Sharma abef81f
fix(workflow): push the tag first before release
Isha-Sharma 22d1d60
update(major): bump all dependencies to major version
Isha-Sharma ce9c161
chore: regenerate package-lock
Isha-Sharma 05946ce
update(workflow): use node v22
Isha-Sharma d3ffaee
chore(release): publish v2.3.4-linting.0
87f6779
chore: proper error handling @ hooks + update image versions @ npm-pu…
Isha-Sharma 7b4b36d
chore(release): publish v2.3.4-linting.1
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: format and lint files on PR approval | ||
|
|
||
| on: | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| jobs: | ||
| should_run_format: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.review.state == 'approved' | ||
| outputs: | ||
| run_format: ${{ steps.check.outputs.run_format }} | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
| - name: Check last commit author and message | ||
| id: check | ||
| run: | | ||
| LAST_AUTHOR=$(git log -1 --pretty=format:'%an') | ||
| LAST_MESSAGE=$(git log -1 --pretty=%B) | ||
| if [[ "$LAST_AUTHOR" =~ bot && "$LAST_MESSAGE" =~ "[skip ci]" ]]; then | ||
| echo "run_format=false" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "run_format=true" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| format_files: | ||
| runs-on: ubuntu-latest | ||
| needs: should_run_format | ||
| if: needs.should_run_format.outputs.run_format == 'true' && github.event.review.state == 'approved' | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Lint and Format files | ||
| run: | | ||
| TARGET_BRANCH=${{ github.event.pull_request.base.ref }} | ||
| npm ci --ignore-scripts=true | ||
| npx lint-staged --diff $(git merge-base origin/"$TARGET_BRANCH" HEAD) --allow-empty | ||
|
|
||
| - name: Setup git | ||
| run: | | ||
| git config --global user.email "actions@github.com" | ||
| git config --global user.name "github-actions[bot]" | ||
|
|
||
| - name: Commit and push changes | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| git add -u | ||
| if ( ! git diff-index --quiet --cached HEAD ); then | ||
| git commit -m "CI: format and lint files" -m "[skip ci]" --no-verify | ||
| git push --follow-tags --atomic --no-verify | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/bash | ||
|
|
||
| test -f .git/hooks/pre-commit && .git/hooks/pre-commit | ||
|
|
||
| [[ ! -z $(git rev-parse -q --verify MERGE_HEAD) ]] && exit 0 | ||
|
|
||
| # update same commit for lint changes | ||
| npx lint-staged || exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash | ||
|
|
||
| if test -f .git/hooks/pre-push; then | ||
| bash .git/hooks/pre-push | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .prettierignore | ||
| .gitignore | ||
| .talismanrc | ||
| .hooks/** | ||
| **/.env.* | ||
| **/.env | ||
| **/csp.* | ||
| **/.firebaserc | ||
| **/*.ico | ||
| **/*.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "printWidth": 180, | ||
| "quoteProps": "consistent", | ||
| "trailingComma": "none", | ||
| "arrowParens": "always", | ||
| "plugins": ["@trivago/prettier-plugin-sort-imports"], | ||
| "importOrderParserPlugins": ["typescript", "jsx", "decorators"], | ||
| "importOrder": [ | ||
| "^react$|react-*", | ||
| "constants(.*)$", | ||
| "contexts(.*)$", | ||
| "api-client|openapi-client|oidc-client", | ||
| "^(./|~/|@/)(?!utils/|images/|styles/|types/)", | ||
| "<THIRD_PARTY_MODULES>", | ||
| "utils(.*)$", | ||
| "images(.*)$", | ||
| "styles(.*)$", | ||
| "types(.*)$" | ||
| ], | ||
| "importOrderCaseInsensitive": true, | ||
| "importOrderSeparation": true, | ||
| "importOrderSortSpecifiers": true, | ||
| "importOrderGroupNamespaceSpecifiers": true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import reactPlugin from "eslint-plugin-react"; | ||
|
|
||
| import eslint from "@eslint/js"; | ||
| import eslintConfigPrettier from "eslint-config-prettier"; | ||
| import jsdoc from "eslint-plugin-jsdoc"; | ||
| import globals from "globals"; | ||
|
|
||
| import typescriptParser from "@typescript-eslint/parser"; | ||
| import tseslint from "typescript-eslint"; | ||
|
|
||
| export default [ | ||
| { | ||
| languageOptions: { | ||
| ecmaVersion: "latest", | ||
| sourceType: "module", | ||
| parser: typescriptParser, | ||
| ...reactPlugin.configs.flat.recommended.languageOptions, | ||
| parserOptions: { | ||
| ecmaFeatures: { | ||
| jsx: true | ||
| } | ||
| }, | ||
| globals: { | ||
| ...globals.browser | ||
| } | ||
| } | ||
| }, | ||
| eslint.configs.recommended, | ||
| ...tseslint.configs.recommended, | ||
| eslintConfigPrettier, | ||
| reactPlugin.configs.flat.recommended, | ||
| reactPlugin.configs.flat["jsx-runtime"], | ||
| { | ||
| rules: { | ||
| "no-eval": "error", | ||
| "no-useless-escape": "error", | ||
| // "no-use-before-define": ["warn", { functions: false, classes: true, variables: true }], | ||
| "block-scoped-var": "error", | ||
| "no-alert": "error", | ||
| "no-script-url": "error", | ||
| "no-var": "error", | ||
| "prefer-const": "error", | ||
| "array-callback-return": ["error", { checkForEach: true }], | ||
| "no-extra-boolean-cast": "off", | ||
| "react/jsx-key": "off", | ||
| "prefer-template": "warn", | ||
| "no-self-compare": "warn", | ||
| "no-duplicate-imports": "warn", | ||
| "no-unused-vars": "off", | ||
| "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }], | ||
| "eqeqeq": "warn", | ||
| "max-depth": ["warn", 3], | ||
| "no-inline-comments": "warn", | ||
| "no-multi-assign": "warn", | ||
| "require-await": "warn" | ||
| } | ||
| }, | ||
| { | ||
| files: ["**/*.js", "**/*.ts", "**/*.tsx"], | ||
| plugins: { | ||
| jsdoc | ||
| }, | ||
| rules: { | ||
| "jsdoc/require-jsdoc": [ | ||
| "off", | ||
| { | ||
| enableFixer: false, | ||
| require: { | ||
| FunctionDeclaration: true, | ||
| MethodDefinition: true | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Update actions/checkout to v4.
Both checkout actions use
@v3, which is outdated. GitHub recommends using@v4for better performance and Node.js 20 support.Apply this diff:
Also applies to: 33-33
🧰 Tools
🪛 actionlint (1.7.8)
14-14: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents