-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
New: Object support in extends
, parser
, plugins
, and processor
#54
New: Object support in extends
, parser
, plugins
, and processor
#54
Conversation
👎 Given that we have already decided to do simple config, I don’t think we should be making any further changes to eslintrc. The more enhancements added, the tougher it becomes to get full compatibility with simple config. |
@nzakas I hope you read and evaluate rather than just negating.
The enhancements of this RFC already exist in #9. I think that we are seeing the same goal. The following items are what I want to do for the config system:
It will be very similar to #9. Just a difference is, I believe that we can do those in the current config system. This RFC does the 1. (I have plans to write RFCs for the other.)
It indicates the current codebase is well-structured and we need only small changes to support those. And the small change (rather than a complete replacement that has migration pain) can resolve our longest standing issue with no breaking changes. And while discussion of #9, some concept ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I understand the desire to incrementally change our config system, I do feel strongly that it has gotten extremely complex and unwieldy.
A large number of issues we see from end users are about configuration loading, and despite the complexity involved in our tool, I think we have a problem of valuing flexibility over usability. I agree that flexibility is important, but I really think we should be optimizing for the "happy path" (majority use case), and I believe that requires a holistic approach, rather than a large number of incremental changes.
While the individual changes all make sense, we now have bolted on so many different CLI flags and extra features that I personally am supportive of pursuing a new approach to configuration, where we can design the feature set up front and have a better understanding of the usability of the integration of all the features.
Edit: Split up the wall of text into paragraphs so it's easier to read.
I think that we can do a softer way than the complete replacement because: | ||
|
||
- While discussions, the `plugins` field revived and the `extends` field or similar thing is going to revive. It's going to be similar to the existing config system except `env` and cascading. | ||
- That RFC has brought the config array concept and we have done huge refactoring with the concept. Currently, the config loading logic is well-structured and maintainable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue that our current configuration logic is actually quite complex and hard to understand. Maybe this is just a limitation of the amount of knowledge I can personally keep in my head, but I know that I often have to go back to the source code when I'm triaging issues. And if I'm having difficulties keeping track of how our configuration works, I think it's a safe bet that our end users are struggling as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This RFC is what reduces the complexity by the same approach as #7; it expects users to assemble configuration by JS code and well-known require(...)
instead of ESLint's own resolving logic.
In support of @kaicataldo's comment, from the perspective of a large plugin maintainer.
As an interesting aside, at facebook (because of the history of their linting tooling) the configuration is done not via an function getConfig(path: string, contents: string): ESLintConfig {
const isProjectX = match(path, '/foo/bar/X');
const isProjectY = match(path, '/foo/bar/Y');
// ...
const isFlow = match(contents, '@flow');
// ...
const isTypeScript = match(path, '.ts$');
const config = { parser: 'babel-eslint', rules: { ... } };
if (isProjectX) {
Object.assign(config.rules, { ... });
}
if (isProjectY) {
Object.assign(config.rules, { ... });
}
// ...
if (isTypeScript) {
config.parser = '@typescript-eslint/parser';
config.plugins.push('@typescript-eslint');
Object.assign(config.rules, { ... });
}
return config;
} The file itself is a bit of a mess (5k lines), but it is surprisingly easy to reason about the config for a specific file because ultimately it's all just code which can be debugged with any debugging tool. |
@kaicataldo Which do you talk about the complexity of either userland or our code?
@bradzacher Thank you for your feedback!
Yes, I agree. I feel hard to understand our documentation, too.
Interesting. export const projectConfig = {
includes: ["src/**/*"],
excludes: ["node_modules/*"],
formatter: "stylish",
formatterOptions: {...},
concurrency: "auto",
}
export function getConfigForFile(filePath) {
// Assemble config for a file.
return {...}
} Also, for the current config system, we can improve |
Thank you all for the discussion in this thread and particularly @mysticatea for putting the RFC together! Now that we've decided on a direction to take configs going forward in #9, the TSC decided today to close the other config-related RFCs so we can focus on the new format. You can follow along with that implementation work at eslint/eslint#13481. |
Summary
ESLint accepts objects in all of the
extends
,parser
,plugins
, andprocessor
fields in configurations. It solves the longest standing issue #3458 "Support having plugins as dependencies in shareable config", with small breaking changes.Related Issues