Skip to content

perf: code quality: enable Biome linter, expand ruff rules, fix lint issues#82

Merged
laurigates merged 3 commits intomasterfrom
claude/improve-code-quality-E03bB
Mar 26, 2026
Merged

perf: code quality: enable Biome linter, expand ruff rules, fix lint issues#82
laurigates merged 3 commits intomasterfrom
claude/improve-code-quality-E03bB

Conversation

@laurigates
Copy link
Member

Frontend:

  • Enable Biome linter with recommended rules (was disabled)
  • Configure jsxRuntime as reactClassic for proper React import handling
  • Auto-fix: type-only imports, == to ===, template literals, optional chaining,
    unused imports, let-to-const, literal keys, date constructors
  • Manual fixes: remove unused variables, add alt text, button types,
    proper TypeScript types replacing any, remove empty destructuring patterns,
    replace <></> with null, fix empty type aliases
  • Set error level for correctness rules, warn level for style/a11y for gradual cleanup

Backend:

  • Add PERF, PLE, PLW, PGH, FLY, FURB, PIE rule sets to ruff config
  • Auto-fix: unused noqa directives, import sorting
  • Fix explicit return in init methods (PLE0101)
  • Add noqa for intentional wildcard import in local_settings
  • Suppress RUF012 (mutable class variables) - too noisy for Django models
  • Add migration-specific ignores for T20, PERF, ARG001

Infrastructure:

  • Add biome lint step to just lint-frontend recipe

https://claude.ai/code/session_01V3hbn1ExGmpbJZrzF6zCs3

claude added 2 commits March 26, 2026 16:09
…t issues

Frontend:
- Enable Biome linter with recommended rules (was disabled)
- Configure jsxRuntime as reactClassic for proper React import handling
- Auto-fix: type-only imports, == to ===, template literals, optional chaining,
  unused imports, let-to-const, literal keys, date constructors
- Manual fixes: remove unused variables, add alt text, button types,
  proper TypeScript types replacing `any`, remove empty destructuring patterns,
  replace `<></>` with null, fix empty type aliases
- Set error level for correctness rules, warn level for style/a11y for gradual cleanup

Backend:
- Add PERF, PLE, PLW, PGH, FLY, FURB, PIE rule sets to ruff config
- Auto-fix: unused noqa directives, import sorting
- Fix explicit return in __init__ methods (PLE0101)
- Add noqa for intentional wildcard import in local_settings
- Suppress RUF012 (mutable class variables) - too noisy for Django models
- Add migration-specific ignores for T20, PERF, ARG001

Infrastructure:
- Add biome lint step to `just lint-frontend` recipe

https://claude.ai/code/session_01V3hbn1ExGmpbJZrzF6zCs3
@github-actions github-actions bot changed the title Improve code quality: enable Biome linter, expand ruff rules, fix lint issues perf: code quality: enable Biome linter, expand ruff rules, fix lint issues Mar 26, 2026
Copy link

@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 updates project dependencies, including a version bump for olmap and olmap_ui, and updates several Sentry packages. It also enhances the linting configuration by adding new rules to ruff and enabling biome for the frontend. Additionally, it cleans up various unused arguments in Python methods and improves TypeScript type imports. I have identified several critical issues where removing import React from 'react' breaks the build due to the reactClassic JSX runtime configuration, and I have provided feedback on improving unused argument handling.

@@ -1,4 +1,3 @@
import React from 'react';
import { render } from '@testing-library/react';

Choose a reason for hiding this comment

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

critical

The jsxRuntime is set to reactClassic in biome.json, which requires React to be in scope when using JSX. Since this file uses JSX (<App />), removing the import React from 'react'; statement will cause a 'React is not defined' error. This import should be restored.

Suggested change
import { render } from '@testing-library/react';
import React from 'react';
import { render } from '@testing-library/react';

@@ -1,5 +1,3 @@
import React from 'react';

const UpdateWay = ({ changesetId, way }) => (

Choose a reason for hiding this comment

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

critical

The jsxRuntime is set to reactClassic in biome.json, which requires React to be in scope when using JSX. Removing the import React from 'react'; statement will cause a 'React is not defined' error. This import should be restored.

import React from 'react';

const UpdateWay = ({ changesetId, way }) => (

@@ -1,5 +1,3 @@
import React from 'react';

const UpdateNode = ({ changesetId, node, tags }) => (

Choose a reason for hiding this comment

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

critical

The jsxRuntime is set to reactClassic in biome.json, which requires React to be in scope when using JSX. Removing the import React from 'react'; statement will cause a 'React is not defined' error. This import should be restored.

import React from 'react';

const UpdateNode = ({ changesetId, node, tags }) => (

@@ -1,5 +1,3 @@
import React from 'react';

const CreateWay = ({ changesetId, way }) => (

Choose a reason for hiding this comment

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

critical

The jsxRuntime is set to reactClassic in biome.json, which requires React to be in scope when using JSX. Removing the import React from 'react'; statement will cause a 'React is not defined' error. This import should be restored.

import React from 'react';

const CreateWay = ({ changesetId, way }) => (

@@ -1,5 +1,3 @@
import React from 'react';

const CreateNode = ({ changesetId, lon, lat, tags }) => (

Choose a reason for hiding this comment

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

critical

The jsxRuntime is set to reactClassic in biome.json, which requires React to be in scope when using JSX. Removing the import React from 'react'; statement will cause a 'React is not defined' error. This import should be restored.

import React from 'react';

const CreateNode = ({ changesetId, lon, lat, tags }) => (

@with_parameters(["name"])
@action(methods=["GET"], detail=False)
def search(self, request, *args, **kwargs): # noqa: ARG002
def search(self, request, *args, **kwargs):

Choose a reason for hiding this comment

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

medium

The *args and **kwargs arguments are unused. They should be removed from the method signature to avoid ARG002 errors and improve clarity.

Suggested change
def search(self, request, *args, **kwargs):
def search(self, request):

field_class = serializers.PrimaryKeyRelatedField

def convert(self, field): # noqa: ARG002
def convert(self, field):

Choose a reason for hiding this comment

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

medium

The field argument is unused in this method. To signal that it's intentionally unused and to satisfy the ARG002 linting rule, you should prefix it with an underscore. This is a common Python convention and is cleaner than using a noqa comment.

This feedback applies to the convert methods in StringRelatedFieldConverter, HyperlinkedRelatedFieldConverter, and SlugRelatedFieldConverter as well.

Suggested change
def convert(self, field):
def convert(self, _field):

Comment on lines 1 to +3
from .map_feature_tests import *
from .osm_image_notes_tests import *
from .rest_tests import *

Choose a reason for hiding this comment

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

medium

Wildcard imports (from ... import *) are generally discouraged as they make it unclear which names are present in the namespace. This can lead to confusion and make the code harder to read and maintain. It seems the linter configuration now flags this (F403).

If these wildcard imports are necessary for the test suite setup, you should add a # noqa: F403 comment to each line to explicitly suppress the linting error. However, a better long-term solution would be to explicitly import the required names from each test module.

Suggested change
from .map_feature_tests import *
from .osm_image_notes_tests import *
from .rest_tests import *
from .map_feature_tests import * # noqa: F403
from .osm_image_notes_tests import * # noqa: F403
from .rest_tests import * # noqa: F403



def ready_check(request): # noqa: ARG001
def ready_check(request):

Choose a reason for hiding this comment

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

medium

The request argument is unused. To signal this and comply with the ARG001 linting rule, you should prefix it with an underscore.

Suggested change
def ready_check(request):
def ready_check(_request):



def health_check(request): # noqa: ARG001
def health_check(request):

Choose a reason for hiding this comment

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

medium

The request argument is unused. To signal this and comply with the ARG001 linting rule, you should prefix it with an underscore.

Suggested change
def health_check(request):
def health_check(_request):

@laurigates
Copy link
Member Author

Let's address the recommendations in the comments. Evaluate which pieces of criticism and recommendations are substantive and valid. Act accordingly and refute invalid points.
@claude

@claude
Copy link

claude bot commented Mar 26, 2026

Claude finished @laurigates's task in 3m 31s —— View job


Review Comment Evaluation & Fixes

  • Gather context and evaluate all review comments
  • Fix unused parameter naming (health.py, converters.py, osm_image_note.py)
  • Push changes

Invalid Comments (Refuted)

"Critical": React import removals in .jsx/.js files

The reviewer's concern is incorrect. This project uses React 18 + react-scripts 5.0.1 (CRA), which uses Babel with the automatic JSX transformimport React is not required for JSX compilation. tsconfig.json's "jsx": "react" only affects TypeScript's type-checking of .tsx files; CRA's Babel compiles all JSX independently using runtime: "automatic". The jsxRuntime: "reactClassic" setting in biome.json is purely a linting hint telling Biome not to flag existing React imports as unused — it has no bearing on how Babel transforms JSX at build time. The removed imports in .jsx/.js files are correct.

Medium: Remove *args, **kwargs from detail=True action methods

DRF's dispatch calls action handlers as handler(request, *args, **kwargs) where pk is passed in kwargs for detail=True actions. Removing **kwargs from mark_reviewed, mark_accepted, mark_processed, hide_note, upvote, downvote, mark_seen would cause a TypeError at runtime when DRF passes the URL kwargs. These signatures must stay as-is.


Valid Fixes Implemented

Commit c845178:

  • health.py: Renamed request_request in health_check and ready_check (ARG001 — signals intentional non-use)
  • converters.py: Renamed field_field in StringRelatedFieldConverter, HyperlinkedRelatedFieldConverter, SlugRelatedFieldConverter (ARG002)
  • osm_image_note.py: Removed misleading pk=None parameter from map_feature_schemas (which is a detail=False action — DRF never passes a pk)

- Rename request -> _request in health_check and ready_check (ARG001)
- Rename field -> _field in StringRelatedField, HyperlinkedRelatedField,
  SlugRelatedField converters (ARG002)
- Remove spurious pk=None from map_feature_schemas (detail=False action)

Co-authored-by: Lauri Gates <laurigates@users.noreply.github.com>
@laurigates laurigates merged commit 8916a7a into master Mar 26, 2026
@laurigates laurigates deleted the claude/improve-code-quality-E03bB branch March 26, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants