1.0.1 • Published 4 months ago

typify-eslint-rules v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

typify-eslint-rules

Why

This package allows you to generate typescript types for any ESLint rules based on their meta schema

Install

Using pnpm:

pnpm install 

Using npm:

npm install 

Usage

import { typify } from 'typify-eslint-rules'

import tsPlugin from '@typescript-eslint/eslint-plugin'

const { rules: tsRules } = tsPlugin

await typify(tsRules, {
  distFolder: 'dist'
})

This will generate types for @typescript-eslint/eslint-plugin and place them in dist/rules folder, which are exported in dist/index.d.ts file under RuleOptions type:

// dist/index.d.ts

import type { AdjacentOverloadSignatures } from './rules/adjacent-overload-signatures'
// ... more imports

export type RuleOptions = {
  'adjacent-overload-signatures': AdjacentOverloadSignatures,
  // ... more rules
}

You can also provide an optional prefix:

// ...

await typify(tsRules, {
  distFolder: 'dist',
  rulesPrefix: 'ts/'
})

That prefix will be added to all rules:

// dist/index.d.ts

import type { AdjacentOverloadSignatures } from './rules/adjacent-overload-signatures'
// ... more imports

export type RuleOptions = {
  'ts/adjacent-overload-signatures': AdjacentOverloadSignatures,
  // ... more rules
}

You can also use compileRule and compileSchema to compile a sole rule or a sole schema.

1.0.1

4 months ago

1.0.0

4 months ago

0.0.1

4 months ago