Description
Before You File a Documentation Request Please Confirm You Have Done The Following...
- I have looked for existing open or closed documentation requests that match my proposal.
- I have read the FAQ and my problem is not listed.
Suggested Changes
typescript-eslint has some great documentation and utils to write a custom linting rule 👍 The first line reads "custom ESLint rules generally work the same way for JavaScript and TypeScript code", so the plugin docs from eslint are a good starting point. However, it still left me with some questions around how to utilize such a rule in a project.
Writing custom rules on top of typescript-eslint might not be incredibly common, so I don't expect there to be a extremely detailed step-by-step guide. But I think some pointers around the questions listed below would be a great addition to the documentation:
- Can the
rule
from the code snippet in the documentation be directly consumed in your eslint config, or does it need to be wrapped in a plugin?- my guess is this is generally the same as eslint, but is anything like "Runtime Rules" also possible?
- Do rules need to be compiled to JS before being usable?
- my assumption is yes, but this was optional in
tslint
if you utilizedts-node
. So it would be nice to mention this explicitly.
- my assumption is yes, but this was optional in
- What tsconfig is recommended when compiling a rule?
- I tried copying configuration from the
@typescript-eslint/eslint-plugin
package (given that one contains the rules). Not all of it seems to be relevant for creating rules though
- I tried copying configuration from the
- If you want to publish a package with a rule:
- are there package naming recommendations on top of the naming instructions from eslint itself?
- should
typescript
and@typescript-eslint/***
packages be part of your (peer/dev-)dependencies?
This list is not intended as a literal proposal of questions that should all be addressed in the docs. Rather they're meant as examples of a topic that I think could use some clarification. Even referencing an example repo with a good setup would already help. Alternatively, there's interest in having a generator similar to eslint/generator-eslint. There's an open issue to create a TypeScript template, but at this moment it seems unclear if they want to move forward with that.