cletusw / eslint-plugin-local-rules

A plugin for ESLint that allows you to use project-specific rules
MIT License
161 stars 9 forks source link

Typescript support #13

Closed coolassassin closed 2 years ago

coolassassin commented 2 years ago

How can i do same thing but with typescript?

cletusw commented 2 years ago

This plugin just looks for an eslint-local-rules.js file that exports a rules property, so your file should be able to register ts-node, require a .ts file, then re-export its result. Let me know how that goes and if it works I can add a note to the README!

RobinTail commented 1 year ago

@coolassassin && @cletusw ⬇️

// eslint-local-rules/index.js
require("ts-node").register({ transpileOnly: true });
module.exports = require("./rules").default;
// eslint-local-rules/rules.ts
import { Rule } from "eslint";

export default {
  "my-rule": {
    meta: {
      // ...
    },
    create: (context) => ({
      // ...
    }),
  },
} satisfies Record<string, Rule.RuleModule>;