From 84c6df8714a400322f511677da8e91874a932761 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Mon, 30 Jan 2023 07:52:55 +0200 Subject: [PATCH] Add package for shared typescript configurations for Lens applications, Features and libraries. Signed-off-by: Janne Savolainen --- packages/infrastructure/typescript/README.md | 23 ++++++++++ .../typescript/config/base.json | 46 +++++++++++++++++++ .../typescript/config/styles.d.ts | 17 +++++++ .../infrastructure/typescript/package.json | 21 +++++++++ 4 files changed, 107 insertions(+) create mode 100644 packages/infrastructure/typescript/README.md create mode 100644 packages/infrastructure/typescript/config/base.json create mode 100644 packages/infrastructure/typescript/config/styles.d.ts create mode 100644 packages/infrastructure/typescript/package.json diff --git a/packages/infrastructure/typescript/README.md b/packages/infrastructure/typescript/README.md new file mode 100644 index 0000000000..d9346e9a4b --- /dev/null +++ b/packages/infrastructure/typescript/README.md @@ -0,0 +1,23 @@ +# @k8slens/typescript + +This package contains typescript configurations for Lens packages. + +## Install + +``` +$ npm install @k8slens/typescript +``` + +## Features + +### Base configuration +Base configuration for minimal duplication. + +**tsconfig.json** +```json +{ + "extends": "@k8slens/typescript/config/base.json" +} +``` + + diff --git a/packages/infrastructure/typescript/config/base.json b/packages/infrastructure/typescript/config/base.json new file mode 100644 index 0000000000..0c08f1391c --- /dev/null +++ b/packages/infrastructure/typescript/config/base.json @@ -0,0 +1,46 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "jsx": "react", + "target": "ES2019", + "module": "ESNext", + + "lib": [ + "ESNext", + "DOM", + "DOM.Iterable" + ], + + "moduleResolution": "node16", + "sourceMap": true, + "strict": true, + "noImplicitAny": true, + "noUnusedLocals": true, + "noImplicitReturns": true, + "isolatedModules": true, + "skipLibCheck": true, + "allowJs": false, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "importsNotUsedAsValues": "error", + "traceResolution": false, + "resolveJsonModule": true, + "useDefineForClassFields": true, + + "plugins": [ + { + "name": "typescript-plugin-css-modules" + } + ] + }, + + "ts-node": { + "transpileOnly": true, + + "compilerOptions": { + "module": "CommonJS" + } + }, + + "include": ["./styles.d.ts"] +} diff --git a/packages/infrastructure/typescript/config/styles.d.ts b/packages/infrastructure/typescript/config/styles.d.ts new file mode 100644 index 0000000000..1584916804 --- /dev/null +++ b/packages/infrastructure/typescript/config/styles.d.ts @@ -0,0 +1,17 @@ +// Support import for custom module extensions +// https://www.typescriptlang.org/docs/handbook/modules.html#wildcard-module-declarations + +declare module "*.module.scss" { + const classes: { [key: string]: string }; + export default classes; +} + +declare module "*.module.css" { + const classes: { [key: string]: string }; + export default classes; +} + +declare module "*.scss" { + const content: string; + export = content; +} diff --git a/packages/infrastructure/typescript/package.json b/packages/infrastructure/typescript/package.json new file mode 100644 index 0000000000..918e996042 --- /dev/null +++ b/packages/infrastructure/typescript/package.json @@ -0,0 +1,21 @@ +{ + "name": "@k8slens/typescript", + "private": false, + "version": "0.0.1", + "description": "Typescript configuration for Lens packages.", + "type": "commonjs", + "repository": { + "type": "git", + "url": "git+https://github.com/lensapp/lens.git" + }, + "author": { + "name": "OpenLens Authors", + "email": "info@k8slens.dev" + }, + "license": "MIT", + "homepage": "https://github.com/lensapp/lens", + "dependencies": { + "typescript": "^4.9.3", + "typescript-plugin-css-modules": "^3.4.0" + } +}