Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match typescript-extended rules inside rules block - buildFromOxlintConfig #228

Open
Sysix opened this issue Nov 5, 2024 · 2 comments · May be fixed by #238
Open

match typescript-extended rules inside rules block - buildFromOxlintConfig #228

Sysix opened this issue Nov 5, 2024 · 2 comments · May be fixed by #238

Comments

@Sysix
Copy link
Collaborator

Sysix commented Nov 5, 2024

Some of the typescript-extended rules are inherently supported by oxlint and thus are only advertised as a single rule.
It's a bit annoying having to match rules when they are different names.

Originally posted by @drvn-mr in #226 (comment)

@drvn-mr
Copy link

drvn-mr commented Nov 8, 2024

I should've provided an example but I have a script parsing the oxlint --rules output to match our rules.
This comes out for rules that are in both eslint and @typescript-eslint, for which only a single rule exists in oxlint:

{
  "@typescript-eslint/default-param-last": "default-param-last",
  "@typescript-eslint/no-array-constructor": "no-array-constructor",
  "@typescript-eslint/no-empty-function": "no-empty-function",
  "@typescript-eslint/no-unused-vars": "no-unused-vars",
  "@typescript-eslint/no-useless-constructor": "no-useless-constructor"
}

I'm not sure if they are currently aliased somehow, so I've renamed them to the oxlint equivalent in the config file.
Some of them also don't mention typescript support in the documentation.

@Sysix
Copy link
Collaborator Author

Sysix commented Nov 8, 2024

oh your use case is fixed with #231.

I found another use case which is not supported:

  it('disables matching typescript and eslint rules', () => {
    for (const rule in [
      'no-unused-vars',
      '@typescript-eslint/no-unused-vars',
    ]) {
      const rules = buildFromOxlintConfig({
        rules: {
          [rule]: 'warn',
        },
      });

      expect(rules.length).toBe(1);
      expect(rules[0].rules).not.toBeUndefined();
      expect('no-unused-vars' in rules[0].rules!).toBe(true);
      expect('@typescript-eslint/no-unused-vars' in rules[0].rules!).toBe(true);
    }
  });

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 a pull request may close this issue.

2 participants