-
-
Notifications
You must be signed in to change notification settings - Fork 10
Description
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:
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.
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
- Implement warning feature in codegen.
- Disable ts-plugin if
cmkConfig.enabledisfalse#299 - Update codegen and ts-plugin to enable language features only when
cmkOptions.enabledistrue, and remove warning feature in codegen.