FluidFramework/build-tools/syncpack.config.cjs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

185 строки
4.5 KiB
JavaScript
Исходник Обычный вид История

/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
module.exports = {
indent: "\t",
// Custom types are used to define additional fields in package.json that contain versions that should be
// checked/synced. See https://jamiemason.github.io/syncpack/config/custom-types for more details.
customTypes: {
engines: {
path: "engines",
strategy: "versionsByName",
},
packageManager: {
path: "packageManager",
strategy: "name@version",
},
},
/**
* SemverGroups are used to ensure that groups of packages use the same semver range for dependencies.
*
* semverGroup rules are applied in order to package/dep combinations. First matching rule applies. When running
* `syncpack lint-semver-ranges`, the output is grouped by label.
*/
semverGroups: [
{
label: "engines.node should always use >= ranges",
dependencyTypes: ["engines"],
dependencies: ["node"],
packages: ["**"],
range: ">=",
},
{
label: "engines.npm should always use caret ranges",
dependencyTypes: ["engines"],
dependencies: ["npm"],
packages: ["**"],
range: "^",
},
{
label: "packageManager should always use exact dependency ranges",
dependencyTypes: ["packageManager"],
dependencies: ["**"],
packages: ["**"],
range: "",
},
{
label: "Overridden server dependencies should always be exact versions",
dependencyTypes: ["pnpmOverrides"],
dependencies: [
"@fluidframework/gitresources",
"@fluidframework/protocol-base",
"@fluidframework/server-*",
],
packages: ["**"],
range: "",
},
{
label: "Deps in pnpm overrides should use caret dependency ranges",
dependencyTypes: ["pnpmOverrides"],
dependencies: ["**"],
packages: ["**"],
range: "^",
},
{
label: "Must use exact dependency ranges",
2024-05-28 20:03:41 +03:00
dependencies: ["jssm", "jssm-viz-cli", "sort-package-json"],
packages: ["**"],
range: "",
},
// Some dependencies, like typescript and eslint, recommend to use tilde deps because minors introduce
// changes that may break linting
{
label: "Must use tilde dependency ranges",
dependencies: [
"@biomejs/biome",
"eslint-plugin-*",
"eslint-config-prettier",
"eslint",
"less",
"prettier",
"typescript",
"vue",
"webpack-dev-server",
],
packages: ["**"],
range: "~",
},
{
build(build-tools): Use biome for formatting instead of prettier (#19113) ## Summary Converts build-tools to use [biome](https://biomejs.dev/formatter/) for formatting instead of prettier. Biome is a web toolkit written in Rust. It includes a JS/TS formatter that is _much_ faster than prettier. Biome formats all of build tools in **~50ms**. ## Limitations - Biome does not format [a handful of "protected files"](https://biomejs.dev/guides/how-biome-works/#protected-files) including package.json and tsconfig.json (!!!). I imagine this will change in the future. For now, prettier is still used to format ONLY package.json and tsconfig.json. - It's not clear how well the biome VSCode extension works compared to the prettier one. Format on save should continue to work, but I haven't tested exhaustively. - fluid-build does not cache the results of format:biome tasks because it has no support. Support could be added in a separate PR. - The prettier tasks are also not cached anymore because fluid-build doesn't understand the commandline arguments. Can be fixed in a separate PR if needed. - The build-tools release group is not converted to use release-group-level tasks with fluid-build (i.e. tasks defined in the root package.json). That can be done separately and will require some updates to the formatting task definitions at that time. ## Implementation details - Added the biome dependencies and added a biome.json config file to the build-tools release group root. - Updated prettierignore files to ignore everything except package.json and tsconfig.json. - Added new tasks to the projects: - "check:biome": checks formatting using biome - "check:format": calls check:biome and check:prettier - "check:prettier": checks formatting using prettier -- this replaces the existing "prettier" task - "format:biome": formats using biome - "format:prettier": formats using prettier -- this replaces the existing "prettier:fix" task - "format": this script was already present and has been updated to call format:biome and format:prettier - Updated fluid-build config to understand the new tasks and their relationships. Primarily that "check:prettier" is a replacement for "prettier".
2024-03-06 04:11:28 +03:00
label:
"Dependencies on other fluid packages within the workspace should use tilde dependency ranges",
dependencies: [
"@fluid-private/readme-command",
"@fluid-tools/build-cli",
"@fluid-tools/version-tools",
"@fluidframework/build-tools",
"@fluidframework/bundle-size-tools",
],
packages: ["**"],
range: "~",
},
// All deps should use caret ranges unless previously overridden
{
label: "Dependencies should use caret dependency ranges",
dependencies: ["**"],
dependencyTypes: ["dev", "peer", "prod"],
packages: ["**"],
range: "^",
},
],
/**
* VersionGroups are used to ensure that groups of packages use the same version of dependencies.
*
* versionGroup rules are applied in order to package/dep combinations. First matching rule applies. When running
* `syncpack list-mismatches`, the output is grouped by label.
*/
versionGroups: [
2024-05-28 20:03:41 +03:00
{
label: "chalk >2 is ESM only but build-tools and version-tools are still CJS only.",
dependencies: ["chalk"],
packages: ["@fluidframework/build-tools", "@fluid-tools/version-tools"],
},
{
label: "Versions of common Fluid packages should all match",
dependencies: [
"@fluidframework/build-common",
"@fluidframework/common-utils",
"@fluidframework/eslint-config-fluid",
],
packages: ["**"],
},
{
label: "Versions in engines field should all match",
dependencyTypes: ["engines"],
dependencies: ["**"],
packages: ["**"],
},
{
label: "Versions in packageManager field should all match",
dependencyTypes: ["packageManager"],
dependencies: ["**"],
packages: ["**"],
},
{
build(build-tools): Use biome for formatting instead of prettier (#19113) ## Summary Converts build-tools to use [biome](https://biomejs.dev/formatter/) for formatting instead of prettier. Biome is a web toolkit written in Rust. It includes a JS/TS formatter that is _much_ faster than prettier. Biome formats all of build tools in **~50ms**. ## Limitations - Biome does not format [a handful of "protected files"](https://biomejs.dev/guides/how-biome-works/#protected-files) including package.json and tsconfig.json (!!!). I imagine this will change in the future. For now, prettier is still used to format ONLY package.json and tsconfig.json. - It's not clear how well the biome VSCode extension works compared to the prettier one. Format on save should continue to work, but I haven't tested exhaustively. - fluid-build does not cache the results of format:biome tasks because it has no support. Support could be added in a separate PR. - The prettier tasks are also not cached anymore because fluid-build doesn't understand the commandline arguments. Can be fixed in a separate PR if needed. - The build-tools release group is not converted to use release-group-level tasks with fluid-build (i.e. tasks defined in the root package.json). That can be done separately and will require some updates to the formatting task definitions at that time. ## Implementation details - Added the biome dependencies and added a biome.json config file to the build-tools release group root. - Updated prettierignore files to ignore everything except package.json and tsconfig.json. - Added new tasks to the projects: - "check:biome": checks formatting using biome - "check:format": calls check:biome and check:prettier - "check:prettier": checks formatting using prettier -- this replaces the existing "prettier" task - "format:biome": formats using biome - "format:prettier": formats using prettier -- this replaces the existing "prettier:fix" task - "format": this script was already present and has been updated to call format:biome and format:prettier - Updated fluid-build config to understand the new tasks and their relationships. Primarily that "check:prettier" is a replacement for "prettier".
2024-03-06 04:11:28 +03:00
label:
"Ignore interdependencies on other Fluid packages. This is needed because syncpack doesn't understand our >= < semver ranges",
isIgnored: true,
packages: [
"@fluid-example/**",
"@fluid-experimental/**",
"@fluid-internal/**",
"@fluid-private/**",
"@fluid-tools/**",
"@fluidframework/**",
"fluid-framework",
],
dependencies: [
"@fluid-example/**",
"@fluid-experimental/**",
"@fluid-internal/**",
"@fluid-private/**",
"@fluid-tools/**",
"@fluidframework/**",
"fluid-framework",
],
},
],
};