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

Ability to define linter ruleset in a file #3011

Closed
timotheeguerin opened this issue Mar 12, 2024 · 3 comments
Closed

Ability to define linter ruleset in a file #3011

timotheeguerin opened this issue Mar 12, 2024 · 3 comments

Comments

@timotheeguerin
Copy link
Member

timotheeguerin commented Mar 12, 2024

This would allow us to have the spec repo define the set of rule they want to onboard/disable without being blocked by the azure core packages release as well as combining from multiple sources.

Proposal

Allow to extends ruleset from a file. The file must be yaml and in the same structure as the ruleset structure today

interface RuleSet {
  extends?: string[]
  enable?: Record<string, boolean;
  disable?: Record<string, string>;
}

Usage

To use a file instead of extending a ruleset defined in a package name we can point to the file with the file: prefix

linter:
  extends: 
    - file:path/to/file.yaml

Example

Example file content

extends: 
  - "@typespec/best-practices/recommended"
  - "@typespec/http/recommended"
enable: 
  "@typespec/best-practices/new-rule": true 
disable: 
  "@typespec/best-practices/foo": "This rule is too much"

Example usage:

In tspconfig.yaml

linter:
  extends: 
    - file:./../my-common-rules.yaml

Example of what the azure-rest-api-specs repo could do

linter:
  extends: 
    - file:../../../typespec-rulesets/data-plane.yaml
    - file:../../../typespec-rulesets/arm.yaml # or

Other uses

this pattern would also enable use to have a linter rule versioning system where we create a new ruleset file when we add new linter rule and yopu need to use the latest when you update

@markcowl
Copy link
Contributor

est: 8

@markcowl
Copy link
Contributor

Decided not to take this up for now, but see if there is interest in this in the community

@allenjzhang
Copy link
Member

Closing in favor of Azure/typespec-azure#654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants