Skip to content

Disable language features of ts-plugin by default #289

@mizdra

Description

@mizdra

Background

Currently, the language features of ts-plugin are enabled automatically. This means they are enabled in all TypeScript projects. Consequently, Code Actions for CSS Modules appear in projects not using CSS Modules Kit, such as the following:

Image

This can be annoying for some users.

Solution

Enable language features only if cmkOptions.enable is set to true in tsconfig.json. The default value is false. The minimal configuration to enable language features is as follows:

// tsconfig.json
{
  "compilerOptions": {/* ... */},
  "cmkOptions": {
    "enabled": true
  }
}

In projects where tsconfig.json lacks cmkOptions, language features will not be enabled.

// tsconfig.json
{
  "compilerOptions": {/* ... */}
}

cmkOptions.enabled can be inherited using extends. Therefore, language features will be enabled in the following packages/pkg-a/tsconfig.json:

// tsconfig.base.json
{
  "compilerOptions": {/* ... */},
  "cmkOptions": {
    "enabled": true
  }
}
// packages/pkg-a/tsconfig.json
{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {/* ... */}
}

We also add the cmkOptions.enabled option to explicitly disable language features. This allows disabling language features in projects inheriting from tsconfig.base.json.

// packages/pkg-b/tsconfig.json
{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {/* ... */},
  "cmkOptions": {
    "enabled": false
  }
}

Backwards Compatibility

This is a breaking change. Previously, language features were enabled even in projects without cmkOptions in tsconfig.json. However, this change disables them.

Before implementing this change, I believe we should add a warning feature to codegen that advises adding "cmkOptions": { "enabled": true } to tsconfig.json.

Progress

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: ChangeChange existing functionality.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions