Browse Source

fix: lint `.ts` and `.js` files in CI (#73949)

We've been seeing issues lately where bad formatting in `.ts` files is
making it into `master` and blocking deploys. This PR fixes the issue in
`sentry`, `getsentry` PR coming separately but will look the same.

The flow is:

- someone makes a `.ts` change in an editor that doesn't run Prettier
- local `pre-commit` doesn't run Prettier on `.ts` files (Problem 1)
- the `pre-commit` PR check doesn't run Prettier on `.ts` files either,
so there's no auto-fix
- the `prettier (changed files only)` task on the PR doesn't see any
changed files, and doesn't run so there's no PR failure (Problem 2)
- the PR is merged into `master`. `typescript-and-lint` runs on _all_
files and finds the bad formatting

Problem 1: This PR updates the `pre-commit` config which will auto-lint
the files before they're committed (in most cases) and make sure that
`pre-commit` auto-fixes the files in the PR (in all cases)

Problem 2: This PR fixes a typo in the file names that prevented those
names from being passed through to the tasks. With this fix, the
`typescript-and-lint
George Gritsouk 8 months ago
parent
commit
07ec6085fc
2 changed files with 5 additions and 5 deletions
  1. 3 3
      .github/workflows/frontend.yml
  2. 2 2
      .pre-commit-config.yaml

+ 3 - 3
.github/workflows/frontend.yml

@@ -24,11 +24,11 @@ jobs:
     timeout-minutes: 3
     # Map a step output to a job output
     outputs:
-      lintable_prettier_modified: ${{ steps.changes.output.lintable_prettier_modified }}
-      lintable_prettier_modified_files: ${{ steps.changes.output.lintable_prettier_modified_files }}
+      lintable_prettier_modified: ${{ steps.changes.outputs.lintable_prettier_modified }}
+      lintable_prettier_modified_files: ${{ steps.changes.outputs.lintable_prettier_modified_files }}
       lintable_css_in_js_modified: ${{ steps.changes.outputs.lintable_css_in_js_modified }}
       lintable_css_in_js_modified_files: ${{ steps.changes.outputs.lintable_css_in_js_modified_files }}
-      lintable_css_in_js_rules_changed: ${{ steps.changes.output.lintable_css_in_js_rules_changed }}
+      lintable_css_in_js_rules_changed: ${{ steps.changes.outputs.lintable_css_in_js_rules_changed }}
       lintable_modified: ${{ steps.changes.outputs.lintable_modified }}
       lintable_modified_files: ${{ steps.changes.outputs.lintable_modified_files }}
       lintable_rules_changed: ${{ steps.changes.outputs.lintable_rules_changed }}

+ 2 - 2
.pre-commit-config.yaml

@@ -140,9 +140,9 @@ repos:
     rev: 'v3.1.0' # Use the sha or tag you want to point at
     hooks:
       - id: prettier
-        name: prettier (yaml, markdown, tsx, jsx, css)
+        name: prettier (yaml, markdown, ts, tsx, js, jsx, css)
         # TODO: Remove tsx and jsx when Biome supports styled CSS formatting.
-        types_or: [yaml, markdown, tsx, jsx, css]
+        types_or: [yaml, markdown, ts, tsx, javascript, jsx, css]
         # Override the default version of prettier since there isn't a tag with 3.2.5
         additional_dependencies: ['prettier@3.3.2']
         # https://pre-commit.com/#regular-expressions