Skip to content

feat: configure eslint lines-between-class-members rule repository-wide#1474

Closed
josemontespg wants to merge 19 commits into
google:mainfrom
josemontespg:eslint-lines-between-class-members
Closed

feat: configure eslint lines-between-class-members rule repository-wide#1474
josemontespg wants to merge 19 commits into
google:mainfrom
josemontespg:eslint-lines-between-class-members

Conversation

@josemontespg
Copy link
Copy Markdown
Collaborator

@josemontespg josemontespg commented May 20, 2026

Configure eslint lines-between-class-members rule repository-wide

This PR configures ESLint with the lines-between-class-members rule (requiring empty lines between class members) repository-wide.

Key Changes:

  1. Configured existing ESLint projects (web_core, react, composer) to include the rule.
  2. Set up new ESLint Flat Configurations with Google's GTS style guide for all other TypeScript packages that lacked linting (angular, lit, markdown-it, editor, inspector).
  3. Configured the quotes rule in all configs to allow backticks (template literals) for standard string literals.
  4. Ran formatting/linting repository-wide to align all files with the new rules.
  5. Added ESLint verification steps to all corresponding GitHub Actions CI workflows (ng_build_and_test.yml, lit_build_and_test.yml, editor_build.yml, inspector_build.yml) to ensure the rules are fully enforced on push/PR.

Fixed #1473

- Set up ESLint configs with Google GTS style guide for all TypeScript projects (angular, lit, markdown-it, editor, inspector).
- Enabled the lines-between-class-members rule to enforce blank lines between class members across all packages.
- Configured quotes rule to allow backtick template literals for any string literals.
- Formatted all source files repository-wide.
- Added ESLint execution steps to all corresponding CI workflows to enforce linting repository-wide on push/PR.

TAG=agy
CONV=2a56c296-3b1f-4e6d-9e4a-5b15e8a7504c
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements gts (Google TypeScript Style) linting across multiple packages, including angular, lit, markdown-it, editor, and inspector, while adding custom ESLint rule overrides for class member spacing and quote styles. Feedback suggests centralizing these duplicated configurations at the repository root to improve maintainability. Additionally, it is recommended to use TypeScript-aware versions of class member rules to correctly handle method overloads and to ensure custom overrides are placed before the Prettier configuration in the React package to prevent formatting conflicts.

Comment thread renderers/angular/eslint.config.js Outdated
Comment thread renderers/angular/eslint.config.js Outdated
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'lines-between-class-members': ['error', 'always', {exceptAfterSingleLine: true}],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For TypeScript projects, the base ESLint rule lines-between-class-members is unaware of TS-specific constructs like method overloads. This can lead to incorrect lint errors when overloads are grouped together without empty lines. It is generally recommended to use a TypeScript-aware version of this rule (such as the one provided by @typescript-eslint/eslint-plugin or @stylistic/eslint-plugin-ts) which correctly handles these cases.

Comment thread renderers/react/eslint.config.js
- Replaced the standard lines-between-class-members rule with @stylistic/lines-between-class-members in all 8 configuration files to correctly support TypeScript method overloads.
- Installed @stylistic/eslint-plugin in all package devDependencies.
- Renamed angular eslint config to eslint.config.mjs to resolve ESM node parsing warnings.
- Ran auto-formatting and linter verification across all projects.

TAG=agy
CONV=2a56c296-3b1f-4e6d-9e4a-5b15e8a7504c
- Placed custom rule overrides before prettierConfig to maintain Prettier compatibility and avoid quote conflicts.
- Let Prettier format all ESLint config files.

TAG=agy
CONV=2a56c296-3b1f-4e6d-9e4a-5b15e8a7504c
…g ts-ignore comments

- Added Google LLC Apache 2.0 license headers to all 5 newly created ESLint configurations to satisfy check-license.
- Restored // @ts-ignore (along with eslint-disable-next-line @typescript-eslint/ban-ts-comment) in angular v0.8 and v0.9 markdown files to fix Unused @ts-expect-error compiler build errors in CI.

TAG=agy
CONV=2a56c296-3b1f-4e6d-9e4a-5b15e8a7504c
…ures

- Regenerated all 8 package-lock.json files from the public registry to ensure they are 100% in sync with their updated package.json files, resolving the npm ci sync failures in GitHub Actions.

TAG=agy
CONV=2a56c296-3b1f-4e6d-9e4a-5b15e8a7504c
- Fixed all spacing violations in editor.ts, drawable-canvas.ts, and item-select.ts.
- Removed unused import repeat in inspector.ts.
- Renamed all remaining newly created eslint configs (lit, markdown-it, editor, inspector) to eslint.config.mjs to resolve ESM Node parsing warnings in CI.

TAG=agy
CONV=2a56c296-3b1f-4e6d-9e4a-5b15e8a7504c
- Added @angular/common and @angular/platform-browser directly to devDependencies of renderers/angular package.json.
- Added --legacy-peer-deps flag to build:renderer npm install script in samples/client/angular/package.json to ensure safe peer resolution in CI environment.
- Regenerated corresponding package-lock.json files to ensure they are in sync.

TAG=agy
CONV=2a56c296-3b1f-4e6d-9e4a-5b15e8a7504c
- Configured the Install top-level deps step in ng_build_and_test.yml to use --legacy-peer-deps, resolving the strict peer dependency version mismatch failures on Angular common/core package resolution in CI.

TAG=agy
CONV=2a56c296-3b1f-4e6d-9e4a-5b15e8a7504c
…in CI

- Pinned all core @angular/* packages in renderers/angular/package.json to the exact same version (21.2.5) to eliminate the ERESOLVE peer dependency mismatches.
- Regenerated lockfiles for React, Angular, and Composer to completely align and synchronize all dependencies.
- Cleaned up unused imports across the Lit renderer codebase identified by the newly enforced linter.

TAG=agy
CONV=2a56c296-3b1f-4e6d-9e4a-5b15e8a7504c
…nc lockfiles

- Added eslint and typescript-eslint explicitly to renderers/angular, renderers/lit, renderers/markdown, and tools/editor to fix 'Cannot find module '\''eslint'\''' errors during GTS linting in CI.
- Updated pnpm-lock.yaml in tools/composer to synchronize dependencies after adding @stylistic/eslint-plugin.
- Re-generated and synchronized package-lock.json files across all modified packages.

TAG=agy
CONV=cce8fafa-0d7c-484f-83ea-e99a1339f6fc
@josemontespg josemontespg force-pushed the eslint-lines-between-class-members branch from 98a9b1c to 0332afb Compare May 20, 2026 23:29
@josemontespg josemontespg force-pushed the eslint-lines-between-class-members branch from febb309 to de91811 Compare May 20, 2026 23:57
@josemontespg
Copy link
Copy Markdown
Collaborator Author

This approach works, but makes the formatter CI script much slower, because it has to run npm install on every project, then run the eslint.

This is a limitation of eslint. Until we figure out a way to run this in a quick way O(10s), I don't think we should include it in CI

@github-project-automation github-project-automation Bot moved this from Todo to Done in A2UI May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Configure eslint on all typescript projects in the repo

1 participant