eslint-plugin-unicorn icon indicating copy to clipboard operation
eslint-plugin-unicorn copied to clipboard

no-empty-file should be configurable

Open tkrotoff opened this issue 1 year ago • 3 comments

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

tkrotoff avatar Nov 08 '23 10:11 tkrotoff

Just use eslint-disable comment for your particular case

dimaMachina avatar Nov 08 '23 12:11 dimaMachina

I agree that we should have an option to allow comments.

sindresorhus avatar Feb 06 '24 06:02 sindresorhus

Hello, this is my first experience in open source. Could you see the implementation?

AekoArray avatar Mar 25 '24 20:03 AekoArray