Skip to content
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

Docs section on local development #16854

Closed
1 task
moniuch opened this issue Feb 3, 2023 · 12 comments
Closed
1 task

Docs section on local development #16854

moniuch opened this issue Feb 3, 2023 · 12 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features documentation Relates to ESLint's documentation enhancement This change enhances an existing feature of ESLint

Comments

@moniuch
Copy link
Contributor

moniuch commented Feb 3, 2023

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.

@moniuch moniuch added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels Feb 3, 2023
@nzakas
Copy link
Member

nzakas commented Feb 6, 2023

@moniuch
Copy link
Contributor Author

moniuch commented Feb 6, 2023

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.

@nzakas
Copy link
Member

nzakas commented Feb 6, 2023

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

@nzakas nzakas added documentation Relates to ESLint's documentation accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Feb 6, 2023
@nzakas nzakas assigned nzakas and unassigned nzakas Feb 6, 2023
@moniuch
Copy link
Contributor Author

moniuch commented Feb 7, 2023

That's great to hear! I'll be happy to take a look at the PR when it lands in. :)

@sam3k
Copy link
Contributor

sam3k commented Feb 20, 2023

I'd be happy to test drive the new docs and get familiar with developing custom rules myself. :)

@sam3k
Copy link
Contributor

sam3k commented Mar 29, 2023

Seems related to #16940

@bpmutter
Copy link
Contributor

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

@bpmutter
Copy link
Contributor

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 " 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.

@sam3k
Copy link
Contributor

sam3k commented Apr 12, 2023

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" not touch 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

Screen Shot 2023-04-11 at 10 03 02 PM

@mdjermanovic
Copy link
Member

Fixed by #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

@sam3k
Copy link
Contributor

sam3k commented Jul 21, 2023

Awesome. Looks great!

@moniuch
Copy link
Contributor Author

moniuch commented Jul 21, 2023

@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! ❤️

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jan 18, 2024
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jan 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features documentation Relates to ESLint's documentation enhancement This change enhances an existing feature of ESLint
Projects
Archived in project
Development

No branches or pull requests

5 participants