Skip to content

Commit

Permalink
MI-39: Update ReadMe
Browse files Browse the repository at this point in the history
  • Loading branch information
kai-nguyen-aligent committed Nov 8, 2024
1 parent 67e5f2e commit 2e5888e
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 38 deletions.
105 changes: 69 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,97 @@ Standard code quality tooling for projects written in TypeScript.

## Usage

Install this module:
### Install this package:

```bash
# NPM
npm install -D @aligent/ts-code-standards
# Yarn
yarn add -D @aligent/ts-code-standards
# PNPM
pnpm add -D @aligent/ts-code-standards
```

# NPM
npm install -D @aligent/ts-code-standards
# Yarn
yarn add -D @aligent/ts-code-standards
# PNPM
pnpm add -D @aligent/ts-code-standards
### Copy the `.editorconfig` from this package into your own project:

Copy the `.editorconfig` from this repo into your own.
```bash
# Assuming your package is installed in `node_modules` folder
cp node_modules/@aligent/ts-code-standards/.editorconfig ./.editorconfig
```

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

```javascript
import { prettierConfig } from '@aligent/ts-code-standards';
- For ES modules project:

export default prettierConfig;
```
```javascript
import { prettierConfig } from '@aligent/ts-code-standards';

Then install the ESLint and TypeScript configs depending on what type of project you are setting up:
export default prettierConfig;
```

### General Projects
- For CommonJS project:

Add the following to your `eslint.config.js`:
```javascript
const { prettierConfig } = require('@aligent/ts-code-standards');

```javascript
import { eslintConfigs } from '@aligent/ts-code-standards';
module.exports = prettierConfig;
```

export default [...eslintConfigs.base];
```
### Install the ESLint and TypeScript configs:

#### General Projects

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

- For ES modules project:

```javascript
import { eslintConfigs } from '@aligent/ts-code-standards';

export default [...eslintConfigs.base];
```

Add the following to your `tsconfig.json`:
- For CommonJS project:

```javascript
const { eslintConfigs } = require('@aligent/ts-code-standards');

module.exports = [...eslintConfigs.base];
```

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

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

### React Projects
#### React Projects

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

```javascript
import { eslintConfigs } from '@aligent/ts-code-standards';
- For ES modules project:

export default [...eslintConfigs.react];
```
```javascript
import { eslintConfigs } from '@aligent/ts-code-standards';

export default [...eslintConfigs.react];
```

- For CommonJS project:

```javascript
const { eslintConfigs } = require('@aligent/ts-code-standards');

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"
}
{ "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.
- 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/).
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"./tsconfigs-base": "./tsconfigs/base.json",
"./tsconfigs-react": "./tsconfigs/react.json"
},
"files": [
"dist",
"tsconfigs"
],
"scripts": {
"test": "tsc && eslint .",
"build": "npx rollup -c",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const OUT_DIR = 'dist';

export default {
input: 'src/index.ts',
input: 'src/index.js',
output: [
{
file: `${OUT_DIR}/index.cjs`,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfigs/react.json",
"include": ["**/*.tsx", "**/*.ts", "**/*.js", "src/declarations.d.ts", "src/index.ts"]
"include": ["**/*.tsx", "**/*.ts", "**/*.js", "src/declarations.d.ts", "src/index.js"]
}

0 comments on commit 2e5888e

Please sign in to comment.