sindresorhus/eslint-plugin-unicorn

Rule proposal: `id-match`

Chiusa

#1545 aperta il 11 ott 2021

 (9 commenti) (1 reazione) (0 assegnatari)JavaScript (468 fork)user submission
help wantednew rule

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 4h 30m) (26 PR mergiate in 30 g)

Descrizione

When working with external libraries, it is often undesirable to rename their exports for the sole purpose of conforming with id-match rule.

This has been proposed as addition to ESLint in https://github.com/eslint/eslint/issues/14005, but ultimately it was rejected:

I think this falls under our policies of not adding new options to stylistic rules, so in my opinion the best course of action would be to make a custom rule/plugin.

This rule would be equivalent to id-match with an additional option ignoreImports that would ignore named imports.

Fail

Assuming that rule does not permit IDs with $:

const ContraImageFragment$key = '';

Pass

Assuming that this rule is configured to ignore imports:

import type { ContraImageFragment$key } from '@/__generated__/ContraImageFragment.graphql';

Happy to contribute to the codebase.

Guida contributor