sindresorhus/eslint-plugin-unicorn

no-empty-file should be configurable

Open

#2,218 创建于 2023年11月8日

在 GitHub 查看
 (5 评论) (1 反应) (0 负责人)JavaScript (5,022 star) (468 fork)user submission
enhancementgood for beginnerhelp wanted

描述

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

贡献者指南