Skip to content
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

User-defined extended diagnostics #48117

Open
CSchulz opened this issue Nov 18, 2022 · 3 comments
Open

User-defined extended diagnostics #48117

CSchulz opened this issue Nov 18, 2022 · 3 comments
Labels
area: compiler Issues related to `ngc`, Angular's template compiler compiler: extended diagnostics feature: under consideration Feature request for which voting has completed and the request is now under consideration feature Issue that requests a new feature P4 A relatively minor issue that is not relevant to core functions
Milestone

Comments

@CSchulz
Copy link

CSchulz commented Nov 18, 2022

Which @angular/* package(s) are relevant/related to the feature request?

compiler-cli

Description

With great pleasure I looked at the new possibilities of extended diagnostics, but unfortunately I found out that there is no possibility to extend it myself.

For the moment I can patch the execution to inject some own checks but it feels not awesome.

Proposed solution

I think a good way to add some own rules would be a similar system like the builders schema.
You define within a checks.json file all supported rules, each rule can have a schema.json file to handle all configuration parameters.

{
  "checks": {
    "custom-check": {
      "implementation": "./custom-check",
      "schema": "./custom-check/schema.json",
      "description": "checks some custom stuff."
    },
    "custom-check-without-configuration": {
      "implementation": "./custom-check-without-configuration",
      "description": "checks some custom stuff."
    }
  }
}

The angular.json file contains a list of extending check sets on root level (same level as projects) and load all rules during build, serve, etc.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "projects": {
  },
  "extendedDiagnosticsExtensions": [
    "./local-provided-custom-checks",
    "@npm-provided/custom-checks"
  ]
}

The tsconfig.json file lists all checks also custom ones. If a custom one is not listed, it won't be enabled.

{
  "angularCompilerOptions": {
    "extendedDiagnostics": {
      // The categories to use for specific diagnostics.
      "checks": {
        // Maps check name to its category.
        "invalidBananaInBox": "suppress",
        "customCheck": "error",
        "customCheckWithoutConfiguration": "suppress",
      },

      // The category to use for any diagnostics not listed in `checks` above.
      "defaultCategory": "error"
    }
  }
}

Alternatives considered

to be considered

@dylhunn dylhunn added feature Issue that requests a new feature area: compiler Issues related to `ngc`, Angular's template compiler compiler: extended diagnostics labels Nov 21, 2022
@ngbot ngbot bot modified the milestone: Backlog Nov 21, 2022
@dylhunn dylhunn added the P4 A relatively minor issue that is not relevant to core functions label Nov 21, 2022
@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Nov 22, 2022
@angular-robot
Copy link
Contributor

angular-robot bot commented Nov 22, 2022

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

@dgp1130
Copy link
Contributor

dgp1130 commented Nov 29, 2022

We've discussed supporting custom extended diagnostics in the past, and I think we're generally interested in supporting that, though it has some usability and security considerations to work through and hasn't been prioritized. Please upvote if anyone is interested!

/cc @JamesHenry @piotrtomiak who've expressed interest.

@dgp1130 dgp1130 added feature: under consideration Feature request for which voting has completed and the request is now under consideration and removed feature: votes required Feature request which is currently still in the voting phase labels Nov 29, 2022
@dgp1130 dgp1130 changed the title Extended diagnostics: Add extension point for own checks User-defined extended diagnostics Nov 29, 2022
@Harpush
Copy link

Harpush commented Feb 2, 2023

That's a great idea! I recently wanted to write an ESLint rule that involved component ts AST info and got stuck. Using extended diagnostic for it could be awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: compiler Issues related to `ngc`, Angular's template compiler compiler: extended diagnostics feature: under consideration Feature request for which voting has completed and the request is now under consideration feature Issue that requests a new feature P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

4 participants