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

Add experimental support for post processors #7568

Merged
merged 47 commits into from Apr 12, 2024

Conversation

YuanboXue-Amber
Copy link
Contributor

@YuanboXue-Amber YuanboXue-Amber commented Mar 22, 2024

Which issue, if any, is this issue related to?

Closes #7567

Is there anything in the PR that needs further explanation?

Adding experimental config processors that allows modifying lint results object:

Type:

// config type:
type ConfigProcessors = string[];

// type of each processor object:
type Processor = {
  name: string;
  postprocess: PostProcessFunction;
};

type PostProcessFunction = (result: LintResult) => void;

Usage:

  • In config:

    JSON:

    {
      "processors": ["some_module"]
    }

    or multiple processors:

    {
      "processors": ["module_A", "module_B"]
    }
  • Example processor:

    export default function myProcessor() {
      return {
        name: 'remap-location',
    
        /** @type {(result: LintResult) => void} */
        postprocess(result) {
          result.warnings.forEach(warning => {
            warning.endLine = warning.endLine === undefined ? warning.line : warning.line + 5;
          });
        },
      };
    }

Copy link

changeset-bot bot commented Mar 22, 2024

🦋 Changeset detected

Latest commit: 38b3bcc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
stylelint Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@YuanboXue-Amber YuanboXue-Amber marked this pull request as ready for review March 25, 2024 10:47
@YuanboXue-Amber YuanboXue-Amber changed the title [DRAFT] Add config postProcess that allows modifying lint result feat: Add config postProcess that allows modifying lint result Mar 25, 2024
@YuanboXue-Amber YuanboXue-Amber changed the title feat: Add config postProcess that allows modifying lint result feat: Add config postProcessor that allows modifying lint result Mar 25, 2024
@YuanboXue-Amber YuanboXue-Amber changed the title feat: Add config postProcessor that allows modifying lint result feat: Add config postProcessor that allows modifying lint results Mar 25, 2024
@ybiquitous ybiquitous changed the title feat: Add config postProcessor that allows modifying lint results POC: Add support for post processors Mar 27, 2024
@ybiquitous ybiquitous changed the title POC: Add support for post processors POC: Add experimental support for post processors Mar 27, 2024
@ybiquitous ybiquitous changed the title POC: Add experimental support for post processors Add experimental support for post processors Mar 29, 2024
Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

@YuanboXue-Amber Thanks for the pull request. Can you take a look at my comments?

.changeset/neat-walls-argue.md Outdated Show resolved Hide resolved
docs/user-guide/configure.md Outdated Show resolved Hide resolved
docs/user-guide/configure.md Show resolved Hide resolved
docs/user-guide/configure.md Outdated Show resolved Hide resolved
docs/user-guide/configure.md Outdated Show resolved Hide resolved
YuanboXue-Amber and others added 7 commits March 31, 2024 22:26
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
@YuanboXue-Amber
Copy link
Contributor Author

[suggest] How about improving the code example to make it closer to real a use-case?

@ybiquitous Do you refer to the example in the configure.md file? I've updated the example there. It is now more aligned with our specific use case, the reason why we needed this feature. Let me know your thoughts.

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

Great! The implementation is overall good 👍🏼

Can you take a look at my some suggestions?

lib/augmentConfig.mjs Outdated Show resolved Hide resolved
lib/augmentConfig.mjs Outdated Show resolved Hide resolved
lib/augmentConfig.mjs Outdated Show resolved Hide resolved
lib/augmentConfig.mjs Outdated Show resolved Hide resolved
lib/augmentConfig.mjs Outdated Show resolved Hide resolved
types/stylelint/index.d.ts Outdated Show resolved Hide resolved
YuanboXue-Amber and others added 9 commits April 6, 2024 19:45
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
@YuanboXue-Amber
Copy link
Contributor Author

Great! The implementation is overall good 👍🏼

Can you take a look at my some suggestions?

Thank you :) I addressed all comments. Appreciate another round of review 🙏

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM 👍🏼

@YuanboXue-Amber
Copy link
Contributor Author

@ybiquitous thank you and could you merge this? I don't have access. Also when will be the next release 🛳️?

@ybiquitous
Copy link
Member

I will merge this after waiting for other reviews in a few days.

@ybiquitous
Copy link
Member

Since there are no concerns or objections, I'm merging this PR. And I'll release the next minor version soon.

@YuanboXue-Amber Again, thank you for the contribution!

@ybiquitous ybiquitous merged commit 6f6abba into stylelint:main Apr 12, 2024
14 checks passed
@YuanboXue-Amber
Copy link
Contributor Author

Thank you @ybiquitous. Looking forward!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add experimental support for post processors
2 participants