feat(lint): adopt @constructive-io/eslint-config and fix repo-wide lint - #1570
Merged
Conversation
ESLint 9 only reads flat config, so pnpm lint has been failing repo-wide since the eslint 8 -> 9 bump. Replaces .eslintrc.json with an eslint.config.mjs on top of the shared package, plus repo-local ignores for codegen output and a few rule relaxations for idioms this repo relies on.
Mechanical output of `eslint . --fix` under the new flat config: indentation, import sorting, unused-import removal. No behavior changes.
Semantics-preserving: Object.prototype.hasOwnProperty.call() instead of direct hasOwnProperty access, redundant regex escapes dropped, comments in empty blocks, a dead `info.version;` expression removed, and two targeted eslint-disable comments (this-alias in a test fixture, async promise executor in s3-utils download).
Ignoring all of sdk/*/src left sdk/migrate-client with nothing to lint, which eslint treats as an error.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
graphql/codegen/src/core/codegen/templates/* are read verbatim at codegen time and written into generated clients, so import sorting there changes generated output and breaks client-generator snapshots.
They hold codegen output snapshots and standalone sqitch/pgpm fixture projects that tests compare against; reformatting them is churn at best and a test failure at worst.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
pnpm linthas been failing repo-wide since the eslint 8→9 bump (eslint 9 only reads flat config; we only shipped.eslintrc.json). This consumes the shared flat config published fromdev-utils(constructive-io/dev-utils#98) and getspnpm lintto exit 0..eslintrc.jsonis deleted;eslint.config.mjsis the shared array plus repo-local adjustments. The bulk of the diff is one mechanicaleslint . --fixcommit (indentation + import sorting), kept separate from the config commit and from the ~20 files that needed a human.Deviations from a literal port of
.eslintrc.jsoncomma-dangle: ['error', 'never']is dropped. It produced 57,145 errors — the codebase uses trailing commas essentially everywhere, and.prettierrc.jsonsetstrailingComma: 'es5', so the rule and the formatter have been in direct contradiction (invisibly, since lint never ran). Prettier owns trailing commas now. If you'd rather enforcenever, that's a separate mass-reformat, and prettier config has to change with it.Generated and verbatim-copied files are ignored. Linting them is churn the next
pnpm generatereverts — and in two cases it actually changes behavior:sdk/{constructive-cli,constructive-react,constructive-sdk}/src,sdk/migrate-client/src/migrate,**/__generated__/**,**/*.generated.ts,postgres/pg-ast/src/{asts,wrapped}.ts(~50k of the original errors)graphql/codegen/src/core/codegen/templates/**— these are read verbatim at codegen time and written into every generated client, so import sorting there silently changes generated output (it broke theclient-generatorsnapshots)**/__fixtures__/**— codegen output snapshots and standalone sqitch/pgpm fixture projects that tests compare againstThe sdk ignore is per-package rather than
sdk/*/src/**: the latter leftsdk/migrate-clientwith zero lintable files, which eslint treats as an error.Rules turned off for idioms this repo relies on:
no-namespace(declare global { namespace Grafast { ... } }),no-unsafe-function-type(Functionin plugin/callback signatures),no-empty-object-type(StrictSelect<S, Shape> = ... ? {} : never). Scoped:no-control-regexoff forpgpm/logger,no-unused-expressionsoff for**/*.type-test.ts.linterOptions.reportUnusedDisableDirectives: 'off'. Worth knowing about: eslint 9 defaults it towarn, and--fixdeletes disable comments it considers unused — including/* eslint-disable @typescript-eslint/no-empty-object-type */at the top of a generated file, leaving a stray blank line the generator would re-add. Turning it off leaves ~30 existing directives intact.Hand fixes (all semantics-preserving)
plus comments in empty
catch {}/finally {}blocks, and two targeted disables (no-this-aliasinMigrateTestFixture,no-async-promise-executorins3-utilsdownload— the executor is genuinely async and rewriting it is out of scope for a lint PR).Verified
pnpm lint→ 0 errors / 191 warnings (allno-unused-vars, warn by design).pnpm buildclean, full CI green.Follow-up
CI doesn't run lint — which is exactly why this rotted for a whole major version. Adding a lint job to
run-tests.yamlis the thing that keeps it fixed.Link to Devin session: https://app.devin.ai/sessions/3b5f5e76ddc74eda83a3543d7da2c75f
Requested by: @pyramation