Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ Standard code quality tooling for projects written in TypeScript.
module.exports = prettierConfig;
```

### Install the ESLint and TypeScript configs:
### Add the following to your `eslint.config.js`:

#### General Projects

##### Add the following to your `eslint.config.js`:

- For ES modules project:

```javascript
Expand All @@ -62,16 +60,8 @@ Standard code quality tooling for projects written in TypeScript.
module.exports = [...eslintConfigs.base];
```

##### Add the following to your `tsconfig.json`:

```json
{ "extends": "@aligent/ts-code-standards/tsconfigs/base.json" }
```

#### React Projects

##### Add the following to your `eslint.config.js`:

- For ES modules project:

```javascript
Expand All @@ -88,14 +78,29 @@ Standard code quality tooling for projects written in TypeScript.
module.exports = [...eslintConfigs.react];
```

##### Add the following to your `tsconfig.json`:
### Add the following to your `tsconfig.json`:

```json
{ "extends": "@aligent/ts-code-standards/tsconfigs/react.json" }
```
- General project:

```json
{ "extends": "@aligent/ts-code-standards/tsconfigs-base" }
```

- Extend project (general project but requires TypeScript project references features):

```json
{ "extends": "@aligent/ts-code-standards/tsconfigs-extend" }
```

- React project:

```json
{ "extends": "@aligent/ts-code-standards/tsconfigs-react" }
```

## Notes

- You'll need to add `include`, `exclude`, `paths` etc. to your `tsconfig` file. These settings will be project specific.
- Your project is considered as `ES modules` project if the `type` option in the nearest `package.json` is set to `module`. Otherwise, it's a CommonJS project. For more information on this, please check [CommonJS vs. ES modules in Node.js](https://blog.logrocket.com/commonjs-vs-es-modules-node-js/).
- For backward compatibility, we also export `./tsconfigs/base.json` and `./tsconfigs/react.json`. However, you should update to the new syntax when configuring your `tsconfig.json` when possible.
- The `tsconfigs-extend` is the configuration for general projects that require TypeScript project references features to enable incremental builds. This is particular useful for monorepo where we have to manage different packages.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"import": "./dist/index.mjs"
},
"./tsconfigs-base": "./tsconfigs/base.json",
"./tsconfigs-extend": "./tsconfigs/extend.json",
"./tsconfigs-react": "./tsconfigs/react.json",
"./tsconfigs/base.json": "./tsconfigs/base.json",
"./tsconfigs/react.json": "./tsconfigs/react.json"
Expand Down
18 changes: 18 additions & 0 deletions tsconfigs/extend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.json",
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"moduleResolution": "bundler",
"module": "ESNext",
"noUncheckedSideEffectImports": true,
"strictNullChecks": true,
"target": "ESNext",
"types": ["node", "vitest", "vitest/globals"]
}
}