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

TS support #176

Closed
rafaelss95 opened this issue Sep 19, 2021 · 2 comments · Fixed by #197
Closed

TS support #176

rafaelss95 opened this issue Sep 19, 2021 · 2 comments · Fixed by #197

Comments

@rafaelss95
Copy link

rafaelss95 commented Sep 19, 2021

Hello ✋

I was trying to use this library in a project, but as I didn't receive any reports (even though I knew there were violations there), I decided to look at the source code and I saw that some rules like no-missing-placeholders and report-message-format (those are the rules I was most interested in, but I believe there are much more) basically depend on utils.getContextIdentifiers, which looks for module.exports or exports.create (please, correct if I'm wrong — I have no familiarity with this repository code and this assumption comes from the little I could see by looking at the code + tests), but with TS (more specifically @typescript-eslint), the rules are usually created using the following structure:

// https://github.com/timdeschryver/eslint-plugin-ngrx
export default ESLintUtils.RuleCreator(docsUrl)<Options, MessageIds>({
  meta: {
    // ...
  }
})

// https://github.com/angular-eslint/angular-eslint
export default createESLintRule<Options, MessageIds>({
  meta: {
    // ...
  }
})

// https://github.com/typescript-eslint/typescript-eslint
export default util.createRule<Options, MessageIds>({
  meta: {
    // ...
  }
})

So I wonder if the implementation could be changed to not depend specifically on module.exports or exports.create and to support these cases above as well. I really wanted to avoid redundancy and use some of the rules that already exist here instead of rewriting from scratch, but I understand if it's not within the scope of your project.

@bmish
Copy link
Member

bmish commented Sep 21, 2021

I would be in favor of supporting TypeScript rules. I guess we could just check that the first argument to the export default function call (e.g. util.createRule) has an object with create/meta.

Relatedly, we also want to support ESM rules (#157) which are similar except without the TypeScript helper.

@bmish
Copy link
Member

bmish commented Sep 27, 2021

I've opened a PR to support this #197. Will be doing more testing of it soon -- feel free to test it as well.

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