-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(config-nx-scopes): support inferred targets #4113
Comments
Thanks! Maybe @fguitton has some feedback to this |
In general, I wonder whats the purpose of filtering projects without targets - why are you not allowed to use a scope e.g |
Hello @RobbyRabbitman, the answer to your question is rather simple, the implementation of Perhaps it is time for an overhaul to help bring more flexible configurations inspired by the current Nx |
If you don't want to have empty targets in your project.json files, you can copy pasta this config and adjust it to your needs until an official release. import { RuleConfigSeverity, type UserConfig } from '@commitlint/types';
import { readCachedProjectGraph } from '@nx/devkit';
const getNxProjects = () => Object.keys(readCachedProjectGraph().nodes);
export default {
// extends: ['@commitlint/config-conventional', '@commitlint/config-nx-scopes'],
extends: ['@commitlint/config-conventional'],
rules: {
'scope-enum': () => [RuleConfigSeverity.Error, 'always', getNxProjects()],
},
} satisfies UserConfig; |
Expected Behavior
Respect inferred tasks: https://nx.dev/concepts/inferred-tasks
Current Behavior
In a nx repo, I have a project which has inferred tasks only: There is no
targets
object in the json, the project itself has targets inferred by nx plugins.commitlint output:
If there is an empty
targets
object, it works as expected:⧗ input: docs(tools-eslint): explain eslint set up ✔ found 0 problems, 0 warnings
Affected packages
Possible Solution
Nx has a public api for getting the projects of a workspace in
@nx/devkit
, maybereadCachedProjectGraph()
is a good fit. This could even improve performance, because right now a filesystem is created and then projects are parsed:commitlint/@commitlint/config-nx-scopes/index.js
Line 20 in 4b204ec
Idk exactly how
FsTree
works but if it just represents the file system, then the current behavior makes sense because the inferred targets are not written to the file system at any time: Therefore thefilter()
predicate checks not the presence of the actual targets of a project => inferred targets are missing.commitlint/@commitlint/config-nx-scopes/index.js
Line 33 in 4b204ec
idk if these imports are public api: If they are not, using
@nx/devkit
would be a good refactor anyways.commitlint/@commitlint/config-nx-scopes/index.js
Lines 2 to 3 in 4b204ec
Context
No response
The text was updated successfully, but these errors were encountered: