-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Isn't it possible to enable & disable specific preset by merge-config? #87
Comments
This comment was marked as resolved.
This comment was marked as resolved.
Oh, I misread that. In textlint kernal, presets are expanded as separate rules and then loaded. in script-compiler editor/packages/@textlint/script-compiler/src/CodeGenerator/worker-codegen.ts Lines 152 to 172 in d5d5a87
in textlint https://github.com/textlint/textlint/blob/e184d1f33340bb3fc0bc13c50f62d8feb6ecae8a/packages/%40textlint/config-loader/src/loader.ts#L215-L223 Probably, We need to treat editor/packages/@textlint/script-compiler/src/CodeGenerator/worker-codegen.ts Lines 152 to 172 in d5d5a87
|
It is possible that the process of excluding rules with an option of |
This comment was marked as outdated.
This comment was marked as outdated.
I see. I like the idea of expanding { presetA: false } that way. Reviewing from the design of config, I see there are two options on how to handle { ruleA: false } here. One is to leave the current config as it is in its current design and regard false as a special instruction to delete the element when merge is performed, as you described. The other is to design the config so that false is a special setting that disables the rule, so that when you merge, you do nothing special and false is the setting value of the rule. This way, I think it will work well not only when merge, but also when writing { ruleA: false } in .textlintrc, so there are fewer surprises and more symmetry. |
#87 (comment)
|
Can you explain the detail? |
const config1 = {
rules: {
a: { /* ... */ }
}
};
const config2 = {
rules: {
a: false
}
};
const result = mergeConfig(config1, config2) In the code above, I'm talking about whether the result should be |
As background, I am trying to provide a mechanism to bundle multiple rule presets into one Chrome extension and let users choose which one they want to use.
I tried to implement this using merge-config command while reading the documentation on the following page,
like this:
but the above code did not work as intended to toggle disabling/enabling of the entire preset.
Is this currently not feasible without adding individual settings to switch disable/enable for each preset for each rule, as shown below?
In this case, though, it makes no sense to use presets in the first place, and it would be easier to use the individual rules without presets.
In addition, I would like to take this opportunity to ask a follow-up question: isn't it possible to "disable a specific rule" in merge-config? I think that just mergeing
false
for each individual ruleId element won't work. By this issue, the above example also includes a workaround that sets a suitably large value formax
.The text was updated successfully, but these errors were encountered: