Skip to content

linter: no-map-spread applies Object.assign wrongly #22954

@posva

Description

@posva

What version of Oxlint are you using?

1.68.0

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": ["unicorn", "typescript", "oxc"],
  "categories": {
    "correctness": "error",
    "suspicious": "off",
    "nursery": "off",
    "pedantic": "off",
    "perf": "warn",
    "style": "off",
  },
  "rules": {
    "no-control-regex": "off",
    "no-dupe-class-members": "error",
    "unicorn/no-useless-spread": "off",
    "no-console": ["error", { "allow": ["warn", "error"] }],
    "numeric-separators-style": "warn",
    "curly": ["error", "multi-line"],
    "require-post-message-target-origin": "off",
  },
  "env": {
    "builtin": true,
  },
  "globals": {},
  "ignorePatterns": [
  ],
}

What happened?

if you lint --fix this code:

  head.push({
    link: [
      ...assets.css.map((attrs: any) => ({ rel: 'stylesheet', ...attrs })),
      ...assets.js.map((attrs: any) => ({ rel: 'modulepreload', ...attrs })),
    ],
    script: [{ type: 'module', src: clientAssets.entry }],
  })

the second spread gets transformed to an Object.assign() but it changes nothing

  head.push({
    link: [
      ...assets.css.map((attrs: any) => ({ rel: 'stylesheet', ...attrs })),
      ...assets.js.map((attrs: any) => (Object.assign({ rel: 'modulepreload' }, attrs))),
    ],
    script: [{ type: 'module', src: clientAssets.entry }],
  })

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