Skip to content

JS dep inference: refine handling of pants: no-infer-dep on multi-line statements  #20207

Open
@huonw

Description

@huonw

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

In the JavaScript backend, we're not 100% sure the handling of // pants: no-infer-dep on multi-line statements is exactly what we want. Currently, it has to be applied to the last line of the statement. This might be confusing.

Tests from #20190:

import {
     a
} from 'ignored'; // pants: no-infer-dep
export {
   a
} from 'ignored'; // pants: no-infer-dep
require(
   'ignored'
) // pants: no-infer-dep
import(
   'ignored'
) // pants: no-infer-dep


import { // pants: no-infer-dep
   a
} from 'accepted';
import {
   c  // pants: no-infer-dep
} from 'accepted';

export { // pants: no-infer-dep
   a
} from 'b';
export {
   c // pants: no-infer-dep
} from 'd';

require( // pants: no-infer-dep
   'accepted'
);
require(
   'accepted' // pants: no-infer-dep
)

import( // pants: no-infer-dep
   'accepted'
);
import(
   'accepted' // pants: no-infer-dep
)

Describe the solution you'd like

Someone to make a decision about which of the above lines (and any others, like "partial" ignores below (which don't make sense) or extreme syntax) should ignore or not.

import {
   b,
   c  // pants: no-infer-dep
} from 'some-module';

Preferably, any pants: no-infer-dep comments that aren't used are an error and/or warning too, because that indicates that we're likely doing something unexpected: the user was trying to ignore a dep but didn't do it exactly right.

We should probably also look at other tools in the JS ecosystem so that we can do something that is familiar to users and/or preserved by tools like auto-formatters.

Describe alternatives you've considered
N/A

Additional context

Discussed in #20190, and #20190 (comment) is of particular interest.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions