-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor(repo): Use sharable typescript-config-spirit in tsconfig files #1787
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# typescript-config-spirit | ||
|
||
> TypeScript configuration and utilities for Spirit Design System. | ||
|
||
## Getting started | ||
|
||
To install `typescript-config-spirit` in your project, you will need to run the | ||
following command using [Yarn][yarn]: | ||
|
||
```bash | ||
yarn add typescript-config-spirit | ||
``` | ||
|
||
## 👨💻 Usage | ||
|
||
```json | ||
// tsconfig.json | ||
{ | ||
"extends": "../../configs/typescript-config-spirit/base", | ||
"compilerOptions": { | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
It is worth noting that when you extend a `tsconfig.json` file, the properties in `compilerOptions` are merged. | ||
And **when both files define the same property, the child `tsconfig.json` wins**. | ||
|
||
However, this is not the case with `include` and `exclude`. | ||
If you define them in the child `tsconfig.json` file, that **exact value will be used; it won’t be merged** with the value from the base `tsconfig.json` file. | ||
|
||
### Base Configuration | ||
|
||
> `typescript-config-spirit/base` | ||
|
||
This configuration is the base TypeScript configuration. | ||
It is fine to use this configuration when you need to transpile Node.js code. | ||
|
||
### DOM Configuration | ||
|
||
> `typescript-config-spirit/dom` | ||
|
||
This configuration extends the base configuration. | ||
It is fine to use this configuration for the code that is running in the DOM. | ||
|
||
For most of the packages this configuration will be the best choice. | ||
|
||
```json | ||
// tsconfig.json | ||
{ | ||
"extends": "../../configs/typescript-config-spirit/dom", | ||
"exclude": ["./dist"], | ||
"include": ["./src/**/*", "./tests/**/*"] | ||
} | ||
``` | ||
|
||
## 🙌 Contributing | ||
|
||
We're always looking for contributors to help us fix bugs, build new features, | ||
or help us improve the project documentation. If you're interested, definitely | ||
check out our [Contributing Guide][contributing]! 👀 | ||
|
||
## 📝 License | ||
|
||
Licensed under the [MIT][license]. | ||
|
||
[yarn]: https://yarnpkg.com/en/ | ||
[contributing]: https://github.com/lmc-eu/spirit-design-system/blob/main/CONTRIBUTING.md | ||
[license]: https://github.com/lmc-eu/spirit-design-system/blob/main/LICENSE.md |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
{ | ||
"compileOnSave": true, | ||
"compilerOptions": { | ||
/* Visit https://aka.ms/tsconfig to read more about this file */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comments in JSON 😨 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that is just fine. Associate JSONC with JSON files in your IDE :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not kidding. The JSON format is really bad for storing configurations. Especially with the lack of comments. For a better understanding of configs, comments like these are necessary. |
||
|
||
/* | ||
* Projects | ||
*/ | ||
// Save .tsbuildinfo files to allow for incremental compilation of projects. | ||
// @see: https://www.typescriptlang.org/tsconfig/#incremental | ||
// "incremental": true, | ||
|
||
/* | ||
* Language and Environment | ||
*/ | ||
// Set the JavaScript language version for emitted JavaScript and include compatible library declarations. | ||
// @see: https://www.typescriptlang.org/tsconfig/#target | ||
"target": "esnext", | ||
|
||
/* | ||
* Modules | ||
*/ | ||
// Specify how TypeScript looks up a file from a given module specifier. | ||
// @see: https://www.typescriptlang.org/tsconfig/#moduleResolution | ||
"moduleResolution": "node", | ||
|
||
// Specify the base directory to resolve non-relative module names. | ||
// @see: https://www.typescriptlang.org/tsconfig/#baseUrl | ||
"baseUrl": ".", | ||
|
||
// Specify type package names to be included without being referenced in a source file. | ||
// If types is specified, only packages listed will be included in the global scope. | ||
// @see: https://www.typescriptlang.org/tsconfig/#types | ||
"types": ["node", "jest"], | ||
|
||
// Specify multiple folders that act like './node_modules/@types'. | ||
// @see: https://www.typescriptlang.org/tsconfig/#typeRoots | ||
"typeRoots": ["../../node_modules/@types"], | ||
|
||
// Enable importing .json files. | ||
// @see: https://www.typescriptlang.org/tsconfig/#resolveJsonModule | ||
"resolveJsonModule": true, | ||
|
||
/* | ||
* JavaScript Support | ||
*/ | ||
// Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. | ||
// @see: https://www.typescriptlang.org/tsconfig/#allowJs | ||
"allowJs": true, | ||
|
||
/* | ||
* Emit | ||
*/ | ||
// Generate .d.ts files from TypeScript and JavaScript files in your project. | ||
// @see: https://www.typescriptlang.org/tsconfig/#declaration | ||
"declaration": true, | ||
|
||
// Create sourcemaps for d.ts files. | ||
// @see: https://www.typescriptlang.org/tsconfig/#sourceMap | ||
"sourceMap": true, | ||
|
||
// Specify an output folder for all emitted files. | ||
// @see: https://www.typescriptlang.org/tsconfig/#outDir | ||
"outDir": "./dist", | ||
|
||
// Disable emitting comments. | ||
// @see: https://www.typescriptlang.org/tsconfig/#removeComments | ||
"removeComments": true, | ||
|
||
// Disable emitting files from a compilation. | ||
// @see: https://www.typescriptlang.org/tsconfig/#noEmit | ||
"noEmit": true, | ||
|
||
// Disable emitting files if any type checking errors are reported. | ||
// @see: https://www.typescriptlang.org/tsconfig/#noEmitOnError | ||
"noEmitOnError": true, | ||
|
||
/* | ||
* Interop Constraints | ||
*/ | ||
// Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. | ||
// @see: https://www.typescriptlang.org/tsconfig/#esModuleInterop | ||
"esModuleInterop": true, | ||
|
||
// Allow 'import x from y' when a module doesn't have a default export. | ||
// @see: https://www.typescriptlang.org/tsconfig/#allowSyntheticDefaultImports | ||
"allowSyntheticDefaultImports": true, | ||
|
||
// Ensure that casing is correct in imports. | ||
// @see: https://www.typescriptlang.org/tsconfig/#forceConsistentCasingInFileNames | ||
"forceConsistentCasingInFileNames": true, | ||
|
||
/* | ||
* Type Checking | ||
* Note: some checks are set to false since linting takes care of them | ||
*/ | ||
// When type checking, take into account 'null' and 'undefined'. | ||
// @see: https://www.typescriptlang.org/tsconfig/#strictNullChecks | ||
"strictNullChecks": true, | ||
|
||
// When assigning functions, check to ensure parameters and the return values are subtype-compatible. | ||
// @see: https://www.typescriptlang.org/tsconfig/#strictFunctionTypes | ||
"strictFunctionTypes": true, | ||
|
||
// Enable error reporting for expressions and declarations with an implied 'any' type. | ||
// @see: https://www.typescriptlang.org/tsconfig/#noImplicitAny | ||
"noImplicitAny": true, | ||
|
||
// Check for class properties that are declared but not set in the constructor. | ||
// @see: https://www.typescriptlang.org/tsconfig/#strictPropertyInitialization | ||
"strictPropertyInitialization": true, | ||
|
||
// Enable error reporting when 'this' is given the type 'any'. | ||
// @see: https://www.typescriptlang.org/tsconfig/#noImplicitThis | ||
"noImplicitThis": true, | ||
|
||
// Ensure 'use strict' is always emitted. | ||
// @see: https://www.typescriptlang.org/tsconfig/#alwaysStrict | ||
"alwaysStrict": true, | ||
|
||
// Enable error reporting when local variables aren't read. | ||
// @see: https://www.typescriptlang.org/tsconfig/#noUnusedLocals | ||
"noUnusedLocals": false, | ||
|
||
// Raise an error when a function parameter isn't read. | ||
// @see: https://www.typescriptlang.org/tsconfig/#noUnusedParameters | ||
"noUnusedParameters": false, | ||
|
||
// Enable error reporting for codepaths that do not explicitly return in a function. | ||
// @see: https://www.typescriptlang.org/tsconfig/#noImplicitReturns | ||
"noImplicitReturns": true, | ||
|
||
// Enable error reporting for fallthrough cases in switch statements. | ||
// @see: https://www.typescriptlang.org/tsconfig/#noFallthroughCasesInSwitch | ||
"noFallthroughCasesInSwitch": false, | ||
|
||
// Disable error reporting for unreachable code. | ||
// @see: https://www.typescriptlang.org/tsconfig/#allowUnreachableCode | ||
"allowUnreachableCode": true, | ||
|
||
/* | ||
* Completeness | ||
*/ | ||
// Skip type checking all .d.ts files. | ||
// @see: https://www.typescriptlang.org/tsconfig/#skipLibCheck | ||
"skipLibCheck": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"extends": "./base", | ||
"compilerOptions": { | ||
// Specify what module code is generated. | ||
// @see: https://www.typescriptlang.org/tsconfig/#module | ||
"module": "es2015", | ||
|
||
// Set the JavaScript language version for emitted JavaScript and include compatible library declarations. | ||
// @see: https://www.typescriptlang.org/tsconfig/#target | ||
"target": "es2015", | ||
|
||
// Specify a set of bundled library declaration files that describe the target runtime environment. | ||
// @see: https://www.typescriptlang.org/tsconfig/#lib | ||
"lib": ["es2016", "dom", "dom.iterable"], | ||
|
||
// If types is specified, only packages listed will be included in the global scope. | ||
// @see: https://www.typescriptlang.org/tsconfig/#types | ||
"types": ["node", "jest", "@testing-library/jest-dom"] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "typescript-config-spirit", | ||
"description": "TypeScript configuration for Spirit Design System", | ||
"version": "0.0.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v0.1.0 (the lowest correct semver version AFAIK) will be released automatically? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, will be re-versioned with the next publish. However, we can start even with the |
||
"private": true, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/lmc-eu/spirit-design-system.git", | ||
"directory": "configs/typescript-config-spirit" | ||
}, | ||
"bugs": "https://github.com/lmc-eu/spirit-design-system/issues", | ||
"keywords": [ | ||
"alma", | ||
"career", | ||
"config", | ||
"spirit", | ||
"spirit-design-system", | ||
"typescript", | ||
"lint", | ||
"preset" | ||
], | ||
"dependencies": { | ||
"typescript": "5.5.4" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,5 @@ | ||
{ | ||
"compileOnSave": true, | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "./dist", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"moduleResolution": "node", | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"module": "es2015", | ||
"target": "es2015", | ||
"noEmit": true, | ||
"strictNullChecks": true, | ||
"strictPropertyInitialization": true, | ||
"resolveJsonModule": true, | ||
"noImplicitReturns": true, | ||
"allowUnreachableCode": false, | ||
"allowSyntheticDefaultImports": true, | ||
"alwaysStrict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noUnusedParameters": false, | ||
"noUnusedLocals": true, | ||
"strictFunctionTypes": true, | ||
"noImplicitAny": true, | ||
"esModuleInterop": true, | ||
"typeRoots": ["../../node_modules/@types"], | ||
"lib": ["es2015", "dom", "dom.iterable"], | ||
"types": ["node", "jest", "@testing-library/jest-dom"] | ||
}, | ||
"extends": "../../configs/typescript-config-spirit/dom", | ||
"include": ["./src/**/*"], | ||
"exclude": ["./node_modules", "./dist/**/*"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,5 @@ | ||
{ | ||
"compileOnSave": true, | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "./dist", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"moduleResolution": "node", | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"module": "es2015", | ||
"target": "es2015", | ||
"noEmit": true, | ||
"strictNullChecks": true, | ||
"strictPropertyInitialization": true, | ||
"resolveJsonModule": true, | ||
"noImplicitReturns": true, | ||
"allowUnreachableCode": false, | ||
"allowSyntheticDefaultImports": true, | ||
"alwaysStrict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noUnusedParameters": false, | ||
"noUnusedLocals": true, | ||
"strictFunctionTypes": true, | ||
"noImplicitAny": true, | ||
"esModuleInterop": true, | ||
"typeRoots": ["../../node_modules/@types"], | ||
"lib": ["es2015", "dom", "dom.iterable"], | ||
"types": ["node", "jest", "@testing-library/jest-dom"] | ||
}, | ||
"extends": "../../configs/typescript-config-spirit/dom", | ||
"include": ["./src/**/*"], | ||
"exclude": ["./node_modules", "./dist/**/*"] | ||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,5 @@ | ||
{ | ||
"compileOnSave": true, | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "./dist", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"moduleResolution": "node", | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"module": "es2015", | ||
"target": "es2015", | ||
"noEmit": true, | ||
"strictNullChecks": true, | ||
"strictPropertyInitialization": true, | ||
"resolveJsonModule": true, | ||
"noImplicitReturns": true, | ||
"allowUnreachableCode": false, | ||
"allowSyntheticDefaultImports": true, | ||
"alwaysStrict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noUnusedParameters": false, | ||
"noUnusedLocals": true, | ||
"strictFunctionTypes": true, | ||
"noImplicitAny": true, | ||
"esModuleInterop": true, | ||
"typeRoots": ["../../node_modules/@types"], | ||
"lib": ["es2015", "dom", "dom.iterable"], | ||
"types": ["node", "jest", "@testing-library/jest-dom"] | ||
}, | ||
"extends": "../../configs/typescript-config-spirit/dom", | ||
"include": ["./src/**/*"], | ||
"exclude": ["./node_modules", "./dist/**/*"] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit-picking: can code be "run in DOM"? 🤔 Didn't you mean "in browser"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might imply renaming this config to
browser
. But I expect you will explain why I'm wrong 🙂.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configuration is the main reason why. So I name it after this. I was considering a "browser" but it will collide with this configuration and maybe it will be misleading.
It is just:
base
- not running in DOM,dom
- running in DOM.