Skip to content

linter: typescript-eslint(no-useless-default-assignment) unsafe fix #21716

@H4ad

Description

@H4ad

What version of Oxlint are you using?

1.61.1

What command did you run?

oxlint --fix

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": [
    "typescript"
  ],
  "categories": {
    "correctness": "warn"
    // TODO: Eventually turn this to error, and enable other categories
  },
  "env": {
    "builtin": true,
    "es2021": true,
    "browser": true,
    "jest": true,
    "node": true
  },
  "options": {
    "typeAware": true,
    "typeCheck": false
  },
  "settings": {
    "react": {
      "version": "18.2.0"
    }
  }
}

What happened?

Before:

export const DEFAULT_TIME_RANGE = '30m';

export interface CreatePublicDashboardProps {
	dashboardId: string;
	timeRangeEnabled: boolean;
	defaultTimeRange: string;
}

const createPublicDashboard = async (
	props: CreatePublicDashboardProps,
) => {
    const { dashboardId, timeRangeEnabled = false, defaultTimeRange = DEFAULT_TIME_RANGE } = props;
};

After:

export const DEFAULT_TIME_RANGE = '30m';

export interface CreatePublicDashboardProps {
	dashboardId: string;
	timeRangeEnabled: boolean;
	defaultTimeRange: string;
}

const createPublicDashboard = async (
	props: CreatePublicDashboardProps,
) => {
    const { dashboardId, timeRangeEnabled, defaultTimeRange } = props;
};

This is not exactly a bug since the type says the value can't be undefined but at same time should not be a safer fix since it still can be undefined since there's nothing guarantees the string is not undefined.

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions