Skip to content

require-jsdoc: contexts and publicOnly lead to false negatives #492

@gustavderdrache

Description

@gustavderdrache

I'm using the publicOnly option on a TypeScript project, and while the contexts option is checked, the plugin is failing to find public interfaces that aren't documented.

More specifically, this pattern isn't being caught by jsdoc/require-jsdoc:

// Should be flagged for having no docs...
interface SomeComponentProps {
  foo: number;
}

const SomeComponent: React.FC<SomeComponentProps> = () => null;

// ... due to this export.
export { SomeComponentProps };
export default SomeComponent;

I experimented with the repo to see if I could isolate a test case, and I was (see below). When publicOnly is set to true, the interface isn't discovered as exported (the code option here is borrowed from another of the TS tests):

    {
      // This should raise 1 error but won't
      code: `
      export interface Foo extends Bar {
        baz(): void;
        meow(): void;
      }
      `,
      errors: [{
        message: 'Missing JSDoc comment.',
        type: 'TSInterfaceDeclaration',
      }],
      options: [{
        contexts: [
          'TSInterfaceDeclaration',
        ],
        publicOnly: true, // commenting out this line will result in a successful test
      }],
      parser: require.resolve('@typescript-eslint/parser'),
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions