Skip to content

Commit

Permalink
Merge pull request #1090 from aligent/chore/MI-72-tsconfig-clean-up
Browse files Browse the repository at this point in the history
MI-72: Update template to match with recent changes
  • Loading branch information
tvhees authored Nov 28, 2024
2 parents ed94bbc + 60875e3 commit 86df855
Show file tree
Hide file tree
Showing 41 changed files with 7,520 additions and 6,075 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 100

[{package.json,*.yml,*.md}]
indent_size = 2
indent_style = space

[*.md]
max_line_length = off
trim_trailing_whitespace = false
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

63 changes: 0 additions & 63 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.13]
node-version: [20.18]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -23,7 +23,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npx nx g library test-lib --unitTestRunner=none
- run: npx nx g library test-lib --directory=libs/test-lib --unitTestRunner=none
- run: npx nx g service test-app
# The next 2 lines are needed for nx affected to work when CI is running on a PR
- uses: nrwl/nx-set-shas@v4
Expand Down
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@ node_modules
# misc
/.sass-cache
/connect.lock
/coverage
**/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
.nx

# System Files
.DS_Store
Thumbs.db

# Nx cache
.nx/cache
.nx/workspace-data

vite.config.*.timestamp*

4 changes: 2 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
auto-install-peers = true
engine-strict=true
auto-install-peers=true
engine-strict=true
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.13
v20.18
6 changes: 3 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
**/dist
**/coverage

# nx format always picks this up and reformats
# this file even if there's no issues, so we ignore it
Expand All @@ -10,4 +10,4 @@ tsconfig.base.json
pnpm-lock.yaml
package-lock.json

/.nx/cache
/.nx/cache
4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,43 @@ Below are some example of general Nx. commands. For more information, check out

## Notes:

- The `tsconfig.base.json` file extends `@tsconfig/node20` and `@tsconfig/strictest` packages. Please note that there are settings which is not shown in that file but still applied. For more information on those settings, visit https://github.com/tsconfig/bases.
- The `tsconfig.base.json` file extends [@aligent/ts-code-standard](https://bitbucket.org/aligent/ts-code-standards/src/main) package. Please note that there are settings which is not shown in that file but still applied. For more information on those settings, visit https://github.com/tsconfig/bases.

- This template is package manager agnostic. To use other package manager, install them by enabling [corepack](https://pnpm.io/installation#using-corepack).
- Following `@aligent/ts-code-standard`, we switched to the new [Eslint's FlatConfig](https://eslint.org/blog/2022/08/new-config-system-part-2/). If you're using [VSCode's Eslint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint), turn on the `eslint.useFlatConfig` setting.

## Maintenance

### Upgrading NPM packages

The NPM packages in `devDependencies` in this repository has a complicated relationship with each other. Therefore, upgrading them should be handled with care.

- All the `@nx` packages must be pinned at the same version with `nx` package to avoid conflict.

```json
"@nx/devkit": "17.3.0",
"@nx/esbuild": "17.3.0",
"@nx/eslint": "17.3.0",
"@nx/eslint-plugin": "17.3.0",
"@nx/js": "17.3.0",
"@nx/plugin": "17.3.0",
"@nx/vite": "17.3.0",
"@nx/workspace": "17.3.0",
"nx": "17.3.0"
```

- All the packages that are in the same scope should be at the same version. For example:

```json
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
```

- `@nx/esbuild` lists `esbuild` as peerDependency. Double check the required version of `esbuild` in `package.json` of this [package](https://www.npmjs.com/package/@nx/esbuild?activeTab=code) before upgrading.
- `eslint` and `prettier` are a peerDependencies of the following packages. Double check the required versions in `package.json` of these packages before upgrading.
- [@aligent/ts-code-standard](https://bitbucket.org/aligent/ts-code-standards/src/main/package.json)
- [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import?activeTab=code)
- `@nx/vite` lists `vite` and `vitest` as peerDependencies. Double check the required version of `vite` and `vitest` in `package.json` of this [package](https://www.npmjs.com/package/@nx/vite?activeTab=code) before upgrading.
- `vitest`, `@vitest/coverage-v8` and `@vitest/ui` should be at the same version.

## Under development

Expand Down
48 changes: 48 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { eslintConfigs } = require('@aligent/ts-code-standards');
const eslintPluginImport = require('eslint-plugin-import');
const jsonParser = require('jsonc-eslint-parser');
const nxEslintPlugin = require('@nx/eslint-plugin');

const eslintBaseConfig = [
...eslintConfigs.core,
{
ignores: ['**/*.js', '**/*.mjs', '**/coverage'],
},
{
files: ['**/*.ts'],
plugins: {
'@nx': nxEslintPlugin,
import: eslintPluginImport,
},
rules: {
'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: [],
depConstraints: [
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*'],
},
],
},
],
'import/no-extraneous-dependencies': [
'warn',
{
optionalDependencies: false,
peerDependencies: false,
bundledDependencies: false,
packageDir: ['.', '../..'],
},
],
},
},
{
files: ['**/*.json'],
languageOptions: { parser: jsonParser },
},
];

module.exports = eslintBaseConfig;
33 changes: 21 additions & 12 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"affected": {
"defaultBase": "origin/staging"
},
"defaultBase": "origin/staging",
"generators": {
"@aligent/serverless-plugin:service": {
"brand": "brand-name"
},
"@nx/js:library": {
"projectNameAndRootFormat": "derived",
"bundler": "none",
"linter": "eslint",
"unitTestRunner": "vitest"
}
},
Expand All @@ -24,30 +22,41 @@
"cache": true
},
"lint": {
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore"
],
"inputs": ["default"],
"cache": true
},
"test": {
"inputs": ["default", "^production"],
"outputs": ["{projectRoot}/coverage"],
"cache": true
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/eslint.config.m[jt]s",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/src/test-setup.[jt]s"
"!{projectRoot}/vite.config.m[jt]s"
],
"sharedGlobals": []
},
"plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
},
{
"plugin": "@nx/vite/plugin",
"options": {
"testTargetName": "test",
"typecheckTargetName": "check-types"
}
}
],
"workspaceLayout": {
"appsDir": "services",
"libsDir": "libs"
Expand Down
Loading

0 comments on commit 86df855

Please sign in to comment.