Skip to content

Add files: [] to the configuration object #3860

@sindresorhus

Description

@sindresorhus

What is the problem you're trying to solve?

In my projects, I prefer to always glob for all CSS files **/*.css and rather ignore the few CSS files I want instead of explicitly specify every file. When having to specify the files, it's easy to forget some files, especially when they're added later.

What solution would you like to see?

I would like to see a top-level setting called files that accepts an array of strings. I could then set files: ['**/*.css'], in my shareable config and use the ignoreFiles in my projects to ignore project-specific files.


There are other benefits to specifying the files in a config object:

  • The run script becomes less messy.
    Before: {"lint": "xo && stylelint foo.js bar.js 'fixtures/*.css'"}
    After: {"lint": "xo && stylelint"}
  • People often forget to quote the globs, which can lead to weird inconsistencies, since if you don't quote them, they're interpreted as shell globs instead of being passed in as strings to stylelint and its glob handling. By specifying the files in the stylelint config, that's not a problem.
  • Editor plugins can read the files config and know which files to lint. It cannot reliably parse the run script commands.

I have had files config in both the AVA and XO projects for years with great success.


This is a duplicate of #2580, but I chose to open a new issue as I feel I have a different use-case and many more arguments for why it makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions