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

[PSC-2029] Allow configuring the lint command via CLI arguments #2153

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

flavray
Copy link
Contributor

@flavray flavray commented Nov 17, 2023

Description, Motivation and Context

The lint command can be configured with a LintConfig. However, this LintConfig is currently hardcoded in lint.ts and cannot be changed via command-line arguments.

This PR adds the ability to configure the lint command in the CLI.

This allows running things like:

$ spot lint api.ts --has-discriminator=error
$ spot lint api.ts --no-nullable-arrays=off

The help command now returns:

$ spot lint api.ts --help

Lint a Spot contract

USAGE
  $ spot lint SPOT_CONTRACT

ARGUMENTS
  SPOT_CONTRACT  path to Spot contract

OPTIONS
  -h, --help                                                     show CLI help
  --has-discriminator=(error|warn|off)                           Setting for has-discriminator
  --has-request-payload=(error|warn|off)                         Setting for has-request-payload
  --has-response=(error|warn|off)                                Setting for has-response
  --has-response-payload=(error|warn|off)                        Setting for has-response-payload
  --no-inline-objects-within-unions=(error|warn|off)             Setting for no-inline-objects-within-unions
  --no-nullable-arrays=(error|warn|off)                          Setting for no-nullable-arrays
  --no-nullable-fields-within-request-bodies=(error|warn|off)    Setting for no-nullable-fields-within-request-bodies
  --no-omittable-fields-within-response-bodies=(error|warn|off)  Setting for no-omittable-fields-within-response-bodies

EXAMPLE
  $ spot lint api.ts
  $ spot lint --has-descriminator=error
  $ spot lint --no-nullable-arrays=off

Checklist:

  • I've added/updated tests to cover my changes
  • I've created an issue associated with this PR

The `lint` command can be configured with a `LintConfig`. However, this
`LintConfig` is currently hardcoded in `lint.ts` and cannot be changed
via command-line arguments.

This PR adds the ability to configure the `lint` command in the CLI.

This allows running things like:

```
$ spot lint api.ts --has-discriminator=error
$ spot lint api.ts --no-nullable-arrays=off
```

The `help` command now returns:

```
$ spot lint api.ts --help

Lint a Spot contract

USAGE
  $ spot lint SPOT_CONTRACT

ARGUMENTS
  SPOT_CONTRACT  path to Spot contract

OPTIONS
  -h, --help                                                     show CLI help
  --has-discriminator=(error|warn|off)                           Setting for has-discriminator
  --has-request-payload=(error|warn|off)                         Setting for has-request-payload
  --has-response=(error|warn|off)                                Setting for has-response
  --has-response-payload=(error|warn|off)                        Setting for has-response-payload
  --no-inline-objects-within-unions=(error|warn|off)             Setting for no-inline-objects-within-unions
  --no-nullable-arrays=(error|warn|off)                          Setting for no-nullable-arrays
  --no-nullable-fields-within-request-bodies=(error|warn|off)    Setting for no-nullable-fields-within-request-bodies
  --no-omittable-fields-within-response-bodies=(error|warn|off)  Setting for no-omittable-fields-within-response-bodies

EXAMPLE
  $ spot lint api.ts
  $ spot lint --has-descriminator=error
  $ spot lint --no-nullable-arrays=off
```
@CLAassistant
Copy link

CLAassistant commented Nov 17, 2023

CLA assistant check
All committers have signed the CLA.

@flavray flavray requested a review from njday November 17, 2023 02:03
@flavray flavray marked this pull request as ready for review November 17, 2023 02:03
@flavray flavray requested a review from a team as a code owner November 17, 2023 02:03
Copy link

@njday njday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@flavray flavray merged commit 1601fb9 into master Nov 17, 2023
6 checks passed
@flavray flavray deleted the PSC-2029-configure-lint-cli branch November 17, 2023 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants