From 879bdf71f87e32f63372ba9b03bdaf36ed7b28c8 Mon Sep 17 00:00:00 2001 From: waldronmatt Date: Tue, 12 Sep 2023 19:51:21 -0400 Subject: [PATCH] fix(workspace): add syncpack for dep mgmt and update root eslint to fix errors --- .eslintrc.cjs | 16 ++++++++++++++-- .syncpackrc | 24 ++++++++++++++++++++++++ README.md | 4 +++- package.json | 6 +++--- pnpm-lock.yaml | 5 +---- 5 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 .syncpackrc diff --git a/.eslintrc.cjs b/.eslintrc.cjs index f8482941..0c24d7fe 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,6 +1,18 @@ module.exports = { root: true, - extends: ['custom/js.cjs'], - // only lint monorepo root and configs files + env: { + node: true, + es2020: true, + }, + extends: ['eslint:recommended', 'plugin:import/recommended', 'airbnb-base'], + rules: { + 'import/no-extraneous-dependencies': [ + 'error', + { + devDependencies: true, + }, + ], + 'linebreak-style': 0, + }, ignorePatterns: ['apps/**', 'packages/**'], }; diff --git a/.syncpackrc b/.syncpackrc new file mode 100644 index 00000000..9aa3140c --- /dev/null +++ b/.syncpackrc @@ -0,0 +1,24 @@ +{ + "semverRange": "^", + "source": [ + "package.json", + "apps/*/package.json", + "configs/*/package.json", + "packages/*/package.json" + ], + "semverGroups": [ + { + "packages": [ + "@waldronmatt/**", + "eslint-config-custom", + "tsconfig-config", + "jest-config", + "vite-project" + ], + "dependencies": [ + "**" + ], + "isIgnored": true + } + ] +} diff --git a/README.md b/README.md index 4f37c0a5..fd6e7c2e 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ pnpm dev Lint files: +**Note**: Since `vite-project` depends on linked packages, a linting error will occur if `pnpm build` has not run at least once first. + ```bash pnpm lint ``` @@ -126,7 +128,7 @@ Delete workspace root `node_modules` and `pnpm-lock.yaml` files: pnpm clear ``` -Lint root and `configs/` `js/cjs` files, check for secrets, validate published packages, and verify monorepo best practices: +Lint root and `configs/` `js/cjs` files, check for secrets, lint dependency versions, validate published packages, and verify monorepo best practices: ```bash pnpm lint:mr diff --git a/package.json b/package.json index 9f12c64d..c8eb030a 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "lint:secrets": "npx secretlint **/*", "lint:publish": "npx publint", "lint:package": "npx manypkg check", - "lint:mr": "run-p lint:js lint:secrets lint:publish lint:package", + "lint:deps": "syncpack lint-semver-ranges --config .syncpackrc", + "lint:mr": "run-p lint:js lint:secrets lint:deps lint:publish lint:package", "dev": "npx nx run-many -t dev", "lint": "npx nx run-many -t lint", "test": "npx nx run-many -t test", @@ -44,12 +45,11 @@ "@lerna-lite/version": "^2.5.1", "@manypkg/cli": "^0.21.0", "@nrwl/cli": "^15.9.3", - "@nrwl/nx-cloud": "16.4.0", + "@nrwl/nx-cloud": "^16.4.0", "@secretlint/secretlint-rule-preset-recommend": "^7.0.7", "commitizen": "^4.3.0", "cz-conventional-changelog": "^3.3.0", "eslint": "^8.49.0", - "eslint-config-custom": "workspace:^", "husky": "^8.0.3", "lint-staged": "^13.3.0", "npm-run-all": "^4.1.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 44be1196..94ab2f92 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,7 +33,7 @@ importers: specifier: ^15.9.3 version: 15.9.3 '@nrwl/nx-cloud': - specifier: 16.4.0 + specifier: ^16.4.0 version: 16.4.0 '@secretlint/secretlint-rule-preset-recommend': specifier: ^7.0.7 @@ -47,9 +47,6 @@ importers: eslint: specifier: ^8.49.0 version: 8.49.0 - eslint-config-custom: - specifier: workspace:^ - version: link:configs/eslint-config-custom husky: specifier: ^8.0.3 version: 8.0.3