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

[lint-ignore][feature] wildcard path to ignored files #1888

Closed
Thiebosh opened this issue Feb 6, 2025 · 3 comments
Closed

[lint-ignore][feature] wildcard path to ignored files #1888

Thiebosh opened this issue Feb 6, 2025 · 3 comments

Comments

@Thiebosh
Copy link

Thiebosh commented Feb 6, 2025

Is your feature request related to a problem? Please describe.

I work with a big api (~500 enpoints and ~1400 jsonSchemas) and for jsonSchemas, we use special keywords at root level for specific use (ihm, code gen...) that are out of openapi specification. Since @redocly/[email protected], the struct rule is triggered by those special keywords, which cause the linter to output +10k errors (or warning, depending on severity setted), all linked to them.

our problems :

  • We tried to customize the rule without luck
  • We can't use (maintain) the lint-ignore file since he is too big (~5k lines) because of the precise relative paths
  • We want to keep the structure rule validation

Describe the solution you'd like

The simplest solution would be to use wildcards in lint-ignore file. It would allow us to go from :

openapi/components/schemas/domainA/subDomainA/objectA.json:
  struct:
    - '#/javaType'
openapi/components/schemas/domainA/subDomainA/subsubDomainA/objectAA.json:
  struct:
    - '#/javaType'
...
openapi/components/schemas/domainA/subDomainZ/subsubDomainZ/objectZY.json:
  struct:
    - '#/javaType'

to something like :


openapi/components/schemas/**/*.json:
  struct:
    - '#/javaType'

or with magic matchers :

_schema.yaml:
  struct:
    - '#/javaType'
_schema.json:
  struct:
    - '#/javaType'

Describe alternatives you've considered

We tried to customize struct rule, or to turn it off and fork it's code from redocly repository, but we simply turned it off to keep the lib up to date

Additional context

wildcards are already in use for join command

@Thiebosh Thiebosh changed the title [lint-ignore] wildcard path to ignored files [lint-ignore][feature] wildcard path to ignored files Feb 6, 2025
@tatomyr
Copy link
Contributor

tatomyr commented Feb 7, 2025

@Thiebosh looks like you're looking for the wrong solution for your problem 🙂. Instead of ignoring the errors, you can extend the existing Schema type using typeExtension.

Your plugin might look like this:

export default () => ({
  id: 'my-type-extension',
  typeExtension: {
    oas3(types) {
      return {
        ...types,
        Schema: {
          ...types.Schema,
          properties: {
            ...types.Schema.properties,
            javaType: { type: 'string' }, // <-- here you extend the predefined type with the keywords you need to add.
          },
        },
      };
    },
  },
});

@Thiebosh
Copy link
Author

Thiebosh commented Feb 7, 2025

actually, I missed this plugin. This solves (most of) my problem, thank you!

still, could you consider using wildcards in lint-ignore on further release ?

@tatomyr
Copy link
Contributor

tatomyr commented Feb 7, 2025

There's no point in using wildcards there. The lint-ignore file is meant to be autogenerated (see the docs) and should not be manually modified. Ignoring should be used sparingly, as it hides actual problems that should rather be fixed or worked around in another way. Introducing wildcards will make things even worse, I believe, as problem cases will be ignored implicitly.

Since your problem is solved, I'm closing the issue. Cheers!

@tatomyr tatomyr closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2025
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

2 participants