Skip to content

Presets for non-js/ts files #3578

Description

@lonix1

This plugin has various rules for non-js/ts files.

But there is no preset for them, so we must explicitly list those rules for the appropriate file types, possibly duplicating them multiple times:

  {
    files: ['**/*.json'],
    plugins: { json, unicorn },
    language: 'json/json',
    extends: [json.configs.recommended],
    rules: {
      'unicorn/comment-content': 'error',
      'unicorn/filename-case': 'error',
      'unicorn/no-abusive-eslint-disable': 'error',
      'unicorn/prefer-https': 'error',
      'unicorn/expiring-todo-comments': 'error',
      'unicorn/no-empty-file': 'error',
      'unicorn/no-manually-wrapped-comments': 'error',
    },
  },

  // depending on how the config is structured, possible also repeat for jsonc, css, md, html...

It would be simpler and less error prone (and DRY) if we could do this instead:

  {
    files: ['**/*.json'],
    plugins: { json, unicorn },
    language: 'json/json',
    extends: [
      json.configs.recommended,
      unicorn.configs.recommendedJson,
    ],
  },

Please consider exposing more presets:

  • unicorn.configs.recommendedJson
  • unicorn.configs.recommendedCss
  • unicorn.configs.recommendedMarkdown
  • unicorn.configs.recommendedHtml
  • possibly also unicorn.configs.agnostic for those rules which work on any file type (comment-content, filename-case, no-abusive-eslint-disable, prefer-https)

Thanks for considering it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions