oxc icon indicating copy to clipboard operation
oxc copied to clipboard

linter: `extends` should resolve the path to workspace package

Open Miodec opened this issue 8 months ago • 2 comments

What version of Oxlint are you using?

0.16.6

What command did you run?

both cli and vsc extension

What does your .oxlintrc.json config file look like?

{
  "extends": [
    // "../packages/oxlint-config/index.json",
    "@monkeytype/oxlint-config"
  ],
  "overrides": [
    {
      "files": ["__tests__/**"],
      "plugins": ["jest", "vitest"],
      "rules": {
        // "no-unused-vars": "off"
      }
    }
  ]
}

What happened?

When trying to use monorepo local workspace packages, the path is not resolved correctly (in ESLint this works fine).

This doesn't work - when switching these around, everything works as expected.

  "extends": [
    // "../packages/oxlint-config/index.json",
    "@monkeytype/oxlint-config"
  ],

Verified its installed as a dev dependency: Image

The file is exported (yes, its called index.json) Image

Not working Image

Working (unused var is now an error) Image

Miodec avatar Apr 14 '25 11:04 Miodec

This is explicit behavior for the moment, we decided not to add any resolution to the config file paths initially because it is faster and simpler. For now, you can specify the file path explicitly. I'll leave this issue open for discussion though.

camchenry avatar Apr 14 '25 17:04 camchenry

This is explicit behavior for the moment, we decided not to add any resolution to the config file paths initially because it is faster and simpler. For now, you can specify the file path explicitly. I'll leave this issue open for discussion though.

It would be a nice-to-have to support both fast relative path and slower resolved paths. In large mono-repos if the base config ever changes path, you would need to update .oxlintrc.json in every package.

Unless the performance hit would be felt on every run, then i guess im fine with that.

Miodec avatar Apr 16 '25 13:04 Miodec

It's much easier to create a template package when the configs are also packages and the paths resolved. I would love to see this!

krispya avatar Jun 08 '25 23:06 krispya

Also, would plugins require this anyways? Since the JSON would need to resolve the path to the installed package? https://github.com/oxc-project/oxc/issues/9905

krispya avatar Jun 09 '25 01:06 krispya

In our case, we have a shared standards package where we export common base configurations for stuff like eslint, prettier, tsconfig among others. I wanted to add the oxlint config too but ran into the same issue. We can't extend a package.

I think we should either allow the JSON to resolve paths or allow programatic configurations (.ts/.js files) so we can resolve this ourselves.

ConsoleTVs avatar Jul 03 '25 12:07 ConsoleTVs

I am doing this too. As an ugly workaround you can have the path go directly to node_modules.

{
	"extends": ["node_modules/@config/oxlint/base.json"]
}

krispya avatar Jul 03 '25 13:07 krispya