sindresorhus/eslint-plugin-unicorn

no-empty-file should be configurable

クローズ

#2,218 opened on 2023/11/08

 (5 件のコメント) (1 件のリアクション) (0 人の担当者)JavaScript (468 件のフォーク)user submission
enhancementgood for beginnerhelp wanted

Repository metrics

Stars
 (5,022 個のスター)
PR merge metrics
 (平均マージ 1d 16h) (30d で 399 merged PRs)

説明

no-empty-file isn't configurable

A file with comments but without code is considered empty. More finesse would be appreciated.

Example: I would like to disallow empty files in general, but I would like to allow *.test.ts(x) files to contain only comments

Use case:

// File: useScreenSizeHint.test.ts
// No need to write tests here, useScreenSizeHint.ts source code is already tested by ScreenSizeHintProvider.test.tsx

ESLint configuration:

rules: {
  'unicorn/no-empty-file': 'error'
},
overrides: [
  {
    files: ['**/*.test.ts', '**/*.test.tsx'],
    rules: {
      // Empty test files with comments are legit
      'unicorn/no-empty-file': ['error', { allow: ['comments'] }]
    },
  }
]

コントリビューターガイド