question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extending rule options in derived configs?

See original GitHub issue

This comes up fairly frequently: Someone extends a shareable config or plugin config which might use no-restricted-syntax or similar to lint certain patterns. A user may wish to alter the list of linted patterns to add one more pattern; however, right now, this means copying the whole list from the shareable config or plugin config, which basically defeats the purpose of using a shareable config in the first place.

I wanted to get the ball rolling on discussing how we might address this with one simple, incomplete, likely flawed proposal. I’m hoping that we can come up with something good after a spirited discussion.

My proposal:

  • Augment new-style rule support in core to allow an extendConfiguration method (in line with meta property and create method).
  • The extendConfiguration method takes two arguments: old options, and new options (in both cases with severities removed). It should return an options object that (ideally) contains a merging of the two sets of options, in whatever way makes sense for the rule in question.
  • When resolving configurations, ESLint core would load the rule, look for an extendConfiguration method, and call it with old and new options if it is present. If not, ESLint core will simply override with the new options, matching current behavior.

One possible challenge I am already seeing is that this requires CLIEngine to load and work with rules, instead of Linter. This may not be a problem if schema validation is also being handled by CLIEngine, but I can’t remember if it is. I’m sure there are more issues with what I have proposed as well. But let’s see if we can come up with something workable and get this sorted!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:26 (25 by maintainers)

github_iconTop GitHub Comments

1reaction
ilyavolodincommented, Nov 17, 2018

I think this is a problem worth solving, but I’m against solving it with adding a first (optional) argument. We state everywhere in our documentation that the first argument of the configuration array is always severity of the error. I think it would be very confusing if we were to break that promise. What if we just split configuration into separate object?

{
  "rules": {
    "semi": ["never"],
    ....
    "inherit": {
      "no-restricted-syntax": ["error", "ForOfStatement"],
      ...
    }
}

This will allow for much clearer backwards compatibility. Inherit could also be a top level node if you don’t like nesting it under rules, although I would call it inheritedRules in that case.

0reactions
eslint-deprecated[bot]commented, Dec 21, 2018

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration Files - ESLint - Pluggable JavaScript Linter
A configuration file, once extended, can inherit all the traits of another configuration file (including rules, plugins, and language options) and modify all ......
Read more >
Derived Configurations - 2021 - SolidWorks Web Help
Derived configurations allow you to create a parent-child relationship within a configuration. By default, all parameters in the child configuration are linked ...
Read more >
Configurations – What Are They Good For? Here's a Few Things
Derived configurations. At its most basic, each configuration can be created manually from the right-mouse menu.
Read more >
Derived Objects and Configuration Records - IBM
By default, they process individual CRs. · With the -recurse option, they process the entire CR hierarchy of each derived object specified, keeping...
Read more >
Configuration in ASP.NET Core - Microsoft Learn
Related groups of registrations can be moved to an extension method to register ... The following configuration providers derive from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found