Skip to content

Commit

Permalink
chore(global): update dotfiles and fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
waldronmatt committed May 10, 2024
1 parent 7430b2f commit bd64862
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 207 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
145 changes: 12 additions & 133 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,153 +1,32 @@
# https://github.com/toptal/gitignore/blob/master/templates/Node.gitignore

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/
# Dependency directory
node_modules

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# NX Cache
.nx

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
# Eslint cache
.eslintcache

# Optional stylelint cache
# Stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# https://github.com/toptal/gitignore/blob/master/templates/Turbo.gitignore

# Turborepo task cache
.turbo

# Custom Additions

# Bundle output directories
dist/
build/

# Jest folder of detailed test coverage
coverage/
# Storybook bundle output
storybook-static

# nx
nx-cloud.env
.nx
# Jest test coverage
coverage

# Storybook
storybook-static
# Env files
nx-cloud.env
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist
coverage
.nx
pnpm-lock.yaml
CHANGELOG.md
1 change: 0 additions & 1 deletion .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
endOfLine: 'lf',
printWidth: 120,
singleQuote: true,
};
12 changes: 10 additions & 2 deletions docs/repo/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ We are using `lint-staged` to run linting and tests on staged files. This is the

1. Check for secrets (`secretlint`)
2. Fix file formatting (`prettier`)
3. Lint and fix issues of affected `.ts` and related files (`eslint` and `nx`)
4. Run tests of affected files (`jest`/`vitest` and `nx`)
3. Lint `package.json` files for package, dependency, and monorepo best practices
4. Lint and fix issues of affected `.ts` and related files (`eslint` and `nx`)
5. Run tests of affected files (`jest`/`vitest` and `nx`)
6. Lint exports on all `.ts` files (`knip` and `nx`)

We limit automatic fixes to file formatting and linting when possible. For everything else, we let the user to decide on actions to take if there are errors.

We also use Github actions as an extra safeguard in case users bypass `lint-staged`.

## Versioning

All packages including `peerDependencies` are configured to use exact versions of packages. I prefer to have exact package versions to simplify debugging and reduce the likelihood of compatibility issues. I use `renovate` to automatically handle version updates.
Expand Down Expand Up @@ -84,3 +88,7 @@ import { Button, type ButtonProps } from '@waldronmatt/demo-ui/lib/index.js';
```

There are other ways to do this such as symlinking and/or stubbing via third-party packages, but I personally ran into issues using these other methods. Alternatively, some may choose to refernce them via a registry (`npm`) with specified versions so that changes do not break other apps in the monorepo. This may be preferred for larger teams and organizations.

## ESM and CJS File Naming Conventions

For the rare instances where I have both `esm` and `cjs` bundles, I set specific file extensions like `.cjs` for `cjs` and use the standard `.js` extension for `esm`. ESM is the module system industry standard and I would prefer to not label them specifically with a `.mjs` extension. Labelling `cjs` files differently helps to remind developers to upgrade in the future if both module systems must be supported.
18 changes: 12 additions & 6 deletions docs/repo/CICD.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@ Installer command to ensure that the exact versions of dependencies specified in
pnpm bootstrap:ci
```

Versioning command that will bypass prompts for avoiding manual intervention:
Lint the monorepo:

```bash
pnpm version:ci
pnpm lint:mr
```

Publishing command that will bypass prompts for avoiding manual intervention:
Found in the workflow `.yml` cicd files, this command will run all three tasks in parallel for only affected files:

```bash
pnpm publish:ci
npx nx affected -t build,lint,test,lint:knip --parallel=4
```

Found in the workflow `.yml` cicd files, this command will run all three tasks in parallel for only affected files:
Versioning command that will bypass prompts for avoiding manual intervention:

```bash
npx nx affected -t build,lint,test --parallel=3
pnpm version:ci
```

Publishing command that will bypass prompts for avoiding manual intervention:

```bash
pnpm publish:ci
```
6 changes: 6 additions & 0 deletions docs/repo/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Delete workspace root `node_modules` and `pnpm-lock.yaml` files:
pnpm delete
```

Find unused exports (applies to projects in `packages` folder):

```bash
pnpm lint:knip
```

Visualize the project structure/dependencies:

```bash
Expand Down
10 changes: 2 additions & 8 deletions docs/repo/MONOREPO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Monorepo Commands

Lint your monorepo (executes all commands below):
Lint the monorepo (executes all commands below):

```bash
pnpm lint:mr
Expand All @@ -18,7 +18,7 @@ Check files for formatting issues:
pnpm lint:format
```

Validate package publishing best practices:
Validate package publishing best practices (applies to projects in `packages` folder):

```bash
pnpm lint:packages
Expand All @@ -35,9 +35,3 @@ Verify monorepo best practice:
```bash
pnpm lint:monorepo
```

Find unused exports:

```bash
pnpm lint:knip
```
4 changes: 2 additions & 2 deletions docs/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"include": ["src"],
"exclude": ["node_modules", "dist", "coverage"],
"compilerOptions": {
"types": ["vitest/globals"],
},
"types": ["vitest/globals"]
}
}
3 changes: 2 additions & 1 deletion lint-staged.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
'*': ['secretlint', 'prettier --cache --write --ignore-unknown'],
'**/package.json': ['node ./publint.js', 'npx syncpack lint --config .syncpackrc', 'manypkg check'],
'*.{cjs,js,jsx,ts,tsx}': ['nx affected -t lint --fix --files'],
'*.{ts,tsx}': ['nx affected -t test --files'],
'*.{ts,tsx}': ['nx affected -t test --files', 'npx nx run-many -t lint:knip'],
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
"commit": "git-cz",
"delete": "rimraf pnpm-lock.yaml .nx node_modules",
"lint:secrets": "npx secretlint **/*",
"lint:format": "prettier --check .",
"lint:format": "prettier --write .",
"lint:packages": "node ./publint.js",
"lint:deps": "npx syncpack lint --config .syncpackrc",
"lint:monorepo": "npx manypkg check",
"lint:knip": "knip --exports",
"lint:mr": "run-p lint:secrets lint:format lint:packages lint:deps lint:monorepo lint:knip",
"lint:mr": "run-p lint:secrets lint:format lint:packages lint:deps lint:monorepo",
"nx:graph": "npx nx graph",
"update:deps": "npx syncpack update",
"list:deps": "npx syncpack list",
"list:packages": "lerna ls -l -all",
"list:changed": "lerna changed -l -all",
"dev": "npx nx run-many -t dev",
"lint:knip": "npx nx run-many -t lint:knip",
"lint": "npx nx run-many -t lint",
"test": "npx nx run-many -t test",
"test:watch": "npx nx run-many -t test:watch",
Expand All @@ -50,7 +50,7 @@
"@lerna-lite/version": "3.3.1",
"@manypkg/cli": "0.21.3",
"@nrwl/cli": "15.9.3",
"@nrwl/nx-cloud": "16.5.2",
"@nrwl/nx-cloud": "18.0.1",
"@secretlint/secretlint-rule-preset-recommend": "8.1.2",
"@types/node": "20.11.30",
"commitizen": "4.3.0",
Expand Down
1 change: 1 addition & 0 deletions packages/basic-math/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"README.md"
],
"scripts": {
"lint:knip": "knip --exports",
"lint": "eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
"test": "jest --coverage",
"test:watch": "jest --watch",
Expand Down
4 changes: 2 additions & 2 deletions packages/basic-math/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist", "coverage"],
"compilerOptions": {
"baseUrl": "./",
},
"baseUrl": "./"
}
}
1 change: 1 addition & 0 deletions packages/parity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"README.md"
],
"scripts": {
"lint:knip": "knip --exports",
"lint": "eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
"test": "jest --coverage",
"test:watch": "jest --watch",
Expand Down
4 changes: 2 additions & 2 deletions packages/parity/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist", "coverage"],
"compilerOptions": {
"baseUrl": "./",
},
"baseUrl": "./"
}
}
1 change: 1 addition & 0 deletions packages/tokens-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"**/*.css"
],
"scripts": {
"lint:knip": "knip --exports",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"build": "tsc --p ./tsconfig.build.json && vite build",
"clean": "rimraf dist coverage tsconfig.build.tsbuildinfo"
Expand Down
4 changes: 2 additions & 2 deletions packages/tokens-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"outDir": "dist",
"baseUrl": "./",
"declaration": true,
"declarationMap": true,
},
"declarationMap": true
}
}
Loading

0 comments on commit bd64862

Please sign in to comment.