sindresorhus/eslint-plugin-unicorn

no-empty-file should be configurable

Fechada

#2.218 aberto em 8 de nov. de 2023

 (5 comentários) (1 reação) (0 responsável)JavaScript (468 forks)user submission
enhancementgood for beginnerhelp wanted

Métricas do repositório

Stars
 (5.022 estrelas)
Métricas de merge de PR
 (Mesclagem média 4h 30m) (26 fundiu PRs em 30d)

Description

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

Guia do colaborador