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: File extension named processor deprecation #17362

Merged
merged 1 commit into from Jul 28, 2023

Conversation

matwilko
Copy link
Contributor

@matwilko matwilko commented Jul 13, 2023

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[X] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Added a warning box to the Plugin and Custom Processor docs noting that the file extension-named processor feature has been removed in flat configuration, and therefore will be completely removed in ESLint v9.

Plugin authors need to be aware that when converting to/implementing new flat configs, they can no longer rely on this auto-inclusion, and must explicitly specify their processors in their configs.

@matwilko matwilko requested a review from a team as a code owner July 13, 2023 11:24
@eslint-github-bot
Copy link

Hi @matwilko!, thanks for the Pull Request

The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The length of the commit message must be less than or equal to 72

To Fix: You can fix this problem by running git commit --amend, editing your commit message, and then running git push -f to update this pull request.

Read more about contributing to ESLint here

@netlify
Copy link

netlify bot commented Jul 13, 2023

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 41c6f71
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/64c3d5cd4333670008048526
😎 Deploy Preview https://deploy-preview-17362--docs-eslint.netlify.app/use/configure/migration-guide
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nzakas
Copy link
Member

nzakas commented Jul 13, 2023

I'm not sure this wording is correct. Can you link to the reference where you found this info?

In particular, if we haven't made any public announcement about deprecation/removal, then we shouldn't insert it into the docs.

(I'm aware I possibly said something at one point, but I can't find any references on my own, so it would be helpful to link to it for context on this PR.)

@matwilko
Copy link
Contributor Author

I hadn't seen any explicit notice about the change in behaviour, which is why I thought a warning needed adding to the docs 😄

It's just something I've run across while setting up a new project using flat config, and I assumed it was a purposeful change as part of moving to flat config - I even had to shim support into my project locally by post-processing the config array and inserting extra elements after elements with plugins that have extension-named processors to support plugins that haven't updated yet.

Given how explicit flat config likes to make things now, only one processor being permitted per-config-element, and nothing else in the system seeming to modify the array by adding/removing elements, it didn't seem odd that this auto-registration hadn't been brought forward, so I didn't think it was a bug.

If this feature wasn't meant to be removed, then this obviously needs to be converted into a bug report 😄

Reproducible example:

// eslint.config.js
var customPlugin = { 
    name: "custom",
    processors: {
        ".js": {
            preprocess: function(text, filename) { console.log('preprocess'); return [{ text: text, filename: "_" + filename }]; },
            postprocess: function(messages) { console.log('postprocess'); return messages[0]; }
        }
    }
};

module.exports = [
    {
        plugins: { customPlugin },
        //processor: customPlugin.processors[".js"]
    }
];

Commenting/uncommenting the processor turns it on/off - it's not auto-included in the config. Interestingly enough, you also can't refer to these .xx processors by name, processor: "customPlugin/.js" results in TypeError: Key "processor": Expected string in the form "pluginName/objectName" but found "customPlugin/.js".

@nzakas
Copy link
Member

nzakas commented Jul 14, 2023

Yes, the file extension processors aren't automatically applied in flat config, but you can manually specify them like processor: markdown/.md. I think at some point we were talking about deprecating file extension processors but I can't find a reference, and unfortunately, the team member with the most knowledge about this has left the team.

So, I've left a suggestion for how we can clean up the warning. Please also double-check the linting error.

@matwilko
Copy link
Contributor Author

As noted above, you can't refer to extension named processors by name in the config - you have to embed the processor object manually because "plugin/.xx" doesn't pass schema validation.

Should I add an extra commit to update the schema validation for processor?

@matwilko matwilko force-pushed the processor-no-auto-extension-docs branch from dda772b to 9a566b3 Compare July 17, 2023 20:18
@eslint-github-bot
Copy link

Hi @matwilko!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The length of the commit message must be less than or equal to 72

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

@matwilko matwilko changed the title docs: Add warning about file extension named processor feature being removed docs: File extension named processor deprecation Jul 17, 2023
@eslint-github-bot eslint-github-bot bot added the documentation Relates to ESLint's documentation label Jul 17, 2023
@matwilko
Copy link
Contributor Author

@nzakas I've updated the language, with an explicit extra warning that the feature will be removed in ESLint v9.

Also added a fix to the processor string validation to allow arbitrary plugin/processor names to be supported.

@matwilko matwilko force-pushed the processor-no-auto-extension-docs branch 2 times, most recently from 1e5561a to 2ea0928 Compare July 17, 2023 20:26
@matwilko matwilko changed the title docs: File extension named processor deprecation fix: File extension named processor deprecation Jul 17, 2023
@eslint-github-bot eslint-github-bot bot added the bug ESLint is working incorrectly label Jul 17, 2023
@matwilko matwilko force-pushed the processor-no-auto-extension-docs branch from 2ea0928 to e41d4ea Compare July 17, 2023 20:37
@nzakas
Copy link
Member

nzakas commented Jul 18, 2023

Once again, I really appreciate the enthusiasm, but we can't change the scope of PR once it's started. This one started as a documentation update, which is what we were looking for, so we shouldn't be adding functionality changes into it.

Additionally, changing something as important as the config system can't be done on a whim. It needs to be discussed first, so please open a separate issue with that suggestion.

@matwilko
Copy link
Contributor Author

No problem, I'll pull out the code change.

Since you already seem to think the system should allow these processors to be named, but it actually doesn't, I'll post it as a new bug fix PR, and we can discuss there 😄

@matwilko matwilko force-pushed the processor-no-auto-extension-docs branch from e41d4ea to dee2c45 Compare July 18, 2023 14:57
@matwilko matwilko changed the title fix: File extension named processor deprecation docs: File extension named processor deprecation Jul 18, 2023
@nzakas
Copy link
Member

nzakas commented Jul 18, 2023

It might be hard to believe, but after 10 years of working on ESLint, even I don't know how everything works by heart. 😆

That's why we need documentation!

@matwilko
Copy link
Contributor Author

Haha, I can absolutely believe that with a system this big 😄 But after 10 years, your general feel for how something should be working isn't nothing - our own systems can always surprise us though 😅

Code changes moved into #17384 for review.

@fasttime
Copy link
Member

Maybe it would be good to add a note to the migration guide to explain that extension-named processors won't work any more. The mention that the syntax for configuring processors hasn't changed should be updated as well.

@matwilko
Copy link
Contributor Author

@nzakas Would you prefer an update to the migration guide in a new PR, or can we roll a further docs update into this PR to keep these related updates together?

@nzakas
Copy link
Member

nzakas commented Jul 19, 2023

@matwilko we can definitely add other docs changes related to explaining file-extension processors in this PR. 👍

@matwilko matwilko force-pushed the processor-no-auto-extension-docs branch from dee2c45 to c57f606 Compare July 19, 2023 17:29
@matwilko
Copy link
Contributor Author

Removed the notice about removal in ESLint 9.

Added a new section to the migration docs covering the differences for processors between eslintrc and flat config, and removed the bullet about processor syntax not changing - while the string form is still around, processor objects can also now be embedded directly.

docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
@matwilko matwilko force-pushed the processor-no-auto-extension-docs branch from c57f606 to 0ae303c Compare July 20, 2023 19:24
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
@matwilko matwilko force-pushed the processor-no-auto-extension-docs branch from 0ae303c to 53349ca Compare July 21, 2023 13:00
docs/src/extend/plugins.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
@matwilko matwilko force-pushed the processor-no-auto-extension-docs branch from 53349ca to b36797e Compare July 24, 2023 16:10
Copy link
Member

@fasttime fasttime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Leaving open for @nzakas to verify.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting close, just a couple of tweaks to clean things up.

docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
docs/src/use/configure/migration-guide.md Outdated Show resolved Hide resolved
@matwilko matwilko force-pushed the processor-no-auto-extension-docs branch 3 times, most recently from 6158111 to 9b62f04 Compare July 28, 2023 14:33
@matwilko matwilko force-pushed the processor-no-auto-extension-docs branch from 9b62f04 to 41c6f71 Compare July 28, 2023 14:50
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@nzakas nzakas merged commit 091f44e into eslint:main Jul 28, 2023
22 checks passed
@matwilko matwilko deleted the processor-no-auto-extension-docs branch July 28, 2023 15:07
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jan 25, 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 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly documentation Relates to ESLint's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants