Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-empty-file should be configurable #2218

Open
tkrotoff opened this issue Nov 8, 2023 · 3 comments · May be fixed by #2300
Open

no-empty-file should be configurable #2218

tkrotoff opened this issue Nov 8, 2023 · 3 comments · May be fixed by #2300

Comments

@tkrotoff
Copy link

tkrotoff commented Nov 8, 2023

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'] }]
    },
  }
]
@dimaMachina
Copy link
Contributor

Just use eslint-disable comment for your particular case

@sindresorhus
Copy link
Owner

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

@AekoArray
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants