Browse Source

ci: Use eslint to track calls to @deprecated functions/components (#70184)

This creates a new workflow specifically for tracking calls to
`@deprecated` functions in javascript.

It's going to run on a schedule, or on demand. It's not needed to run on
every PR because the expectation is that there will be a long list of
deprecations, and we should work over time to fix them up. If this were
running on every PR it would desensitize people to lint problems so
quickly, a really bad place to be.

Followup tasks that we don't need to start with but would be amazing:
- Change the output so it's grouped by `@deprecated` method, so we can
see all related things at once
- Connect it to a slackbot command so we can use/share the results with
the team more easily, especially the count of errors.



Example output: 

https://github.com/getsentry/sentry/actions/runs/8943695929/job/24568982206?pr=70184
Ryan Albrecht 9 months ago
parent
commit
f54deb0fa3
3 changed files with 46 additions and 1 deletions
  1. 12 1
      .eslintrc.js
  2. 33 0
      .github/workflows/frontend-lint-burndown.yml
  3. 1 0
      tsconfig.json

+ 12 - 1
.eslintrc.js

@@ -1,8 +1,19 @@
 /* eslint-env node */
 
+const detectDeprecations = !!process.env.SENTRY_DETECT_DEPRECATIONS;
+
 module.exports = {
   root: true,
-  extends: ['sentry-app/strict'],
+  extends: detectDeprecations
+    ? ['sentry-app/strict', 'plugin:deprecation/recommended']
+    : ['sentry-app/strict'],
+
+  parserOptions: detectDeprecations
+    ? {
+        project: './tsconfig.json',
+      }
+    : {},
+
   globals: {
     require: false,
     expect: false,

+ 33 - 0
.github/workflows/frontend-lint-burndown.yml

@@ -0,0 +1,33 @@
+name: frontend-lint-burndown
+
+on:
+  workflow_dispatch:
+  schedule:
+    - cron: '0 4 * * 1'
+
+env:
+  NODE_OPTIONS: '--max-old-space-size=4096'
+
+jobs:
+  deprecations:
+    name: Lint @deprecated callsites
+    timeout-minutes: 30
+    # Make sure this matches the runner that runs frontend tests
+    runs-on: ubuntu-22.04
+    steps:
+      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+
+      - name: Install dependencies & inject eslint-plugin-deprecation
+        id: dependencies
+        run: yarn add --dev eslint-plugin-deprecation
+
+      # Setup custom tsc matcher, see https://github.com/actions/setup-node/issues/97
+      - name: setup matchers
+        run: |
+          echo "::remove-matcher owner=masters::"
+          echo "::add-matcher::.github/eslint-stylish.json"
+
+      - name: ESLint
+        env:
+          SENTRY_DETECT_DEPRECATIONS: 1
+        run: yarn lint:js

+ 1 - 0
tsconfig.json

@@ -4,6 +4,7 @@
     "allowJs": true
   },
   "include": [
+    ".eslintrc.js",
     "static/app",
     "tests/js",
     "fixtures/js-stubs",