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

Allow custom function to be specified for splitting/ordering of sub-lists when using --rule-list-split option #294

Closed
bmish opened this issue Nov 27, 2022 · 0 comments · Fixed by #365
Labels
enhancement New feature or request

Comments

@bmish
Copy link
Owner

bmish commented Nov 27, 2022

Requested here: ota-meshi/eslint-plugin-regexp#493 (comment)

Perhaps we could allow the option to be passed as a function which returns the list of rule lists and their headere.

// .eslint-doc-generatorrc.js
module.exports = {
  ruleListSplit(rules) {
    const sublist1 = rules.filter(...);
    const sublist2 = rules.filter(...);
    return [
      { rules: sublist1, title: 'Rule List 1' },
      { rules: sublist2, title: 'Rule List 2' },
    ];
  }
};

We might want to rename the option from splitBy to split or ruleListSplit for this (or use a separate option).

Possible types we could allow for this option:

Use case Type CLI Example Config File Example
Split by single property string --rule-list-split meta.type ruleListSplit: 'meta.type'
Split by multiple properties (#291) string[] --rule-list-split meta.deprecated,meta.docs.category (or pass multiple times?) ruleListSplit: ['meta.deprecated', 'meta.docs.category']
Custom splitting function function (not possible on CLI) ruleListSplit(rules) { /* see above example */ }

This could be an alternative way to solve #291

@bmish bmish added the enhancement New feature or request label Nov 27, 2022
@bmish bmish changed the title Allow custom sorting function to be specified for ordering of sub-lists when using --split-by option Allow custom function to be specified for splitting/ordering of sub-lists when using --split-by option Nov 27, 2022
@bmish bmish changed the title Allow custom function to be specified for splitting/ordering of sub-lists when using --split-by option Allow custom function to be specified for splitting/ordering of sub-lists when using --rule-list-split option Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant