sindresorhus/eslint-plugin-unicorn

Rule proposal: `id-match`

已关闭

#1,545 创建于 2021年10月11日

 (9 条评论) (1 个反应) (0 位负责人)JavaScript (468 个派生)user submission
help wantednew rule

仓库指标

星标
 (5,022 个星标)
PR 合并指标
 (平均合并 4小时 30分钟) (30 天内合并 26 个 PR)

描述

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.

贡献者指南