eslint
eslint copied to clipboard
Docs section on local development
ESLint version
8.32.0
What problem do you want to solve?
As a developer who has to deal with eslint challenges sporadically, I find it difficult to gather definite instructions about the local development. When trying to write some project-specific rules or predefined configurations, I need to browse through a lot of web sources to find the recommended ways of writing custom eslint bits locally. What is especially difficult is figuring out how to link Javascript files with your custom rules, whether this is possible at all, and whether you need to create an npm package locally, or maybe there is a syntax for eslintrc.json that allows to refer to local file at any directory, etc.
What do you think is the correct solution?
I think the eslint website deserves a separate section about local development which would lay out all the technical possibilities for developing own plugins and configurations, providing file structure and syntax recipes. It would save a lot of time from those who sporadically need to customize their project's eslint environment
Participation
- [ ] I am willing to submit a pull request for this change.
Additional comments
I cannot declare to submit a pull request for this change, due to insufficient knowledge, but I will be more than happy to be involved in reviewing the new content.
Have you seen this page? https://eslint.org/docs/latest/contribute/development-environment
I have but this is not what I was after.
What I was looking for was information on the best technique to develop custom rules or an entire plugin without having to go through the whole npm publishing process.
To give you an example, one of the bits I was missing was that you can "fake" an npm package locally, by placing eslint-plugin-your-plugin
in any directory you like, and refer to it in package.json
using file:
+ running npm install
. That would have been so helpful to find on eslint pages (even though it is kind of npm thing).
I hope this will kick me off with a way to write some project-specific rules that I need. After deprecation or --rules-dir
it's difficult to figure out how to link your custom rules that the correct way and whether you really need to install eslint-plugin-local-rules
Hopefully, this clarifies and gives you a better idea of my experience.
We are looking at adding documentation that guides people who want to write their first rule. It will probably take some time before we get around to it, but it is on our list to tackle in the future.
cc @bpmutter
That's great to hear! I'll be happy to take a look at the PR when it lands in. :)
I'd be happy to test drive the new docs and get familiar with developing custom rules myself. :)
Seems related to https://github.com/eslint/eslint/issues/16940
I'd be happy to test drive the new docs and get familiar with developing custom rules myself. :)
here's the draft of the tutorial if you'd like to take a look! https://github.com/eslint/eslint/pull/17024
fwiw i also find ChatGPT to be quite talented at ESLint-related stuff. for example, if you ask ChatGPT something like "how to make an eslint custom rule that <YOUR REQUIREMENT>" it can give you a very strong starting point.
I suspect this works so well b/c ESLint has been around for a while and there is a lot of content on the web published about it for GPT to borrow from.
I'd be happy to test drive the new docs and get familiar with developing custom rules myself. :)
here's the draft of the tutorial if you'd like to take a look! #17024
I'm following along the tutorial and is so easy to go through it. Here are a few things I noticed:
- I think you meant to say
touch enforce-foo-bar.test.js
on "Step 5: Set up Testing" nottouch foo-bar.test.js
. - In step 6; I would conclude asking the reader to run
npm run test
and then maybe even provide an example of the expected output - Reason for the previous point is, I am getting the following when I run
npm run test
Fixed by https://github.com/eslint/eslint/pull/17024.
https://eslint.org/docs/latest/extend/custom-rule-tutorial
How to use custom rules without publishing to npm:
https://eslint.org/docs/latest/extend/custom-rule-tutorial#step-8-use-the-plugin-locally
Awesome. Looks great!
@bpmutter Let me thank you for your arduous work in closing this ticket, in particular - in handling all the reviews and comments in #17024. Fantastic job! ❤️