-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Provide documentation for writing eslint rules in typescript #40
Comments
If folks have any ideas on the first point, feel free to shout out. From what I could tell, theres ESTree which provides ESTree.Node, but doesn't have the addition of the JSX spec, so doesn't include any nodes like Perhaps we need to create these types? Ideally they would be usable in conjunction with the ESTree types, so that rules can be written in typescript without needing to use the ts nodes. |
i started working on this some time ago, this is ast generated from parser but it's going to take some time to finish, and right now we have migrations :> |
Thats awesome! Yeah obviously it makes sense to get the migrations done first - but this gives a good starting point for future work. Once the migrations are done, happy to help finish these off and get started on a utils package. |
# [3.1.0](JamesHenry/eslint-plugin-tslint@v3.0.0...v3.1.0) (2018-10-19) ### Bug Fixes * Tiny lint note elimination ([a731838](JamesHenry/eslint-plugin-tslint@a731838)) ### Features * Support for tslint property ([18a4afb](JamesHenry/eslint-plugin-tslint@18a4afb)), closes [#40](JamesHenry/eslint-plugin-tslint#40)
I see that the eslint-plugin package got migrated to TS, but I think we still need some docs that go beyond the main ESLint rule development docs... with some information about node types in Should these docs be written as markdown files in https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/typescript-estree/src ? |
They would probably be better suited to being in the plugin project folder. It'd probably be good to outline what we'd want to see in the docs. I can think of a few things:
|
I had to create a file with a copy of some of the type information from this project to get this to work. |
It has been a fair while since I opened this issue, and the project has come a long way. I think one thing that would be valuable is to create an example repo or yeomen generator (or similar) with a rule or two written in typescript. This would give a clear understanding of:
The complexity of the current layout of the repo means it's hard to track down which things are called where, and how simple things like testing work. |
Documentation is something we need to work on as a whole (eg #1298). I just haven't had a lot of spare time outside of general triaging, reviews and bugfixes. Similarly for people using But the same argument stands - time spent on documentation for creating an eslint plugin with TS, is "much lower impact". It's not that I don't want to - it's that I have a limited amount of time to volunteer (5-10 hours a week). I'm still figuring out how to best divvy up my time. Contributors are always onboarded already, so they would rather fix bugs blocking them, or add features they need, rather than contributing docs for others... I'll see if I can spend some time this month on it all. I'm on PTO from work, so I've got a bit more time on my hands. |
Yep, that all makes sense - and I expect I'll feel much the same once I'm onboarded 😆 Once I figure things out, happy to make a demo repo with a simple rule and test if that is helpful! |
I am a little curious, I have been trying to write my own rules using typescript for a while now, but cant find any docs other than: https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/plugin-development/README.md So I was wondering what is the status on docs for writing rules? 😄 |
If anyone had a link to a working repo that would be a great help, as well. I feel completely blocked on writing a simple rule that checks for type information when this was pretty straightforward using TSLint. |
For now - this repo itself serves as documentation in the form of examples. There are no other docs right now, as I haven't had the time to write any and nobody in the community has stepped up to write some. (as I mentioned in #40 (comment) - once onboarded, people don't feel the drive to contribute docs back) I wish I could help out, but I just don't have a spare few hours to sit down and write some docs, as all my volunteer time is spent on issues/prs. |
* fix: lock @typescript-eslint/eslint-plugin version in range minor version of @typescript-eslint/eslint-plugin breaks its utils * ci: ignore built and dependecies files * chore: add table of contents and fix commit hook * docs: add troubleshooting note * docs: fix lint-staged example and add note about "git add" * chore: restrict using `npm i` in root * chore: fix tagging for prerelease
Currently theres a bunch of rules at https://github.com/bradzacher/eslint-plugin-typescript written in js that, since they're operating on typescript should eventually be migrated to be written in typescript as per the comment https://github.com/bradzacher/eslint-plugin-typescript/issues/56#issuecomment-455313509.
I think a good first step here would be to:
Figure out how the typing works for writing rules in typescript - I still haven't gotten my head around where all the types come from since some are from ESTree, some are from the JSX spec, and then some will be typescript specific
Create or update ESUtils to be typescript so that it can provide typeguards as helper functions - for example
isJSXAttribute(node)
, similar to how https://github.com/ajafff/tsutils works at the moment.The text was updated successfully, but these errors were encountered: