sindresorhus/eslint-plugin-unicorn

no-empty-file should be configurable

已關閉

#2,218 建立於 2023年11月8日

 (5 則留言) (1 個反應) (0 位負責人)JavaScript (468 個分叉)user submission
enhancementgood for beginnerhelp wanted

倉庫指標

星標
 (5,022 顆星)
PR 合併指標
 (平均合併 1天 16小時) (30 天內合併 399 個 PR)

描述

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'] }]
    },
  }
]

貢獻者指南