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.

An option allowExtends could enable extending.

The model I have in mind is https://github.com/stylelint/stylelint/blob/master/src/postcssPlugin.js#L69. Hopefully we can avoid using require() directly, though, because it is synchronous. Open to other implementation ideas, of course, if they are comparably simple.

Whatever the implementation, key requirements are:

  • extend configurations of JSON or YAML format.
  • extends accepts a single string or an array of strings.
  • extends lookups can be absolute or relative paths, or a node_module name.
  • merging of extends occurs in the order of the array, so the last item takes priority over the first item (merges on top of it).

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
azzcommented, Mar 13, 2019

Yep you’re totally right. We found a better way.

0reactions
davidtheclarkcommented, Mar 10, 2019

🤔The ESLint RFC I found through the Prettier issue is very interesting. I agree with the premise that ESLint’s current configuration complexity should be considered a warning to others, rather than something to emulate. And I really like the idea of demanding a JS file, allowing people to implement their own imports, merges, transforms, etc., rather than trying to appease every developer’s desire with configuration-loader magic.

I’ve looked at a few packages that try to implement generic extends patterns, and they just don’t seem generic enough that I want to include them in Cosmiconfig.

I’m not completely opposed to the idea of adding an extends option that always expects a custom merge function as its argument. Thinking through what that means, though …

  1. We look at an extends property in the loaded configuration. (What about those who will want a different property name, or a nested property?)
  2. We expect the value of extends to be an array of strings. (What about those who will want to require() modules directly into their extends array?)
  3. We resolve all of the strings to corresponding configuration files. (What about those who will want special resolution algorithms, as happened with both ESLint and Babel, the posterchildren of extends?)
  4. We recursively use Cosmiconfig to find and load those files.
  5. We merge them together with the provided merge function.

Cosmiconfig’s value really lies in step 4: the rest is highly likely to vary across implementations, and is fairly straightforward to implement. So I still lean towards not trying to add a generic extends pattern in Cosmiconfig, instead allowing users who want extends, or some extends-like system, to use Cosmiconfig behind the scenes to look up and load files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

extends - JavaScript - MDN Web Docs - Mozilla
The extends keyword is used in class declarations or class expressions to create a class that is a child of another class.
Read more >
Handbook - Interfaces
One of TypeScript's core principles is that type checking focuses on the shape that values have. This is sometimes called “duck typing” or...
Read more >
TypeScript Extend Interface
Summary: in this tutorial, you will learn how to extend an interface that allows you to copy properties and methods of one interface...
Read more >
Extending object-like types with interfaces in TypeScript
Extending multiple interfaces refers to the concept of composition where the interface is designed to extend attributes it needs.
Read more >
Allow class to extend from a Generic #35382
My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code; This wouldn't change the ...
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