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

feat: allow extending settings via config #150

Conversation

blackxored
Copy link
Contributor

@blackxored blackxored commented Nov 21, 2017

Simplified usage (there's a lot more dynamic stuff on my config, so apologies for typos/syntax):

module.exports = {
  extends: ['@commitlint/config-angular'],
  settings: {
    scope: {
      enumerables: {
         "auth": { description: "Authentication code, login, user profile, etc." },
         "settings": { description: "Settings and preferences" },
      }
    },
  },
  rules: {
    'scope-enum': () => {
      const scopes = ['auth', 'settings'];
      return [2, 'always', scopes.concat(['system'])];
    },
  },
};

@marionebl
Copy link
Contributor

Thanks for contributing this PR. I'd prefer a format that combines the enum values with the descriptions, e.g.:

  rules: {
    'scope-enum': () => {
      const scopes = [
          {value: 'auth', description: 'something something' }, 
          {value: 'settings', description: 'something differnt'}
      ];
      return [2, 'always', scopes];
    }
  }

Cool things about this:

  • Can be implemented while maintaining backwards compat
  • Keep unified API for all commitlint tools
  • Make help texts available in liniting eventually
  • Can be adapted beyond the *-enum fields

What do you think?

@blackxored
Copy link
Contributor Author

Hi, unfortunately I’m not yet that familiar to the codebase to be able to come up with a new format or something that’s scope specific. I took a look at the settings at prompt and replicated that format.

@marionebl
Copy link
Contributor

Yeah sure, I'd implement that change myself. I'd like your perspective as an API consumer on that one, though.

@RayBenefield
Copy link

@marionebl I think the API you proposed looks solid for me as a consumer. I was actually just looking for this feature now so I hope this gets implemented soon. :)

@blackxored
Copy link
Contributor Author

I think the problem with that is that while it solves the scope problem, we'll need something custom just like this for, let's say, types, or something else configs might want to change, so you're not really "extending" the config; which is exactly where I started and had to modify prompt itself to be able to get help descriptions. In that case, they were missing and accepted but that won't always be the case for custom config authors.

IMHO think having both would the best but I'd definitely give this one a second look.

@marionebl
Copy link
Contributor

Closing this for now. The extension of the configuration by "described values" is on the roadmap.

@marionebl marionebl closed this Jan 29, 2018
@mogelbrod
Copy link

Closing this for now. The extension of the configuration by "described values" is on the roadmap.

Any progress on this? Couldn't find any mention outside of the README.

@escapedcat
Copy link
Member

Any progress on this? Couldn't find any mention outside of the README.

Hey @mogelbrod , didn't see your comment, sorry. There wasn't any progress afaik.

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.

5 participants