prefer-rolling-workspace-spec
💡 This rule is manually fixable by editor suggestions.
This rule requires that dependencies declared with workspace protocol use a rolling workspace spec instead of a specific semver range.
Using workspace: protocol, you can either specify a “rolling” notation to use whatever the target workspace version happens to be at publish time, or you can use a specific semver range.
For example, if you have packages foo, bar, qar, zoo in the workspace and they all are at version 1.5.0, the following:
{ "dependencies": { "foo": "workspace:*", "bar": "workspace:~", "qar": "workspace:^", "zoo": "workspace:^1.5.0" }}Will be transformed into the following at pack/publish time.
{ "dependencies": { "foo": "1.5.0", "bar": "~1.5.0", "qar": "^1.5.0", "zoo": "^1.5.0" }}In this example, the first three are using “rolling” notation, while zoo is using a specific semver range.
This rule enforces that all use of workspace: protocol should use “rolling” notation, instead of locking it to a specific semver range.
There are valid cases for both, and so this isn’t a recommendation one way or the other. But in case your project standards are to have all packages published together, with each referencing the latest version of the others, this rule could be used to enforce that.
Examples
Section titled “Examples”{ "dependencies": { "abc": "workspace:1.2.3", "ghi": "workspace:^1.2.3", "ghi": "workspace:~1.2.3", "jkl": "workspace:>=1.2.3", "mno": "workspace:>1.2.3", "pqr": "workspace:<=1.2.3", "stu": "workspace:<1.2.3" }}{ "dependencies": { "abc": "workspace:*", // or "workspace:" "ghi": "workspace:^", "ghi": "workspace:~" }}Options
Section titled “Options”| Name | Description | Type |
|---|---|---|
ignoreDependencies |
Specific dependencies to ignore. | Array |
ignorePatterns |
Regex patterns for dependency names to ignore. | Array |
ignoreDependencies
Section titled “ignoreDependencies”Define an array of specific script names that should be ignored by this rule.
{ "prefer-rolling-workspace-spec": [ "error", { "ignoreDependencies": [ "@typescript-eslint/types", "@typescript-eslint/utils" ] } ]}ignorePatterns
Section titled “ignorePatterns”Define an array of regex patterns that should be ignored by this rule.
{ "prefer-rolling-workspace-spec": [ "error", { "ignorePatterns": ["@typescript-eslint/.*"] } ]}Related Rules
Section titled “Related Rules”valid-dependencies- Enforces that thedependenciesproperty is valid.valid-devDependencies- Enforces that thedevDependenciesproperty is valid.