oxc icon indicating copy to clipboard operation
oxc copied to clipboard

Oxlint doesn't follow `extends` directive in .eslintrc.json

Open sergi opened this issue 1 year ago • 6 comments

Given a .eslint.json file like this:

{
    "extends": "../.eslintrc.json",
    "rules": {
        "no-console": "error",
        "brace-style": "off"
    }
}

Oxlint will only check for these two rules, ignoring all the parent rules from ../.eslintrc.json.

Running oxlint with the following command:

oxlint --symlinks -c ../.eslintrc.json -A unicorn --deny-warnings --tsconfig ./tsconfig.json .

sergi avatar May 20 '24 10:05 sergi

I think this is known. Couldn't find it in the docs but I remembered reading it here.

todor-a avatar May 20 '24 18:05 todor-a

I'm in the process of setting up json schema, it will solve the discoverability issue.

As for supporting extends, I think it's valuable so I'll keep this feature request open.

Boshen avatar May 21 '24 02:05 Boshen

@Boshen I can implement the extends resolution; Last night I actually did some work on it; But it seems like we are changing the ESLintConfig load process which would conflict with my changes.

I was planning to create an ESLintConfigBuilder that would resolve the stuff after deserialization and build an ESLintConfig.

I don't know the scope of changes in #3355; So let me know whether I should wait for you to merge those changes, start stacking on top of it; Or ignore it and let you merge with it.

Of course, I can also put a pin in it if you don't find it necessary at the moment.

rzvxa avatar May 21 '24 06:05 rzvxa

@Boshen I can implement the extends resolution; Last night I actually did some work on it; But it seems like we are changing the ESLintConfig load process which would conflict with my changes.

I was planning to create an ESLintConfigBuilder that would resolve the stuff after deserialization and build an ESLintConfig.

I don't know the scope of changes in #3355; So let me know whether I should wait for you to merge those changes, start stacking on top of it; Or ignore it and let you merge with it.

Of course, I can also put a pin in it if you don't find it necessary at the moment.

I'm currently working on json schema support using the schematic crate, there is a automatic extends support https://moonrepo.github.io/schematic/config/struct/extend.html I wanna try.

I'll let you know once it's done.

Boshen avatar May 21 '24 07:05 Boshen

@Boshen I can implement the extends resolution; Last night I actually did some work on it; But it seems like we are changing the ESLintConfig load process which would conflict with my changes. I was planning to create an ESLintConfigBuilder that would resolve the stuff after deserialization and build an ESLintConfig. I don't know the scope of changes in #3355; So let me know whether I should wait for you to merge those changes, start stacking on top of it; Or ignore it and let you merge with it. Of course, I can also put a pin in it if you don't find it necessary at the moment.

I'm currently working on json schema support using the schematic crate, there is a automatic extends support https://moonrepo.github.io/schematic/config/struct/extend.html I wanna try.

I'll let you know once it's done.

It seems nice, especially if we somehow get to pass the eslintrc path to resolve relative extends. That's the main reason I've tried it with a builder, When we deserialize string directly (for example for test runners) we don't get to resolve relative extends.

rzvxa avatar May 21 '24 08:05 rzvxa

What's the status of this issue? were you able to take advantage of extends support in schematic?

sergi avatar Sep 13 '24 12:09 sergi

.oxlintrc.json now supports the extends keyword in https://github.com/oxc-project/oxc/issues/9307. Something like this from the original example will work:

// .oxlintrc.json
{
    "extends": ["../.eslintrc.json"],
    "rules": {
      // ...
    }
}

camchenry avatar Mar 13 '25 02:03 camchenry