Skip to content

Isn't it possible to enable & disable specific preset by merge-config? #87

Open
@r7kamura

Description

@r7kamura

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:

textlintWorker.postMessage({
  command: "merge-config",
  textlintrc: {
    rules: {
      "preset-ja-technical-writing": true,
      "preset-japanese": false
    },
  },
});

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?

textlintWorker.postMessage({
  command: "merge-config",
  textlintrc: {
    rules: {
      "preset-ja-technical-writing": {
        "max-comma": {
          max: Number.MAX_SAFE_INTEGER,
        },
        "sentence-length": {
          max: Number.MAX_SAFE_INTEGER,
        },
        "max-ten": {
          max: Number.MAX_SAFE_INTEGER,
        },
        "max-kanji-continuous-len": {
          max: Number.MAX_SAFE_INTEGER,
          allow: [],
        },
        "arabic-kanji-numbers": false,
        // ...
      },
      "preset-japanese": {
        // ...
      },
    },
  },
});

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 for max.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugBug or Bug fixeshelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions