Skip to content

chore: fix precommit for eslint - #32596

Merged
mistercrunch merged 3 commits into
masterfrom
fix_eslint_precommit
Mar 12, 2025
Merged

mistercrunch merged 3 commits into
masterfrom
fix_eslint_precommit

Conversation

@mistercrunch

@mistercrunch mistercrunch commented Mar 11, 2025 •

Copy link
Copy Markdown
Member

Trying to fix prettier and eslint in pre-commit so it only runs on altered files.

@rusackas this works for me, but is largely a rollback of #32352 in some key areas. Wondering what's wrong here.

Changes:

  • skipping dups in CI (eslint and tsc checks run in another GHA)
  • using the prettier action repo as opposed to a custom script
  • eslint back on using scripts/eslint.sh

If this doesn't work in some cases I can try and address the core issues.

@korbit-ai korbit-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've completed my review and didn't find any issues.

Need a new review? Comment /korbit-review on this PR and I'll review your latest changes.

Korbit Guide: Usage and Customization

Interacting with Korbit

  • You can manually ask Korbit to review your PR using the /korbit-review command in a comment at the root of your PR.
  • You can ask Korbit to generate a new PR description using the /korbit-generate-pr-description command in any comment on your PR.
  • Too many Korbit comments? I can resolve all my comment threads if you use the /korbit-resolve command in any comment on your PR.
  • On any given comment that Korbit raises on your pull request, you can have a discussion with Korbit by replying to the comment.
  • Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.

Customizing Korbit

  • Check out our docs on how you can make Korbit work best for you and your team.
  • Customize Korbit for your organization through the Korbit Console.

Current Korbit Configuration

General Settings ​
Setting Value
Review Schedule Automatic excluding drafts
Max Issue Count 10
Automatic PR Descriptions ❌
Issue Categories ​
Category Enabled
Documentation ✅
Logging ✅
Error Handling ✅
Readability ✅
Design ✅
Performance ✅
Security ✅
Functionality ✅

Feedback and Support

Note

Korbit Pro is free for open source projects 🎉

Looking to add Korbit to your team? Get started with a free 2 week trial here

@github-actions github-actions Bot added github_actions Pull requests that update GitHub Actions code preset-io labels Mar 11, 2025
@mistercrunch

Copy link
Copy Markdown
Member Author

@rusackas since you mentioned that this didn't work for you in the past, wondering if you can pull/test this and report back. Also remembering some issues with a user that was using Linux, where it's possible that $@ and this snippet "${@//$frontend_dir\//}" in scripts/eslint.sh doesn't behave the same way as in OSX.

I don't have a linux VM laying around to test... Would love if someone can test on Linux.

@rusackas

Copy link
Copy Markdown
Member

I'll test and report back asap. Would love to get this speedy again.

Comment thread .pre-commit-config.yaml
args: ["--markdown-linebreak-ext=md"]
- repo: local
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8 # Use the sha or tag you want to point at

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using 3.3.3 on the repo. I wonder if that'll lead to trouble.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, I see it uses prettier 3.3.3 below... but this repo is archived and claims it was broken by newer versions of Prettier. Not sure what to make of that yet.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure how much to worry about "This repository was archived by the owner on Apr 11, 2024. It is now read-only." - I guess it might be there forever, but someone could go sweeping up one day.

@mistercrunch mistercrunch Mar 12, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah seems it'd be good hygiene to get rid of this GHA-as-a-submodule and simply git push ourselves in our action. I don't think we need a reference to an unmaintained/super-simple GHA here given the use case.

Comment thread .pre-commit-config.yaml Outdated
files: ^superset-frontend/.*\.(js|jsx|ts|tsx)$
- id: eslint-docs
name: eslint (docs)
entry: bash -c 'cd docs && FILES=$(echo "$@" | sed "s|docs/||g") && yarn eslint --ext .js,.jsx,.ts,.tsx --quiet $([ -z "$SKIP_FIX" ] && echo "--fix") $FILES'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're getting rid of SKIP_FIX?

@mistercrunch mistercrunch Mar 12, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, unless I'm missing something I think it's fair to assume that pre-commit tries and fix things. Personally I've never seen prettier or eslint make a bad fix, meaning it's pretty much always preferable to --fix.

If I remember well there's something in the pre-commit GHA that checks if the code's been altered and fails if/when that's the case. I think the return code is negative regardless, but we're still checking to see if anything changed and fail if that's the case. Here: https://github.com/apache/superset/blob/master/.github/workflows/pre-commit.yml#L69-L72

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, what I meant is that if SKIP_FIX is no longer in pre-commit.yaml as of this PR, I think we can remove it from this line.

set +e # Don't exit immediately on failure
# Skip auto-fixing in CI to ensure changes are committed locally
export SKIP_FIX=1
export SKIP=eslint-frontend,type-checking-frontend

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think SKIP_FIX was introduced in your previous PR and isn't referenced anywhere else in the repo after this PR.

SKIP is used for pre-commit steps that are already handled in other GHAs, in this case those 2 are handled in the superset-frontend GHA.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, ok, I wasn't understanding what SKIP did, but SKIP_FIX being removed here means we can remove it in pre-commit-config.yml as well, then.

@rusackas

rusackas commented Mar 12, 2025 •

Copy link
Copy Markdown
Member

@rusackas this works for me, but is largely a rollback of #32352 in some key areas. Wondering what's wrong here.

Fine by me! It seems to just roll back the parts I wasn't really hoping to touch much in the first place :D

The things I set out to do which still seem to be in effect here are:

  • Run eslint with the --quiet flag
  • Set up/ensure Node 20
  • Bump mypy to 1.15.0

With this change, we lose two things, which maybe we can fix here or in subsequent PR(s):

  • Reverts typescript checking (which led to 95% of my last PR's contents). I'm sure we can add a new hook for that. It was catching these since npm run type slides in as a side-run task of npm run lint :)
  • Prettier is currently fixing busted files when running the hooks locally, but eslint no longer is. I wonder if we should always run with the --fix flag, or if that needs to be somehow dynamically disabled on CI and only run locally ¯\_(ツ)_/¯

Otherwise, just a couple of loose ends in the code to contend with in threads above.

@mistercrunch

Copy link
Copy Markdown
Member Author

Reverts typescript checking

From my understanding it's still here -> https://github.com/apache/superset/pull/32596/files#diff-63a9c44a44acf85fea213a857769990937107cf072831e1a26808cfde9d096b9R77-R83

Prettier is currently fixing busted files when running the hooks locally, but eslint no longer is

Can add --fix in there, super easy. It's probably better that way. Personally before I would run a custom command to try and do it, but it's probably a better behavior to always --fix, let me add it to the PR here.

@mistercrunch

Copy link
Copy Markdown
Member Author

Here, added --fix -> ac7fd7e

@rusackas

Copy link
Copy Markdown
Member

Thanks for --fixing.

Once the last remnant of SKIP_FIX is gone, you've got my stamp.

I'll tackle TS checking in a separate PR (it'd be nice, but not blocking this)

Up to you if you want to ditch that archived GHA inclusion or not for this PR, or handle that separately. More of a TODO than a blocker.

@mistercrunch

Copy link
Copy Markdown
Member Author

Ok removed the last SKIP_FIX reference that was there for the docs I think. pre-commit now always tries to fix what it can, which I think is what everyone wants all the time.

@mistercrunch
mistercrunch merged commit d8d4b75 into master Mar 12, 2025
@mistercrunch
mistercrunch deleted the fix_eslint_precommit branch March 12, 2025 18:26
preset-machine pushed a commit to preset-io/superset that referenced this pull request Mar 12, 2025
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
villebro added a commit to villebro/superset that referenced this pull request Oct 13, 2026
…nt the full changelog file

Comparing changelog.py's output with the published 6.0.0 and 6.1.0
changelogs showed several problems:

- A commit made with `git revert` has the subject `Revert "... (#N)"`
  and no PR number of its own, so it was read as PR #N again. 6.1.0's
  changelog lists apache#38846 twice although it was reverted on the 6.1
  branch, and because apache#38846 appears in 6.1.0's history, the 7.0.0
  changelog left it out although 7.0 includes it. Each PR's state is
  now worked out from its commits in order: reverted PRs are left out,
  and reverting a revert lands the PR again.
- PRs merged more than once were listed once per merge (apache#31998, apache#32596
  and apache#33205 in 6.0.0's changelog). They're listed once.
- Logins were looked up by git author name, using the first PR seen
  for that name, so one person's revert of another's PR credited all
  of the reverter's later PRs to the other person. Each PR is credited
  to its own author.
- The heading named the git ref (`### 6.0` in 6.0.0's changelog), and
  release managers added the license header, `## Change Log` and blank
  lines by hand. The command prints the complete CHANGELOG/<version>.md
  file, naming --release_version or SUPERSET_VERSION in the heading, and
  sends its progress output to stderr.

A PR GitHub no longer serves is listed with its commit author's login
and its subject without the `(#N)` suffix, so it needs no hand edits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code preset-io size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants